1.0.8 • Published 10 years ago

credit-card-validator v1.0.8

Weekly downloads
260
License
LGPLv3+
Repository
github
Last release
10 years ago

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');

LGPLv3+

1.0.8

10 years ago

1.0.7

10 years ago

1.0.6

10 years ago

1.0.5

10 years ago

1.0.4

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago

0.0.1

10 years ago