Type error when using standardSchemaValidator on Vue #1083
-
I'm trying to migrate from
The old form using const userForm = useForm({
defaultValues: {
firstName: "",
lastName: "",
} as UserForm,
validatorAdapter: zodValidator(), // 👈 here is the deprecated error
validators: {
onChange: ZodSchema, // 👈 My Zod schema
},
onSubmit: async ({ value }) => {
console.log({ value });
},
}); After seeing the error of the zodValidator being deprecated, I tried using the standardSchemaValidator by following the React Example which is updated: https://tanstack.com/form/latest/docs/framework/react/examples/standard-schema const ZodSchema = z.object({
firstName: z
.string()
.min(3, '[Zod] You must have a length of at least 3')
.startsWith('A', "[Zod] First name must start with 'A'"),
lastName: z.string().min(3, '[Zod] You must have a length of at least 3'),
})
const userForm = useForm({
defaultValues: {
firstName: "Asdsd",
lastName: "Doe",
},
validators: {
onChange: ZodSchema, // 👈 Here is the type error
},
onSubmit: async ({ value }) => {
console.log({ value });
},
}); I'm using exactly the same implementation that's on the docs, but it throws a type error that says Details for the type errorType 'ZodObject<{ firstName: ZodString; lastName: ZodString; }, "strip", ZodTypeAny, { firstName: string; lastName: string; }, { firstName: string; lastName: string; }>' is not assignable to type 'FormValidateFn<{ firstName: string; lastName: string; }, undefined> | StandardSchemaV1<{ firstName: string; lastName: string; }, unknown> | undefined'.ts- I'm using Vue with Tanstack with the following versions: |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
My bad. I had to bump zod from |
Beta Was this translation helpful? Give feedback.
My bad. I had to bump zod from
3.23
to3.24
. Now it's fixed.