resolvers
resolvers copied to clipboard
Inconsistent reporting of root errors
Describe the bug
Currently, root errors are onChange
/append
written tomyArray.message
and onSubmit
written to myArray.root
.
To Reproduce Steps to reproduce the behavior:
- Go to https://codesandbox.io/s/zod-resolver-root-inconsistency-m57c85?file=/src/App.tsx
- Click on "Add"
- Click on "Add" again
- See that the root error is written to
formState.errors.people.message
- Click on "Submit"
- See that the root error is written to
formState.errors.people.root.message
Codesandbox link (Required) https://codesandbox.io/s/zod-resolver-root-inconsistency-m57c85?file=/src/App.tsx
Expected behavior
I would expect that the array errors are always written to myArray.root
, no matter if onChange
or onSubmit
is called.
Versions
react-hook-form
: 7.46.0
@hookform/resolvers
: 3.3.1
I have the same issue