-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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 after 4.12.0 update
#4565
Comments
Thanks for reporting this, should be fixed with the next release. |
Has this been fixed? @logaretm In my case neither the accountNumber: toTypedSchema(
zod.coerce
.string()
.trim()
.toUpperCase()
.regex(/^[A-Z0-9]*$/, "can only have letters and numbers!")
.min(6, "must be 6 characters long!")
.max(6, "must be 6 characters long!")
.transform((val) => val.toUpperCase())
), Expected |
I ran some more tests and figured out this works for |
Yeah. That PR works for our cases right now. I haven't tried every scenario but I've been adapting our product to use vee-validate and really like it overall, but I much prefer the patten of scoping rules within specific components such as a |
Any update? |
After fiddling with the source code, I realized the best solution for me was to simply apply the transform after the parsing. |
What happened?
I'm using the
.transform()
method to edit the data to be sent to the form submit function.After the update to 4.12.0, the transform is not applied anymore to the
values
I get back fromhandleSubmit
.Note that type infers works: the api handler function is typed on the
output
of the schema and by passing thevalues
fromhandleSubmit
gives me no errors.I can confirm it works with the
4.11.8
release.Repdoduction:
https://stackblitz.com/edit/vue3-script-setup-with-vite-ujk93v?file=src%2FApp.vue
v4.12.1:
The values are parsed by the schema validator, but the original ones are passed to the
handleSubmit
.v4.11.8:
Try to set the vee-validate and @vee-validate/zod packages to 4.11.8 and run the example again, you will see the transformed data is passed through the
handleSubmit
now.Reproduction steps
Version
Vue.js 3.x and vee-validate 4.x
What browsers are you seeing the problem on?
Relevant log output
No response
Demo link
https://stackblitz.com/edit/vue3-script-setup-with-vite-ujk93v?file=src%2FApp.vue
Code of Conduct
The text was updated successfully, but these errors were encountered: