Skip to content

Commit 1ab5728

Browse files
committed
adding Maestro credit card ranges
1 parent b958bd7 commit 1ab5728

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ Validator | Description
102102
**isBoolean(str [, options])** | check if the string is a boolean.<br/>`options` is an object which defaults to `{ loose: false }`. If `loose` is 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']).
103103
**isBtcAddress(str)** | check if the string is a valid BTC address.
104104
**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 }`.
105-
**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.
105+
**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.
106106
**isCurrency(str [, options])** | check if the string is a valid currency amount.<br/><br/>`options` is an object which defaults to `{ symbol: '$', require_symbol: false, allow_space_after_symbol: false, symbol_after_digits: false, allow_negatives: true, parens_for_negatives: false, negative_sign_before_digits: false, negative_sign_after_digits: false, allow_negative_sign_placeholder: false, thousands_separator: ',', decimal_separator: '.', allow_decimal: true, require_decimal: false, digits_after_decimal: [2], allow_space_after_digits: false }`.<br/>**Note:** The array `digits_after_decimal` is filled with the exact number of digits allowed not a range, for example a range 1 to 3 will be given as [1, 2, 3].
107107
**isDataURI(str)** | check if the string is a [data uri format][Data URI Format].
108108
**isDate(str [, options])** | check if the string is a valid date. e.g. [`2002-07-15`, new Date()].<br/><br/> `options` is an object which can contain the keys `format`, `strictMode` and/or `delimiters`.<br/><br/>`format` is a string and defaults to `YYYY/MM/DD`.<br/><br/>`strictMode` is a boolean and defaults to `false`. If `strictMode` is set to true, the validator will reject strings different from `format`.<br/><br/> `delimiters` is an array of allowed date delimiters and defaults to `['/', '-']`.

src/lib/isCreditCard.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const cards = {
77
discover: /^6(?:011|5[0-9][0-9])[0-9]{12,15}$/,
88
jcb: /^(?:2131|1800|35\d{3})\d{11}$/,
99
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}$/;
10+
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}$/,
1011
unionpay: /^(6[27][0-9]{14}|^(81[0-9]{14,17}))$/,
1112
visa: /^(?:4[0-9]{12})(?:[0-9]{3,6})?$/,
1213
};

test/validators.test.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5437,6 +5437,9 @@ describe('Validators', () => {
54375437
'4716989580001715211',
54385438
'8171999927660000',
54395439
'8171999900000000021',
5440+
'5899162000000000',
5441+
'6759649826438453',
5442+
'6799990100000000019',
54405443
],
54415444
invalid: [
54425445
'foo',
@@ -5471,6 +5474,32 @@ describe('Validators', () => {
54715474
});
54725475
});
54735476

5477+
it('should validate Maestro provided credit cards', () => {
5478+
test({
5479+
validator: 'isCreditCard',
5480+
args: [{ provider: 'Maestro' }],
5481+
valid: [
5482+
'6759649826438453',
5483+
'6799990100000000019',
5484+
'6283875070985593',
5485+
],
5486+
invalid: [
5487+
'foo',
5488+
'2222155765072228',
5489+
'2225855203075256',
5490+
'2720428011723762',
5491+
'2718760626256570',
5492+
'36050234196908',
5493+
'375556917985515999999993',
5494+
'4716461583322103',
5495+
'4716-2210-5188-5662',
5496+
'4716989580001715211',
5497+
'4929 7226 5379 7141',
5498+
'5398228707871527',
5499+
'6234917882863855suffix',
5500+
],
5501+
});
5502+
});
54745503

54755504
it('should validate AmEx provided credit cards', () => {
54765505
test({

0 commit comments

Comments
 (0)