Giter VIP home page Giter VIP logo

creditcard.js's Introduction

creditcard.js

Build Status Dependency Status devDependency Status npm

A simple credit cards validation library in JavaScript.

Project website: https://contaazul.github.io/creditcard.js

Install

creditcard.js is available as a NPM package. You can install through Yarn or NPM:

Yarn

$ yarn add creditcard.js

NPM

$ npm install creditcard.js

Usage

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'

Methods

isValid(number) -> boolean

Checks whether the credit card number format is valid. (See the full list of currently supported cards)

number

Required
Type: string

options

Optional
Type: { cards: string[] }


isExpirationDateValid(month, year) -> boolean

Checks that the expiration date is valid and not expired. (2 or 4 digit years are accepted)

month

Required
Type: string

year

Required
Type: string


isSecurityCodeValid(creditCardNumber, securityCode) -> boolean

Check that the security code is valid according to the type of credit card.

creditCardNumber

Required
Type: string

securityCode

Required
Type: string


getCreditCardNameByNumber(number) -> string

Returns the credit card type from the card number. (See the full list of currently supported cards)

number

Required
Type: string


Suportted credit card types

  • American Express
  • Aura
  • Banescard
  • Cabal
  • Diners
  • Discover
  • Elo
  • Goodcard
  • Hipercard
  • Mastercard
  • Maxxvan
  • Visa

License

MIT © Conta Azul

creditcard.js's People

Contributors

fernahh avatar cirocfc avatar caarlos0 avatar verzola avatar dependabot[bot] avatar dedicio avatar aureliojargas avatar carlosrberto avatar felipeuntill avatar guibrancopc avatar randalmaia avatar ronaldoflima avatar diogomqbm avatar matheuspoleza avatar

Watchers

James Cloos avatar Bruno Bennotti avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.