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: 2 additions & 0 deletions src/lib/isCreditCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ const cards = {
amex: /^3[47][0-9]{13}$/,
dinersclub: /^3(?:0[0-5]|[68][0-9])[0-9]{11}$/,
discover: /^6(?:011|5[0-9][0-9])[0-9]{12,15}$/,
instapayment: /^63[7-9][0-9]{13}$/,
jcb: /^(?:2131|1800|35\d{3})\d{11}$/,
maestro: /^(5018|5020|5038|6304|6759|6761|6763)[0-9]{8,15}$/,
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
45 changes: 45 additions & 0 deletions test/validators.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6382,11 +6382,15 @@ describe('Validators', () => {
'4716989580001715211',
'8171999927660000',
'8171999900000000021',
'5018000000000009',
'6370000000000009',
],
invalid: [
'foo',
'foo',
'5398228707871528',
'637000000000000901',
'501800000000000901234567890',
'2718760626256571',
'2721465526338453',
'2220175103860763',
Expand Down Expand Up @@ -6670,6 +6674,47 @@ describe('Validators', () => {
});


it('should validate Maestro provided credit cards', () => {
test({
validator: 'isCreditCard',
args: [{ provider: 'Maestro' }],
valid: [
'5018000000000009',
'5020000000000005',
'5038000000000005',
'6304000000000000',
'6759000000000000',
],
invalid: [
'foo',
'5019000000000000',
'4716461583322103',
'375556917985515',
],
});
});


it('should validate InstaPayment provided credit cards', () => {
test({
validator: 'isCreditCard',
args: [{ provider: 'InstaPayment' }],
valid: [
'6370000000000009',
'6380000000000007',
'6390000000000005',
],
invalid: [
'foo',
'6360000000000001',
'6400000000000002',
'4716461583322103',
'375556917985515',
],
});
});


it('should validate identity cards', () => {
const fixtures = [
{
Expand Down
Loading