braintree / credit-card-type

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

Credit Card Type is not checking the current card length #27

Closed saxinte closed 8 years ago

saxinte commented 8 years ago

Basically this MasterCard number: 5100 0811 1222 3332

If we use it this way: creditCardType('51000811122233325100081112223332')); creditCardType('51000811122233321111')); creditCardType('51000811122233320000'));

Found a MasterCard credit card which is wrong, it should test the length of the current card.

Thanks

crookedneighbor commented 8 years ago

If I'm understanding correctly, you're saying that the provided inputs are indicating that the cards are MasterCards, when they are not, because the length of the card is too long to be a MasterCard.

That seems reasonable to me, but I want to hear from some of the other maintainers first with their opinions.

The code that would need to change is here: https://github.com/braintree/credit-card-type/blob/master/index.js#L139

mrak commented 8 years ago

We actually package a different library for validations such as length and Luhn 10: card-validator.

This one is for best-guess identification of a card type. The card-validator library should be able to account for your scenarios.

crookedneighbor commented 8 years ago

^ Makes sense to me.