ui
ui copied to clipboard
Textarea + Form not throwing validation errors
Hello
I think the example on the docs does not work as intended.
I would expect it to show an error when the typing a value that breaches the zod schema but it does not.
Thanks for the all the great components
Hi @zeevo, by default the useForm hook by react-hook-form has the mode set to onSubmit, this mean that the validation is applied only when the form is submitted. You can change it to onChange to get the behaviour you're expecting.
const form = useForm<z.infer<typeof FormSchema>>({
resolver: zodResolver(FormSchema),
mode: `onChange`
})
For further information check the react-hook-form docs
Thanks for the tip @dan5py !