Skip to content

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

Description

@azakharo

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:
react-hook-form/documentation#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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions