Skip to content

Commit 0eaded6

Browse files
author
Brian T. Whaley
committed
changed providers to optional parameter in options object
1 parent c931036 commit 0eaded6

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/lib/isCreditCard.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ const cards = {
1111
visa: /^(?:4[0-9]{12})(?:[0-9]{3,6})?$/,
1212
};
1313
/* eslint-disable max-len */
14-
const creditCard = /^(?:4[0-9]{12}(?:[0-9]{3,6})?|5[1-5][0-9]{14}|(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}|6(?:011|5[0-9][0-9])[0-9]{12,15}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11}|6[27][0-9]{14}|^(81[0-9]{14,17}))$/;
14+
const allCards = /^(?:4[0-9]{12}(?:[0-9]{3,6})?|5[1-5][0-9]{14}|(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}|6(?:011|5[0-9][0-9])[0-9]{12,15}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11}|6[27][0-9]{14}|^(81[0-9]{14,17}))$/;
1515
/* eslint-enable max-len */
1616

1717
export default function isCreditCard(card, options = {}) {
1818
assertString(card);
19+
const { provider } = options;
1920
const sanitized = card.replace(/[- ]+/g, '');
2021
if (provider && provider.toLowerCase() in cards) {
2122
// specific provider in the list

test/validators.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5397,7 +5397,7 @@ describe('Validators', () => {
53975397
});
53985398
});
53995399

5400-
5400+
54015401
it('should validate identity cards', () => {
54025402
const fixtures = [
54035403
{

0 commit comments

Comments
 (0)