-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Open
Description
Version Number
"react-hook-form": "^7.62.0", "@hookform/resolvers": "^5.2.1",
Codesandbox/Expo snack
https://codepen.io/ferhatavdic/pen/KwVZPNq
Steps to reproduce
When no items are in the list:
- open the browser console and observe the error message path (it is also written in the logs)
- click trigger validation and look at the logs
- click submit form and look at the logs
When trigger validation is clicked, the error message path is error.message
When submit form is clicked, the error message path is error.root.message
To handle the message i need to consider both paths and i believe that shouldn't be the case given the error comes from the same useController that points directly to the array, and not the entire form or any other parent object.
Expected behaviour
error.message
should always be the path. Not error.root.message
What browsers are you seeing the problem on?
Firefox
Relevant log output
Browser console logs:
=== ✅ Calling handleSubmit (onSubmit) ===
Error object:
Object { message: "at_least_1_item", type: <
5F3E
span class="pl-pds">"", ref: {…} }
error.message: at_least_1_item
error.root?.message: undefined
Error object: Object { root: {…} }
root:
Object { message: "at_least_1_item", type: "", ref: {…} }
<prototype>: Object { … }
error.message: undefined
error.root?.message: at_least_1_item
=== 🔄 Calling trigger('items') ===
Error object:
Object { message: "at_least_1_item", type: "", ref: {…} }
error.message: at_least_1_item
error.root?.message: undefined
Code of Conduct
- I agree to follow this project's Code of Conduct
Metadata
Metadata
Assignees
Labels
No labels