From d4a5ee0a13c8293f390812ddef21bc6969ffd78a Mon Sep 17 00:00:00 2001 From: aemarcuss Date: Sun, 22 Mar 2020 19:28:45 +0000 Subject: [PATCH] feat(isCreditCard): added support for 19 digit cc (#1177) * added support for 19 digit cc added support for 19 digit visa and discover * Update validators.js added tests --- src/lib/isCreditCard.js | 2 +- test/validators.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib/isCreditCard.js b/src/lib/isCreditCard.js index 79a66445b..2b6f2b217 100644 --- a/src/lib/isCreditCard.js +++ b/src/lib/isCreditCard.js @@ -1,7 +1,7 @@ import assertString from './util/assertString'; /* eslint-disable max-len */ -const 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}|6[27][0-9]{14})$/; +const creditCard = /^(?:4[0-9]{12}(?:[0-9]{3,6})?|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,15}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11}|6[27][0-9]{14})$/; /* eslint-enable max-len */ export default function isCreditCard(str) { diff --git a/test/validators.js b/test/validators.js index 49ce190b5..3eadcc072 100644 --- a/test/validators.js +++ b/test/validators.js @@ -3893,6 +3893,7 @@ describe('Validators', () => { '2720428011723762', '2718760626256570', '6765780016990268', + '4716989580001715211', ], invalid: [ 'foo', @@ -3906,6 +3907,7 @@ describe('Validators', () => { 'prefix6234917882863855', '623491788middle2863855', '6234917882863855suffix', + '4716989580001715213', ], }); });