Skip to content

Commit e84623b

Browse files
feat(isCreditCard): Fixed regex for Union Pay Credit cards with 81 range (#1715)
* Fixes #1680 * Added Tests
1 parent 69881b6 commit e84623b

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/lib/isCreditCard.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import assertString from './util/assertString';
22

33
/* eslint-disable max-len */
4-
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})$/;
4+
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}))$/;
55
/* eslint-enable max-len */
66

77
export default function isCreditCard(str) {

test/validators.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4575,6 +4575,8 @@ describe('Validators', () => {
45754575
'2718760626256570',
45764576
'6765780016990268',
45774577
'4716989580001715211',
4578+
'8171999927660000',
4579+
'8171999900000000021',
45784580
],
45794581
invalid: [
45804582
'foo',

0 commit comments

Comments
 (0)