braintree / credit-card-type

A library for determining credit card type
MIT License
985 stars 154 forks source link

Incorrect regexps for prefixPattern #80

Closed webbie closed 6 years ago

webbie commented 6 years ago

prefixPattern regexps are incorrect for all card types except Visa, they have $ sign at the end of regexp: /^(3|34|37)$/ /^(3|3[0689]|30[0-5])$/ ..

crookedneighbor commented 6 years ago

This is intentional.

You'll see that in all those cases, the exactPattern regex will take over when it reaches the end of the prefixPattern. Amex, Diner's Club.

IE, it's only intended to match the prefix of the card.

Do you see a specific case where it's wrong and is causing the card detection to be incorrect?

webbie commented 6 years ago

Ah got it.. actually, I was using these regexs for my custom validation, with full credit card numbers (that is difference, didn't realized your library takes numbers as user types them).