GithubHelp home page GithubHelp logo

luhn's Introduction

npm version Build Status GitHub license

luhn

Validation and control key generation for credit cards (and more) using Luhn algorithm.

Usage

In node.js

var Luhn = require('luhn-js');

Luhn.isValid('44542738505150162'); // false
Luhn.isValid('44540661970241257'); // true

Luhn.generate('4454066197024125'); // 44540661970241257

Luhn.getRemainder('44543353847144279'); // 8

API

isValid(value) -> Boolean

Check requirements.
Returns if the Luhn check digit is valid.

Required

  • Value must be not Null
  • Value must be of type String
  • Value must respect format ^[0-9]{2,}$

generate(value) -> String

Check requirements.
Returns the Luhn check digit appended to the value.

Required

  • Value must be not Null
  • Value must be of type String
  • Value must respect format ^[0-9]{1,}$

getRemainder(value) -> Number

Does NOT check requirements.
Returns the Luhn remainder.

Note: getRemainder(value) === 0 is equivalent to isValid(value). You may want to use this method instead of isValid if you ensure argument requirements on your side.

Required

  • Value must be not Null
  • Value must be of type String

luhn's People

Contributors

edumdum avatar

Stargazers

 avatar Mohamad J. Makki avatar  avatar Dumitru Uzun avatar Stanislav avatar Max Kurapov avatar Jems avatar Jason Di Benedetto avatar Ian Bytchek avatar Marc-Aurèle DARCHE avatar Marcus Vinicius Monteiro de Souza avatar Oleg avatar  avatar  avatar

Watchers

James Cloos avatar Mohamad J. Makki avatar

luhn's Issues

Not working with IE11

It seems to me that this package is not working in the old IE11 browser. Can you confirm that?

Failed to minify the code from this file

There is an error when run build

Creating an optimized production build...
Failed to compile.

Failed to minify the code from this file:

    ./node_modules/luhn-js/src/luhn.js:15

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.