You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As you can see, there is no associated error in the formState for the child. To get the error, one has to make sure, that there is no error thrown on the parent by the schema validation. For example, make the test function on the parent return true.
This can't be controlled by selective trigger calls.
We have a real world example, where we want to validate field level input and at the same time check, if the field levels intersect/overlap with their siblings. While the validation is possible with yup, we can't get both errors at the same time in the formState when using react-hook-form. The current workaround is to run the validation manually and use setError to set the second error (and clear it manually).
I'm wondering, why react-hook-form is designed like this. Literally removing the errors, in this case, returned by yup. And if this is an edge case, that is simply irrelevant?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Apparently, field level errors are removed/not passed through, when they are nested and both parent AND child throw an error.
Here is an example:
https://codesandbox.io/s/elastic-hooks-7vqci?file=/src/App.js:430-597
As you can see, there is no associated error in the
formState
for the child. To get the error, one has to make sure, that there is no error thrown on the parent by the schema validation. For example, make thetest
function on the parent returntrue
.This can't be controlled by selective
trigger
calls.We have a real world example, where we want to validate field level input and at the same time check, if the field levels intersect/overlap with their siblings. While the validation is possible with
yup
, we can't get both errors at the same time in theformState
when using react-hook-form. The current workaround is to run the validation manually and usesetError
to set the second error (and clear it manually).I'm wondering, why react-hook-form is designed like this. Literally removing the errors, in this case, returned by yup. And if this is an edge case, that is simply irrelevant?
Beta Was this translation helpful? Give feedback.
All reactions