GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - juspay/card-validator: Card validation helpers for payment forms.

This repository was archived by the owner on Dec 29, 2025. It is now read-only.
BranchesTags
Open more actions menu

Latest commit

 

History

57 Commits
57 Commits

Folders and files

NameName
Last commit message
Last commit date
dist
dist
 
 
src
src
 
 
CONTRIBUTING.md
CONTRIBUTING.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
index.js
index.js
 
 
package.json
package.json
 
 

Repository files navigation

Card Validator

Generic helpers for card number, expiry and CVV validations

npm version

Usage:

Import the library and initialize card object.

Install from npm:

npm i @juspay/simple-card-validator --save

var cardValidator = require('simple-card-validator');

Or, you can simply use the file from dist/validator.js if you are not using node/npm.

var card = new cardValidator('4242-4242-4242-4242');

Getting card details

card.getCardDetails(); This would output, card brand and different validation outputs like below:

{ card_type: 'visa',
  valid: true,
  luhn_valid: true,
  length_valid: true,
  cvv_length: [ 3 ],
  gaps: [ 4, 8, 12 ],
  supported_lengths: [ 16 ],
  max_length: 16 }

Output format

Field Description Type
card_type The card issuer for the provided card String
valid Are the card details valid Boolean
luhn_valid Is the card number valid Boolean
length_valid If the card number length is valid Boolean
cvv_length If the CVV/CAVV length is valid Array [ Integer ]
gaps Gaps for UI as printed in cards Array [ Integer ]
supported_lengths Supported lengths for the card type Array [ Integer ]
max_length Maximum length for the card type Integer

Validations

To simply validate a card, call: card.validateCard(); The result will be a validity boolean.

For validating expiry date, card.validateExpiry('12/2018');

Additionally, the base date can be set for expiry validations. The base month and date can be provided by using, card.setBaseDate(month, year);

eg: card.setBaseDate('02', '2016');

For validating CVV, use: card.validateCvv(111); CVV will be validated based on the brand of the card.

Contribution

Read through the development guidelines.

License

MIT license. Copyright © 2018 - juspay.in.

About

Card validation helpers for payment forms.

Topics

amexcardcard-validatorcredit-cardmastercardpaymentsrupayvisa

Resources

Readme
MIT license

Contributing

Contributing
Activity
Custom properties

Stars

29 stars

Watchers

17 watching

Forks

23 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.