Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with validating cvv #31

Closed
RachelTakeuchi-minted opened this issue Aug 17, 2016 · 2 comments
Closed

Problem with validating cvv #31

RachelTakeuchi-minted opened this issue Aug 17, 2016 · 2 comments

Comments

@RachelTakeuchi-minted
Copy link

RachelTakeuchi-minted commented Aug 17, 2016

I'm trying to validate a cvv for an American Express card, which expects a length of 4. I have a scenario where value=123 and maxLength=4 and I expect the cvv to not be valid, but it always says it is valid.

Does cvv validation just check for maxLength, and if it's less than that then it's valid? That doesn't make sense to me.. The problem is occurring in the min function, where it will always return the minimum DEFAULT_LENGTH if the maxLength I pass in is greater than it.

@crookedneighbor
Copy link
Contributor

Hi @RachelTakeuchi-minted, it looks like our documentation around the cvv, postalCode, and the expiration date methods is incorrect. It says those return Boolean values, but instead, they return an Object with this signature:

{
  isValid: false, 
  isPotentiallyValid: true
}

So

var validityInfo = cardValidator.cvv('123', 4);
validityInfo.isPotentiallyValid; // true
validityInfo.isValid; // false

Does that help?

We'll update our documentation to correct the errors.

@jahirfiquitiva
Copy link

jahirfiquitiva commented Apr 24, 2024

I'm having a similar issue... I have set maxLength to 4, but it is also considering 4 as the minLength, which means the validation checks that the CVV length is exactly the value of maxLength, which I don't think is what we expect when the property is named maxLength... I would expect any number between 1 and maxLength (4) digits to be valid.

I think this function needs an additional argument for minLength

if (value.length < Math.min.apply(null, maxLength)) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants