Assign errors for all fields #11820
Answered
by
nicostombros
D3strukt0r
asked this question in
Q&A
-
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.
Answered by
nicostombros
Apr 26, 2024
Replies: 1 comment 1 reply
-
Do you mean with something like |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
D3strukt0r
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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