react-hook-form / resolvers

📋 Validation resolvers: Yup, Zod, Superstruct, Joi, Vest, Class Validator, io-ts, Nope, computed-types, typanion, Ajv, TypeBox, ArkType, Valibot, effect-ts and VineJS
https://react-hook-form.com/
MIT License
1.71k stars 155 forks source link

Inconsistent reporting of root errors #627

Open Kirdock opened 11 months ago

Kirdock commented 11 months ago

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

achour94 commented 2 months ago

I have the same issue