Skip to content

Commit e807004

Browse files
committed
fix(isCreditCard): anchor Mastercard pattern to 16 digits
1 parent 3d2f4b3 commit e807004

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

src/lib/isCreditCard.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const cards = {
66
dinersclub: /^3(?:0[0-5]|[68][0-9])[0-9]{11}$/,
77
discover: /^6(?:011|5[0-9][0-9])[0-9]{12,15}$/,
88
jcb: /^(?:2131|1800|35\d{3})\d{11}$/,
9-
mastercard: /^5[1-5][0-9]{2}|(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}$/, // /^[25][1-7][0-9]{14}$/;
9+
mastercard: /^(5[1-5][0-9]{2}|(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720))[0-9]{12}$/,
1010
unionpay: /^(6[27][0-9]{14}|^(81[0-9]{14,17}))$/,
1111
visa: /^(?:4[0-9]{12})(?:[0-9]{3,6})?$/,
1212
};

test/validators.test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6574,10 +6574,13 @@ describe('Validators', () => {
65746574
'2225855203075256',
65756575
'2718760626256570',
65766576
'2720428011723762',
6577+
'5105105105105100',
65776578
'5398228707871527',
65786579
],
65796580
invalid: [
65806581
'foo',
6582+
'5108',
6583+
'5100000000000000000000003',
65816584
'36050234196908',
65826585
'375556917985515',
65836586
'375556917985515999999993',

0 commit comments

Comments
 (0)