Skip to content

issue: useFieldArray root error is set to the actual field array root object, not the .root property using resolvers #801

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task done
Moshyfawn opened this issue Jul 28, 2022 · 5 comments · Fixed by #802
Labels
question Further information is requested

Comments

@Moshyfawn
Copy link
Contributor

Moshyfawn commented Jul 28, 2022

Version Number

7.34.0

Codesandbox/Expo snack

https://codesandbox.io/s/immutable-dawn-v1iigh?file=%2Fsrc%2FApp.tsx

Steps to reproduce

  1. Go to csb
    2.1 See the errors object shape in the console
{
  "fields": {
    "message": "The fields list is too small",
    "type": "too_small",
    "ref": {
      "name": "fields"
    }
  }
}

2.2 See the field array error message paragraph <p> content is empty

{errors.fields && <p>{errors.fields.root?.message}</p>}

Expected behaviour

The errors object shape is the same between using the "native" useFieldArray and resolver validation from the 7.34.0 release

What browsers are you seeing the problem on?

No response

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@Moshyfawn
Copy link
Contributor Author

It might be more of a discussion than an issue, but I feel like we need to address the discrepancy between the API at least in the docs

@bluebill1049
Copy link
Member

thanks, @Moshyfawn that's a resolver, I haven't considered supporting it just yet. maybe the next feature? Is this probably something to do in the resolver repo?

@bluebill1049 bluebill1049 added the question Further information is requested label Jul 28, 2022
@Moshyfawn
Copy link
Contributor Author

I wasn't quite sure if I should file this issue at react-hook-form/resolvers or even react-hook-form/documentation. Since this repo aggregates all the infra, I left it here :P

I feel like we should have some note somewhere, whether it's a note in docs for the resolvers or formState section or at least an issue ppl can search for know that we know lol (hence the long issue title with a bunch of "keywords" to possible match someone's search query for this issue)

@bluebill1049
Copy link
Member

I just release I haven't updated the doc as well :( too busy... i will do it this weekend. I will ping you there and you can help me on the wording as well 🤗

@Moshyfawn
Copy link
Contributor Author

I just release I haven't updated the doc as well :( too busy... i will do it this weekend. I will ping you there and you can help me on the wording as well 🤗

Yep, sounds good! I'm currently swamped with a new release as well, so if you can ping me when you want to work on docs, I can for sure help you update the info!

@bluebill1049 bluebill1049 transferred this issue from react-hook-form/react-hook-form Jul 29, 2022
bluebill1049 added a commit that referenced this issue Jul 31, 2022
* doc update to include rules for useFieldArray

* include a mini example

* include info for build in validation only

* Update src/data/en/api.tsx

Co-authored-by: moshyfawn <[email protected]>

* Update src/data/en/api.tsx

Co-authored-by: moshyfawn <[email protected]>

* Update src/data/en/api.tsx

Co-authored-by: moshyfawn <[email protected]>

* Update src/data/en/api.tsx

Co-authored-by: moshyfawn <[email protected]>

* Update src/data/en/api.tsx

Co-authored-by: moshyfawn <[email protected]>

* Update api.tsx

* prettier

* prettier

Co-authored-by: moshyfawn <[email protected]>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants