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

card-validator

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

card-validator - npm Package Compare versions

Comparing version 2.2.5 to 2.2.6

6

CHANGELOG.md

@@ -0,1 +1,7 @@

2.2.6
=====
- Fixes cases where card numbers were incorrectly reported as `isPotentiallyValid: false` when more digits could still be entered
- issue #20 and PR #21
2.2.5

@@ -2,0 +8,0 @@ =====

2

package.json
{
"name": "card-validator",
"version": "2.2.5",
"version": "2.2.6",
"description": "A library for validating credit card fields",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -12,3 +12,3 @@ var isString = require('lodash/lang/isString');

function cardNumber(value) {
var potentialTypes, cardType, valid, i, maxLength;
var potentialTypes, cardType, isPotentiallyValid, isValid, i, maxLength;

@@ -36,22 +36,19 @@ if (isNumber(value)) {

if (cardType.type === 'unionpay') { // UnionPay is not Luhn 10 compliant
valid = true;
isValid = true;
} else {
valid = luhn10(value);
isValid = luhn10(value);
}
maxLength = Math.max.apply(null, cardType.lengths);
for (i = 0; i < cardType.lengths.length; i++) {
if (cardType.lengths[i] === value.length) {
return verification(cardType, valid, valid);
isPotentiallyValid = (value.length !== maxLength) || isValid;
return verification(cardType, isPotentiallyValid, isValid);
}
}
maxLength = Math.max.apply(null, cardType.lengths);
if (value.length < maxLength) {
return verification(cardType, true, false);
}
return verification(cardType, false, false);
return verification(cardType, value.length < maxLength, false);
}
module.exports = cardNumber;
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