Skip to content

Veevalidate input, number validation leads to "... must be a number type, but the final value was: NaN." #4993

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

Open
2 of 5 tasks
Nils3311 opened this issue Feb 21, 2025 · 0 comments

Comments

@Nils3311
Copy link

Nils3311 commented Feb 21, 2025

What happened?

When an input is validated against the number rule and is first filled and then cleared, it produces the error "... must be a number type, but the final value was: NaN." For a number input, I expect it to be "null" when empty, even after the field has been filled and cleared again.

I attempted to resolve this using a model value with a setter that emits null, a watcher, and other methods. Initially, it emits null, but then immediately after that emits an empty string ''. Without the VeeValidate form context, the input emits the correct null when using a setter to fix this problem.

Of course it could be solved with a transform and replace the '' with null. But I guess thats not way it should be handled and very repetitive for every number validation.

This issue also appears in several examples on VeeValidate. For instance, in the currency example at https://vee-validate.logaretm.com/v4/examples/value-formatting/.

Reproduction steps

  1. Go to "https://vee-validate.logaretm.com/v4/examples/value-formatting/"
  2. Fill in a value in the input
  3. Remove the value from the input
  4. See the error "amount must be a number type, but the final value was: NaN."

I would expect the output to be "null" and not a string.

Version

Vue.js 3.x and vee-validate 4.x

What browsers are you seeing the problem on?

  • Firefox
  • Chrome
  • Safari
  • Microsoft Edge

Relevant log output

Demo link

https://stackblitz.com/edit/vee-validate-v4-input-masks-cfnp7vio?file=src%2FApp.vue

Code of Conduct

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

1 participant