card-validator
Advanced tools
Comparing version 2.0.1 to 2.0.2
@@ -0,1 +1,6 @@ | ||
2.0.2 | ||
===== | ||
- Update `credit-card-type` to 4.0.0 | ||
2.0.1 | ||
@@ -2,0 +7,0 @@ ===== |
{ | ||
"name": "card-validator", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "A library for validating credit card fields", | ||
@@ -22,3 +22,3 @@ "main": "index.js", | ||
"gulp": "^3.8.8", | ||
"gulp-eslint": "^0.6.0", | ||
"gulp-eslint": "^0.14.0", | ||
"gulp-rename": "^1.2.0", | ||
@@ -42,7 +42,7 @@ "gulp-size": "^1.1.0", | ||
"dependencies": { | ||
"credit-card-type": "^4.0.0", | ||
"lodash.assign": "^3.0.0", | ||
"lodash.isnumber": "^3.0.1", | ||
"credit-card-type": "^2.0.0", | ||
"lodash.assign": "^3.0.0", | ||
"lodash.isstring": "^3.0.1" | ||
} | ||
} |
var isString = require('lodash.isstring'); | ||
var extend = require('lodash.assign'); | ||
var luhn10 = require('./luhn-10'); | ||
var getCardType = require('credit-card-type'); | ||
var getCardTypes = require('credit-card-type'); | ||
var isNumber = require('lodash.isnumber'); | ||
@@ -11,14 +11,4 @@ | ||
function isEmptyObject(object) { | ||
var key; | ||
for (key in object) { | ||
if (object.hasOwnProperty(key)) { return false; } | ||
} | ||
return true; | ||
} | ||
function cardNumber(value) { | ||
var cardType, valid, i, maxLength; | ||
var potentialTypes, cardType, valid, i, maxLength; | ||
@@ -31,4 +21,2 @@ if (isNumber(value)) { | ||
if (value === '') { return verification(null, true, false); } | ||
value = value.replace(/\-|\s/g, ''); | ||
@@ -38,6 +26,13 @@ | ||
cardType = getCardType(value); | ||
if (isEmptyObject(cardType)) { return verification(null, false, false); } | ||
potentialTypes = getCardTypes(value); | ||
if (cardType.type === 'unionpay') { // UnionPay is not Luhn 10 compliant | ||
if (potentialTypes.length === 0) { | ||
return verification(null, false, false); | ||
} else if (potentialTypes.length !== 1) { | ||
return verification(null, true, false); | ||
} | ||
cardType = potentialTypes[0]; | ||
if (cardType.type === 'unionpay') { // UnionPay is not Luhn 10 compliant | ||
valid = true; | ||
@@ -44,0 +39,0 @@ } else { |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
105346
2319
+ Addedcredit-card-type@4.1.0(transitive)
- Removedcredit-card-type@2.0.0(transitive)
- Removedlodash._arraycopy@3.0.0(transitive)
- Removedlodash._arrayeach@3.0.0(transitive)
- Removedlodash._baseclone@3.3.0(transitive)
- Removedlodash._basefor@3.0.3(transitive)
- Removedlodash.clonedeep@3.0.2(transitive)
Updatedcredit-card-type@^4.0.0