Skip to content

Commit

Permalink
feat(isCreditCard): Fixed regex for Union Pay Credit cards with 81 ra…
Browse files Browse the repository at this point in the history
…nge (#1715)

* Fixes #1680

* Added Tests
  • Loading branch information
shreyassai123 authored Sep 26, 2021
1 parent 69881b6 commit e84623b
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,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})$/;
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}|^(81[0-9]{14,17}))$/;
/* 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 @@ -4575,6 +4575,8 @@ describe('Validators', () => {
'2718760626256570',
'6765780016990268',
'4716989580001715211',
'8171999927660000',
'8171999900000000021',
],
invalid: [
'foo',
Expand Down

0 comments on commit e84623b

Please sign in to comment.