Skip to content
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

useFieldArray min 1 item validation error changes its location in the errors object #1108

Open
azakharo opened this issue Dec 28, 2024 · 0 comments

Comments

@azakharo
Copy link

Version Number
"@hookform/resolvers": "3.9.1",
"react-hook-form": "7.54.2",
"yup": "1.6.1"

Reproducer:
https://stackblitz.com/edit/vitejs-vite-hufhmrxa?file=src%2FForm%2FForm.tsx

As I understand, this is the same issue as the one described here:
#801

Steps to reproduce

  1. Start app
  2. Input IP and port for the 1st server
  3. Press Submit
  4. Press "Delete" for the 1st server, examine the form's errors
errors: {
    "servers": {
        "message": "servers field must have at least 1 items",
        "type": "min",
        "ref": {
            "name": "servers"
        }
    }
}
  1. Press "Submit" again, examine the form's errors.
errors: {
    "servers": {
        "root": {
            "message": "servers field must have at least 1 items",
            "type": "min",
            "ref": {}
        }
    }
}

Expected behaviour
The validation error must be always at errors.servers.root. It should not change its location.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant