Skip to content

bluestealth/credit-card-validator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

credit-card-validator

NPM Version NPM Downloads

Process Visa, American Express, Discover, Mastercard, and JCB Credit Card Numbers

Installation

$ npm install credit-card-validator

API

var creditCardValidator = require('credit-card-validator')

creditCardValidator.getCardName(accountString)

Processes a string containing a partial or full credit card number and returns the card type.

creditCardValidator.getFaClass(accountString)

Processes a string contaning a partial or full credit card number and returns the font-awesome class related to the given card.

creditCardValidator.getCardAccountNumLengths(accountString)

Processes a string containing a partial or full credit card number and returns the accepted account number lengths for a given card type.

creditCardValidator.getCardSecurityNumLengths(accountString)

Processes a string containing a partial or full credit card number and returns the accepted security number lengths for a given card type.

creditCardValidator.validateCardLength(accountString)

Processes a string containing a full credit card number and returns true if the length of the account number given is acceptable for a given type of card.

creditCardValidator.validateCardSecurityCodeLength(accountString, securityString)

Processes a string containing a partial or full credit card number along with a security code and returns true if the length of the security code is acceptable for a given type of card.

creditCardValidator.validateCardLuhn(accountString)

Processes a string containing a credit card number and returns true if the luhn checksum is correct.

creditCardValidator.validateCard(accountString)

Processes a string containing a full credit card number and returns true if the card number is the right length for the card type and it has a valid luhn checksum.

creditCardValidator.validateCardAndSecCode(accountString, securityString)

Processes a string containing a full credit card number and returns true if the account number and security code are the correct length for the card type and it has a valid luhn checksum.

Example

var creditCardValidator = require('credit-card-validator');
var validCard = creditCardValidator.validateCardAndSecCode('4111 1111 1111 1111', '412');

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published