-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding Maestro credit card ranges #2223
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ const cards = { | |
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}$/; | ||
maestro: /^(493698|50(0[0-9]{3}|4(1[0-7][0-4]|7[6-9][0-9]))|50[678](7[789][0-9]|9[0-9]{2})|5[6-9]|63|67|6)\d{6,19}$/, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same nitpick as above: could you kindly correctly sort by alphabet, -> maestro should be before mastercard :-) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not 100% sure the regexp is 100% correct, e.g. this would return
according to the source you provided the length is supposed to be |
||
unionpay: /^(6[27][0-9]{14}|^(81[0-9]{14,17}))$/, | ||
visa: /^(?:4[0-9]{12})(?:[0-9]{3,6})?$/, | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5968,6 +5968,8 @@ describe('Validators', () => { | |
'4716989580001715211', | ||
'8171999927660000', | ||
'8171999900000000021', | ||
'6759649826438453', | ||
'6799990100000000019', | ||
], | ||
invalid: [ | ||
'foo', | ||
|
@@ -6002,6 +6004,32 @@ describe('Validators', () => { | |
}); | ||
}); | ||
|
||
it('should validate Maestro provided credit cards', () => { | ||
test({ | ||
validator: 'isCreditCard', | ||
args: [{ provider: 'Maestro' }], | ||
valid: [ | ||
'6759649826438453', | ||
'6799990100000000019', | ||
'6283875070985593', | ||
], | ||
invalid: [ | ||
'foo', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should add some tests for too short numbers as well :-) |
||
'2222155765072228', | ||
'2225855203075256', | ||
'2720428011723762', | ||
'2718760626256570', | ||
'36050234196908', | ||
'375556917985515999999993', | ||
'4716461583322103', | ||
'4716-2210-5188-5662', | ||
'4716989580001715211', | ||
'4929 7226 5379 7141', | ||
'5398228707871527', | ||
'6234917882863855suffix', | ||
], | ||
}); | ||
}); | ||
|
||
it('should validate AmEx provided credit cards', () => { | ||
test({ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.