From 0eaded683150141a7aa504663718d6182b224284 Mon Sep 17 00:00:00 2001 From: "Brian T. Whaley" Date: Mon, 22 Aug 2022 15:54:49 -0400 Subject: [PATCH] changed providers to optional parameter in options object --- src/lib/isCreditCard.js | 3 ++- test/validators.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lib/isCreditCard.js b/src/lib/isCreditCard.js index 2e44ba3ed..0a874c9cf 100644 --- a/src/lib/isCreditCard.js +++ b/src/lib/isCreditCard.js @@ -11,11 +11,12 @@ const cards = { visa: /^(?:4[0-9]{12})(?:[0-9]{3,6})?$/, }; /* eslint-disable max-len */ -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}))$/; +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}))$/; /* eslint-enable max-len */ export default function isCreditCard(card, options = {}) { assertString(card); + const { provider } = options; const sanitized = card.replace(/[- ]+/g, ''); if (provider && provider.toLowerCase() in cards) { // specific provider in the list diff --git a/test/validators.js b/test/validators.js index 293a8a3a9..761e82e3a 100644 --- a/test/validators.js +++ b/test/validators.js @@ -5397,7 +5397,7 @@ describe('Validators', () => { }); }); - + it('should validate identity cards', () => { const fixtures = [ {