Assign errors for all fields #11820
-
Let's say, i don't want to duplicate a complex (or needs other data only available in the backend) validation in the frontend and backend, so i just have it in the backend. The backend now creates an object/array of all the fields with their errors. Is there a way to tell this library, "hey here are all the errors, please make them available in 'formState.errors'"? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Do you mean with something like |
Beta Was this translation helpful? Give feedback.
Do you mean with something like
setError
?https://react-hook-form.com/docs/useform/seterror
You probably want to loop over each of your errors and do setError to map the field to the error