Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lib/isCreditCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const cards = {
dinersclub: /^3(?:0[0-5]|[68][0-9])[0-9]{11}$/,
discover: /^6(?:011|5[0-9][0-9])[0-9]{12,15}$/,
jcb: /^(?:2131|1800|35\d{3})\d{11}$/,
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}$/;
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}$/;
unionpay: /^(6[27][0-9]{14}|^(81[0-9]{14,17}))$/,
visa: /^(?:4[0-9]{12})(?:[0-9]{3,6})?$/,
};
Expand Down
3 changes: 3 additions & 0 deletions test/validators.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6612,6 +6612,9 @@ describe('Validators', () => {
],
invalid: [
'foo',
'5108', // short partial string (was wrongly accepted due to missing group around the alternation)
'5108foo', // start-anchored only, trailing chars ignored
'5398228707871527x', // valid 16-digit Mastercard with trailing junk
'36050234196908',
'375556917985515',
'375556917985515999999993',
Expand Down