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.0.1 to 2.0.2

5

CHANGELOG.md

@@ -0,1 +1,6 @@

2.0.2
=====
- Update `credit-card-type` to 4.0.0
2.0.1

@@ -2,0 +7,0 @@ =====

8

package.json
{
"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 {

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