bendrucker / angular-credit-cards

Angular directives for parsing and validating credit card inputs
MIT License
328 stars 98 forks source link

cc-exp validation error #144

Closed AndrewLosikhin closed 7 years ago

AndrewLosikhin commented 7 years ago

Steps to reproduce:

  1. Open the demo page http://embed.plnkr.co/uE47aZ/preview
  2. Put in Expiration month value "20"
  3. Put in Expiration year value "1"

AR: ccForm.$error.ccExp is false

ER ccForm.$error.ccExp must be true because both of params are invalid.

bendrucker commented 7 years ago

So this just comes down to the fact that ccExp watches the model values: https://github.com/bendrucker/angular-credit-cards/blob/master/src/expiration.js#L45-L50. Angular won't set those until it sees a valid result. I don't want to change it to watching view values since that'd require duplicate parsing and wouldn't respect any custom parsers you appended.

This should, however, be doable by also watching month.$valid && year.$valid and returning false early from ccExp when that's false.

Can't get to this right away but if you want to submit a PR I'd be happy to review.

bendrucker commented 7 years ago

Closing based on inactivity, I'm happy to review a PR if anyone is interested in landing this functionality