card-validator
Advanced tools
Comparing version 2.2.5 to 2.2.6
@@ -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 @@ ===== |
{ | ||
"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; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
87176
1764