T
TanStack6mo ago
like-gold

Error Using Zod as Form Validator

I was planning to migrate my form from RHF to TF and tried implementing a simple user validator using Zod, but I encountered an error
No description
9 Replies
like-gold
like-goldOP6mo ago
No description
flat-fuchsia
flat-fuchsia6mo ago
what version of zod are you using? you might be outdated, as you need zod to implement the Standard Schema for this to work
like-gold
like-goldOP6mo ago
I am using
"zod": "^3.23.8"
"zod": "^3.23.8"
like-gold
like-goldOP6mo ago
GitHub
Release v3.24.0 · colinhacks/zod
Implement @standard-schema/spec This is the first version of Zod to implement the Standard Schema spec. This is a new community effort among several validation library authors to implement a common...
like-gold
like-goldOP6mo ago
I just updated zod to the latest version (v3.24.2), but I'm still seeing an error:
No description
No description
stormy-gold
stormy-gold6mo ago
You have to specify which validator should run against your schema.
validators: { onChange: userSchema }
validators: { onChange: userSchema }
Instead of:
validators: userSchema
validators: userSchema
like-gold
like-goldOP6mo ago
Still error
like-gold
like-goldOP6mo ago
Great! This works well. I've tried that before, but I didn't know I also needed to update the Zod.
validators: { onChange: userSchema }
validators: { onChange: userSchema }
Thank you @ksgn @Ajaco @Luca | LeCarbonator

Did you find this page helpful?