zodValidator from @tanstack/zod-form-adapter deprecated
Describe the bug
zodValidator from zod is deprecated in version 3.24.0 and zod suggests we use standardSchemaValidator instead but there is no such thing in @tanstack/zod-form-adapter in version 0.41.3.
Your minimal, reproducible example
https://stackblitz.com/github/tanstack/form/tree/main/examples/react/zod?embed=1&theme=dark&preset=node&file=src/index.tsx
Steps to reproduce
- open index.tsx
- you see zodValidator deprecation
Expected behavior
I expected alternative for zodValidator but there is no such thing in @tanstack/zod-form-adapter
How often does this bug happen?
None
Screenshots or Videos
No response
Platform
OS: windows Browser: Google Chrome Version: 132
TanStack Form adapter
react-form
TanStack Form version
0.41.3
TypeScript version
No response
Additional context
No response
Since zod 3.24 implemented the Standard Schema interface, you no longer need an adapter to use it on TanStack Form. You can safely remove zodValidator and it will keep working fine as onChange: YourZodSchema :)
Example: https://tanstack.com/form/latest/docs/framework/react/examples/standard-schema
👀
Docs are not up to date with this, see e.g. https://tanstack.com/start/latest/docs/framework/react/guide/middleware#the-inputvalidator-method
Upon following the docs the form gets validated as expected.
const form = useForm({
defaultValues: {
name: "",
email: ""
},
validators: {
onSubmit: formSchema,
},
onSubmitInvalid: async ({ value }) => {
toast.error("Please fix the errors in the form before submitting.");
},
onSubmit: async ({ value }) => {
toast.success(
"Your request has been submitted. We will get back to you soon!",
);
},
});
onSubmit expects type FormValidators but the working code uses zod object to perform validation. This causes my NextJS build to fail. Even VScode highlights this type error. Below is what it is supposed to be but it does not perform validation
validators: {
onSubmit: formSchema.parse,
},
I used ts-ignore to skip this type error