resolvers icon indicating copy to clipboard operation
resolvers copied to clipboard

Inconsistent reporting of root errors

Open Kirdock opened this issue 1 year ago • 1 comments

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:

  1. Go to https://codesandbox.io/s/zod-resolver-root-inconsistency-m57c85?file=/src/App.tsx
  2. Click on "Add"
  3. Click on "Add" again
  4. See that the root error is written to formState.errors.people.message
  5. Click on "Submit"
  6. 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

Kirdock avatar Sep 04 '23 13:09 Kirdock

I have the same issue

achour94 avatar Jun 07 '24 12:06 achour94