Skip to content

Commit

Permalink
Merge branch 'master' of github.com:ContaAzul/creditcard.js
Browse files Browse the repository at this point in the history
  • Loading branch information
fernahh committed May 25, 2018
2 parents 4f3ad40 + 4cd2866 commit 774d6a5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
4 changes: 1 addition & 3 deletions src/creditCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ class CreditCard {

for (let i = 0; i < CREDIT_CARD_LIST.length; i++) {
let creditcard = CREDIT_CARD_LIST[i];
let regex = new RegExp(creditcard.regexpFull);

if (regex.test(number))
if (creditcard.regexpFull.test(number))
return creditcard.name;
}

Expand Down
16 changes: 8 additions & 8 deletions src/creditCardList.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
const CREDIT_CARD_LIST = [
{
name: 'Elo',
regexpFull: '^(401178|401179|431274|438935|451416|457393|457631|457632|504175|627780|636297|636368|(506699|5067[0-6]\d|50677[0-8])|(50900\d|5090[1-9]\d|509[1-9]\d{2})|65003[1-3]|(65003[5-9]|65004\d|65005[0-1])|(65040[5-9]|6504[1-3]\d)|(65048[5-9]|65049\d|6505[0-2]\d|65053[0-8])|(65054[1-9]|6505[5-8]\d|65059[0-8])|(65070\d|65071[0-8])|65072[0-7]|(65090[1-9]|65091\d|650920)|(65165[2-9]|6516[6-7]\d)|(65500\d|65501\d)|(65502[1-9]|6550[3-4]\d|65505[0-8]))[0-9]{10,12}'
regexpFull: /^(401178|401179|431274|438935|451416|457393|457631|457632|504175|627780|636297|636368|(506699|5067[0-6]\d|50677[0-8])|(50900\d|5090[1-9]\d|509[1-9]\d{2})|65003[1-3]|(65003[5-9]|65004\d|65005[0-1])|(65040[5-9]|6504[1-3]\d)|(65048[5-9]|65049\d|6505[0-2]\d|65053[0-8])|(65054[1-9]|6505[5-8]\d|65059[0-8])|(65070\d|65071[0-8])|65072[0-7]|(65090[1-9]|65091\d|650920)|(65165[2-9]|6516[6-7]\d)|(65500\d|65501\d)|(65502[1-9]|6550[3-4]\d|65505[0-8]))[0-9]{10,12}/
}, {
name: 'Diners',
regexpFull: '^3(?:0[0-5]|[68][0-9])[0-9]{11}$'
regexpFull: /^3(?:0[0-5]|[68][0-9])[0-9]{11}$/
}, {
name: 'Discover',
regexpFull: '^6(?:011|5[0-9]{2}|4[4-9][0-9]{1}|(22(12[6-9]|1[3-9][0-9]|[2-8][0-9]{2}|9[01][0-9]|92[0-5]$)[0-9]{10}$))[0-9]{12}$'
regexpFull: /^6(?:011|5[0-9]{2}|4[4-9][0-9]{1}|(22(12[6-9]|1[3-9][0-9]|[2-8][0-9]{2}|9[01][0-9]|92[0-5]$)[0-9]{10}$))[0-9]{12}$/
}, {
name: 'Hipercard',
regexpFull: '^(38[0-9]{17}|60[0-9]{14})$'
regexpFull: /^(38[0-9]{17}|60[0-9]{14})$/
}, {
name: 'Amex',
regexpFull: '^3[47][0-9]{13}$'
regexpFull: /^3[47][0-9]{13}$/
}, {
name: 'Aura',
regexpFull: '^50[0-9]{14,17}$'
regexpFull: /^50[0-9]{14,17}$/
}, {
name: 'Mastercard',
regexpFull: '^(5[1-5][0-9]{14}|2221[0-9]{12}|222[2-9][0-9]{12}|22[3-9][0-9]{13}|2[3-6][0-9]{14}|27[01][0-9]{13}|2720[0-9]{12})$'
regexpFull: /^(5[1-5][0-9]{14}|2221[0-9]{12}|222[2-9][0-9]{12}|22[3-9][0-9]{13}|2[3-6][0-9]{14}|27[01][0-9]{13}|2720[0-9]{12})$/
}, {
name: 'Visa',
regexpFull: '^4[0-9]{12}(?:[0-9]{3})?$'
regexpFull: /^4[0-9]{12}(?:[0-9]{3})?$/
}
];

Expand Down

0 comments on commit 774d6a5

Please sign in to comment.