Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

luhn-js

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

luhn-js

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

  • 1.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8.6K
decreased by-3.55%
Maintainers
1
Weekly downloads
 
Created
Source

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

Keywords

FAQs

Package last updated on 28 Oct 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc