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

Validating with Zod not applying the .transform() method for useField() #4713

Open
4 of 5 tasks
jbogheand opened this issue Mar 26, 2024 · 1 comment
Open
4 of 5 tasks

Comments

@jbogheand
Copy link

jbogheand commented Mar 26, 2024

What happened?

I'm using the .transform() method to edit the data to be sent to the form submit function.
It works well for fields declared with defineField() method but not for custom inputs / fields declared with useField() method.

In the second case, the value is submitted without being transformed, even though it is being validated. Neither the transform() function nor the zod string transformations ( like toUppoerCase() ) work.

image

Reproduction steps

  1. Create a custom input component using useField() with a Zod validation schema
  2. Use it in a form context
  3. Type a valid value and submit
  4. The value is correctly validated but not transformed

!!! I have note tested for Safari

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

No response

Demo link

https://stackblitz.com/edit/vitejs-vite-mrsjdx?file=src%2FApp.vue,src%2Fcomponents%2FForm1.vue,src%2Fcomponents%2FForm2.vue,src%2Fcomponents%2FInputText.vue&terminal=dev

Code of Conduct

@jbogheand
Copy link
Author

The issue is similar to this one #4565, where the problem seems to have been solved partially.

This PR seems to be related as well #4692, possibly offering a solution.

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