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

Field-Level validation for root and nested fields #1039

Open
alena-apanovich opened this issue Feb 2, 2024 · 0 comments
Open

Field-Level validation for root and nested fields #1039

alena-apanovich opened this issue Feb 2, 2024 · 0 comments

Comments

@alena-apanovich
Copy link

Are you submitting a bug report or a feature request?

Bug Report

What is the current behavior?

Prerequisites

  1. I have two Fields on my UI:
  2. name property for the first field equals "test".
  3. name property for the second field equals "test.inner".
  4. validate property for the first field equals () => 'Required'.
  5. validate property for the first field equals () => 'Required2'.

Example 1

The first rendered field on UI is the "test" field

Actual result:

  • "test" field receives broken error {"0":"R","1":"e","2":"q","3":"u","4":"i","5":"r","6":"e","7":"d","inner":"Required2"}
  • "test.inner" field receives the correct error: "Required2"

Example 2

The first rendered field on UI is the "test.inner" field

Actual result:

  • "test.inner" field doesn't receive an error at all
  • "test" field receives the correct error: "Required"

What is the expected behavior?

  1. The result doesn't depend on the Fields rendering order on the UI.
  2. Fields receive error represented as a string (specified in the validate callback for the field):
  • "test" field will receive "Required" error.
  • "test.inner" field will receive "Required2" error.

Sandbox Link

The two examples are presented in CodeSandbox

What's your environment?

react-final-form: 6.5.0
final-form: 4.20.1
Node: 18.19.0
Browser: Latest Chrome
MacOS Apple M1

Other information

A similar issue was fixed for FieldArray: #160.

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