From 800dded29e41211080af72e544342b591b894415 Mon Sep 17 00:00:00 2001 From: Risejandi Autida Date: Tue, 6 Sep 2016 21:35:23 +0800 Subject: [PATCH] Add support to MasterCard's 2-Series BINs --- lib/isCreditCard.js | 4 ++-- test/validators.js | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/isCreditCard.js b/lib/isCreditCard.js index ff73bba90..d3938edc3 100644 --- a/lib/isCreditCard.js +++ b/lib/isCreditCard.js @@ -12,7 +12,7 @@ var _assertString2 = _interopRequireDefault(_assertString); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /* eslint-disable max-len */ -var creditCard = /^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11})|62[0-9]{14}$/; +var creditCard = /^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11})|62[0-9]{14}$/; /* eslint-enable max-len */ function isCreditCard(str) { @@ -42,4 +42,4 @@ function isCreditCard(str) { } return !!(sum % 10 === 0 ? sanitized : false); } -module.exports = exports['default']; \ No newline at end of file +module.exports = exports['default']; diff --git a/test/validators.js b/test/validators.js index f45eac558..ba8dab3d9 100644 --- a/test/validators.js +++ b/test/validators.js @@ -1600,11 +1600,18 @@ describe('Validators', function () { '6234698580215388', '6226050967750613', '6246281879460688', + '2222155765072228', + '2225855203075256', + '2720428011723762', + '2718760626256570' ], invalid: [ 'foo', 'foo', '5398228707871528', + '2718760626256571', + '2721465526338453', + '2220175103860763' ], }); });