Skip to content

Skip CVC validation when card number validation fails#809

Open
joshpensky wants to merge 9 commits into
masterfrom
josh/des-705-fix-cvc-validation-when-card-number-changes
Open

Skip CVC validation when card number validation fails#809
joshpensky wants to merge 9 commits into
masterfrom
josh/des-705-fix-cvc-validation-when-card-number-changes

Conversation

@joshpensky

Copy link
Copy Markdown
Contributor

Why

Fixes a bug where CVC validation fails automatically when card number validation fails

Since CVC validation is based on card number, we should wait until the card number is valid first

Before

Screen.Recording.2026-02-02.at.16.41.14.mov

After

Screen.Recording.2026-02-02.at.16.40.37.mov

How

  • Update CVC validation to skip validation if cardValidation.isValid is false

@joshpensky joshpensky self-assigned this Feb 2, 2026
@joshpensky joshpensky requested a review from a team as a code owner February 2, 2026 16:42
@joshpensky joshpensky added the bug Something isn't working label Feb 2, 2026
@changeset-bot

changeset-bot Bot commented Feb 2, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f805ed2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 14 packages
Name Type
@evervault/card-validator Patch
@evervault/ui-components Patch
@evervault/react-native Patch
@evervault/evervault-react-native Patch
shared Patch
@evervault/ui-components-e2e-tests Patch
evervault-expo-example Patch
react-native-example Patch
@evervault/browser Patch
@evervault/inputs Patch
example-react-google-wallet Patch
@evervault/browser-e2e-tests Patch
e2e-tests-ui-components-vanilla-server Patch
@evervault/inputs-e2e-tests Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

!cardValidation.isValid
) {
return undefined;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might be splitting hairs, and maybe overcomplicating so feel free to ignore

But I reckon when a CVC is entered that would be invalid for any card type (basically any CVC <3 digits), we should persist the invalid warning. However, if the CVC could be valid depending on the card type, that's when we should clear the warning.

On another note, would it be better to try to decouple CVC validation in the card-validator from card number validation? It feels here we are hijacking the validateCVC behaviour, instead of improving it

Comment thread packages/card-validator/index.ts Outdated
return {
cvc: null,
isValid: false,
reason: "invalid_number",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as my comment bellow. I wonder if CVC validation should just be decoupled from card validation.

The reason being is that conceptually the validateCVC function should return true or false only. Imo the card number being valid should be irrelevant (the brand the card number matches is a different story)

pseudo-code cvc validation suggestion:

const { brands } = validateNumber(cardNumber); // used only to check if number matches any brands

if (cvc valid for any brands) {
  return true;
}

if (brands && cvc not valid for any brands) {
  return false;
}

if (no brands && cvc.length < 3) {
  return false;
}

return true;

@jmorgadosoares jmorgadosoares force-pushed the josh/des-705-fix-cvc-validation-when-card-number-changes branch from a763cbe to 0aa1bab Compare June 10, 2026 15:09
@jmorgadosoares jmorgadosoares force-pushed the josh/des-705-fix-cvc-validation-when-card-number-changes branch from 3690251 to 4f6f274 Compare June 10, 2026 15:12
@jmorgadosoares jmorgadosoares force-pushed the josh/des-705-fix-cvc-validation-when-card-number-changes branch from 4f6f274 to ee93c67 Compare June 12, 2026 14:18

@joshpensky joshpensky left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for taking this! left a few comments about splitting this out

Comment thread packages/shared/src/useForm.ts Outdated
Comment thread packages/card-validator/index.ts Outdated
Comment thread packages/card-validator/index.ts Outdated
Comment thread .changeset/spicy-mayflies-give.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Development

Successfully merging this pull request may close these issues.

3 participants