-
-
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?
Adding Maestro credit card ranges #2223
Conversation
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.
update readme as well
@linediconsine this would be useful for the @faker-js/faker project. Would you be interested in rebasing this PR to get it merged, or if you don't have time I could make a new PR? |
78921e6
to
a816c87
Compare
@rubiin Updated Readme and solved conflicts Thanks |
a816c87
to
1ab5728
Compare
1ab5728
to
1cfa3ad
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2223 +/- ##
==========================================
- Coverage 99.95% 99.95% -0.01%
==========================================
Files 107 107
Lines 2454 2449 -5
Branches 619 619
==========================================
- Hits 2453 2448 -5
Partials 1 1 ☔ View full report in Codecov by Sentry. |
@profnandaa @tux-tn @pano9000 could you please review my PR ? |
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.
Regexp needs some tweaking still :-)
@@ -99,7 +99,7 @@ Validator | Description | |||
**isBoolean(str [, options])** | check if the string is a boolean.<br/>`options` is an object which defaults to `{ loose: false }`. If `loose` is set to false, the validator will strictly match ['true', 'false', '0', '1']. If `loose` is set to true, the validator will also match 'yes', 'no', and will match a valid boolean string of any case. (e.g.: ['true', 'True', 'TRUE']). | |||
**isBtcAddress(str)** | check if the string is a valid BTC address. | |||
**isByteLength(str [, options])** | check if the string's length (in UTF-8 bytes) falls in a range.<br/><br/>`options` is an object which defaults to `{ min: 0, max: undefined }`. | |||
**isCreditCard(str [, options])** | check if the string is a credit card number.<br/><br/> `options` is an optional object that can be supplied with the following key(s): `provider` is an optional key whose value should be a string, and defines the company issuing the credit card. Valid values include `['amex', 'dinersclub', 'discover', 'jcb', 'mastercard', 'unionpay', 'visa']` or blank will check for any provider. | |||
**isCreditCard(str [, options])** | check if the string is a credit card number.<br/><br/> `options` is an optional object that can be supplied with the following key(s): `provider` is an optional key whose value should be a string, and defines the company issuing the credit card. Valid values include `['amex', 'dinersclub', 'discover', 'jcb', 'mastercard', 'unionpay', 'visa','maestro']` or blank will check for any provider. |
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.
- could you kindly correctly alphabetically sort the values?
- nitpicking: could you get rid of the extra space at the end the of the line :-)
@@ -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 comment
The 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 comment
The 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 true
for the following number:
6312345
- which has a length of 7 digits only
according to the source you provided the length is supposed to be
lengths: [12, 13, 14, 15, 16, 17, 18, 19]
'6283875070985593', | ||
], | ||
invalid: [ | ||
'foo', |
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.
we should add some tests for too short numbers as well :-)
kind of related PR: #1701 |
Add Maestro brand credit cards ranges regexp
I used the ranges provided
credit-card-type
hereThis should solve a problem that I am facing with some Mastro cards on a work project
Checklist