medipass / react-payment-inputs

A React Hook & Container to help with payment card input fields.
https://medipass.github.io/react-payment-inputs
342 stars 62 forks source link

Incorrect behavior of CVC validator if credit card type is not known #4

Closed szimek closed 5 years ago

szimek commented 5 years ago

CVC validator doesn't work correctly, i.e. returns true for invalid (e.g. 1 digit only) CVC number, if there's no credit card type available yet. This may happen if someone tries to fill out CVC field, without filling out credit card number field yet, though I admit that it's probably very, very unlikely 😄. Combined with automatic focus of the next field, in this case ZIP code field, it automatically moves focus to this field after typing any digit.

I'm not sure if it handles all cases, but maybe it would be ok to assume that CVC is invalid, if it has less than 3 digits? Additionally, once credit card type is known, it could check if CVC should have 3 or 4 digits.

szimek commented 5 years ago

@jxom Thanks!