Use Braintree card-validator
justinobney opened this issue · comments
https://github.com/braintree/card-validator
Provides a little better response that allows only showing the errors once you can be sure they are errors
{
card: {
niceType: 'American Express',
type: 'american-express',
gaps: [4, 10],
lengths: [15],
code: {name: 'CID', size: 4}
},
isPotentiallyValid: true, // if false, indicates there is no way the card could be valid
isValid: true // if true, number is valid for submission
If I get a chance, I will try to fork the repo and try out with Braintree
What’s the distinction between this and creditcards’ functionality? What issues are you having?
It looks like isPotentiallyValid
is the same as creditcards
giving you an "eager type". You can check if (type && !valid)
to get the same effect.
For showing errors, I usually wait for the user to submit the form then show all validation errors.
You are correct. I must have not been paying attention and missed this. I was going through a lot of components before I found yours.
Thanks!
Anytime, thanks for using the lib.