Skip to content

Commit

Permalink
feat(isCreditCard): added support for 19 digit cc (#1177)
Browse files Browse the repository at this point in the history
* added support for 19 digit cc

added support for 19 digit visa and  discover

* Update validators.js

added tests
  • Loading branch information
aemarcuss authored Mar 22, 2020
1 parent 2a3ad84 commit d4a5ee0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/isCreditCard.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions test/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -3893,6 +3893,7 @@ describe('Validators', () => {
'2720428011723762',
'2718760626256570',
'6765780016990268',
'4716989580001715211',
],
invalid: [
'foo',
Expand All @@ -3906,6 +3907,7 @@ describe('Validators', () => {
'prefix6234917882863855',
'623491788middle2863855',
'6234917882863855suffix',
'4716989580001715213',
],
});
});
Expand Down

0 comments on commit d4a5ee0

Please sign in to comment.