card-validator
Advanced tools
Comparing version 2.2.3 to 2.2.4
@@ -0,1 +1,8 @@ | ||
2.2.4 | ||
===== | ||
- Fixes validation of space separated expiration dates | ||
- Fixes potential validity of slashless expiration dates | ||
- Fixes validation of expiration dates that are too long | ||
2.2.3 | ||
@@ -2,0 +9,0 @@ ===== |
{ | ||
"name": "card-validator", | ||
"version": "2.2.3", | ||
"version": "2.2.4", | ||
"description": "A library for validating credit card fields", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
var expirationYear = require('./expiration-year'); | ||
var isArray = require('lodash/lang/isArray'); | ||
@@ -6,5 +7,9 @@ function parseDate(value) { | ||
if (value.match('/')) { | ||
if (/\//.test(value)) { | ||
value = value.split(/\s*\/\s*/g); | ||
} else if (/\s/.test(value)) { | ||
value = value.split(/ +/g); | ||
} | ||
if (isArray(value)) { | ||
return { | ||
@@ -16,8 +21,8 @@ month: value[0], | ||
len = value[0] === '0' || value.length > 5 || value.length === 4 ? 2 : 1; | ||
len = value[0] === '0' || value.length > 5 ? 2 : 1; | ||
if (value.length === 3 && value[0] === '1') { | ||
year = value.substr(1, 2); | ||
if (value[0] === '1') { | ||
year = value.substr(1); | ||
yearValid = expirationYear(year); | ||
if (!yearValid.isValid) { | ||
if (!yearValid.isPotentiallyValid) { | ||
len = 2; | ||
@@ -31,3 +36,3 @@ } | ||
month: month, | ||
year: value.substr(month.length, 4) | ||
year: value.substr(month.length) | ||
}; | ||
@@ -34,0 +39,0 @@ } |
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
86396
1761