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

Cannot validate complete nested object #828

Open
oxc opened this issue Nov 29, 2024 · 0 comments
Open

Cannot validate complete nested object #828

oxc opened this issue Nov 29, 2024 · 0 comments

Comments

@oxc
Copy link

oxc commented Nov 29, 2024

Describe the bug and the expected behavior

I'm trying to use form.validate.getButtonProps to validate a complete fieldset, i.e. a field that consists only of nested fields.

The validation will produce the errors of the subfields, but it since for the fieldset field no value is submitted, it will never land in the list of validatedFields, and thus not have any errors assigned.

I would have expected that validating a nested object field causes all subfields of this field to be validated, and have their errors reported.

Suggestion
When sending a validate intent, always validate all fields for which the field name is a prefix.

Or, make it configurable with a recursive flag on the ValidationIntent payload

Conform version

v1.2.2

Steps to Reproduce the Bug or Issue

Here is a sandbox that demonstrates the problem:
https://codesandbox.io/p/devbox/smoosh-frost-gf79qd?workspaceId=1702db6b-2042-4a59-957b-ee67bb3c5948

I've added two buttons to the ToDo List example, a "Validate Task" button, which triggers the described behaviour (of not doing anything, basically).
For comparison, there is also a "Validate Task Content" button, which works as expected.

Steps

  • Click on Todo list
  • Click on Add task
  • Click on Validate Task
    • I would have expected the task content to become red
  • Click on Validate Task Content
    • This works, but it validates only one leaf field

But there is no way to validate an entire field with subfields.

What browsers are you seeing the problem on?

No response

Screenshots or Videos

No response

Additional context

No response

@oxc oxc changed the title Cannot validate nested object fields Cannot validate complete nested object Nov 29, 2024
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