Skip to content

Commit

Permalink
changed providers to optional parameter in options object
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian T. Whaley committed Aug 22, 2022
1 parent c931036 commit 0eaded6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/lib/isCreditCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -5397,7 +5397,7 @@ describe('Validators', () => {
});
});


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

0 comments on commit 0eaded6

Please sign in to comment.