-
-
Notifications
You must be signed in to change notification settings - Fork 200
Closed
Labels
Description
Describe the bug
When using superstruct resolver with an array
field type the the error
object is an array
instead of an object per the React Hook Form documentation.
To Reproduce
Steps to reproduce the behavior:
- Go to https://codesandbox.io/s/competent-kalam-v98vd?file=/src/App.js
- Click on "Submit Query" button
- Observe the
arrayField
errors property is an array instead of an object. This is the unexpected behavior. - Observe that
nonArrayField
errors property is an object as expected.
Expected behavior
Per the documentation the errors for a field should be an object with a message
and type
property and not an array.
Desktop (please complete the following information):
- OS: MacOS 10.15.7
- Browser: Firefox
- Version 88.0b4
Additional context
In this instance it appears that parseErrorSchema produces an object like this:
{ "arrayField.0": { "message": "Expected one of `"John,"Jane"`, but received: "Bill"", "type": "enums" } }
which when passed to toNestError
from @hookform/resovlers
returns an Array
jorisre, FahriDevZ and dcordz