A simple credit cards validation library in JavaScript.
creditcard.js available as a NPM package. You can install through npm:
$ npm install --save creditcard.js
import {
isValid,
isExpirationDateValid,
isSecurityCodeValid,
getCreditCardNameByNumber
} from 'creditcard.js';
isValid('4916108926268679'); // returns true
isExpirationDateValid('02', '2020'); // returns true
isSecurityCodeValid('4556603578296676', '250'); // returns true
getCreditCardNameByNumber('4539578763621486'); // returns 'Visa'
Name | Returns |
---|---|
CreditCard#isValid(cardNumber) |
Boolean |
CreditCard#isExpirationDateValid(month, year) |
Boolean |
CreditCard#isSecurityCodeValid(cardNumber, securityCode) |
Boolean |
CreditCard#getCreditCardNameByNumber(cardNumber) |
String |
Latest ✔ | Latest ✔ | 9+ ✔ | Latest ✔ | 8+ ✔ |
MIT © Conta Azul