-
-
Notifications
You must be signed in to change notification settings - Fork 100
Description
- Before posting an issue, read the FAQ and search the previous issues.
Description
I would like to add a validation rule to ensure at least one checkbox is checked for each record.
I'm currently using z.record(z.string(), z.array(z.string()).min(1))
for the schema.
However, I found that validation indeed happened but the error was not added when I reassign the array with the checked options,
although it does work if the schema is with a fixed key (checkboxes: z.array(z.string()).min(1)
).
After looking into it a bit, I found that the diff logic suggests that the first element has changed (checkbox.key1.0
) but it does not match with the path having errors (checkbox.key1
) so the error is not added.

I have made a MRE with the link below. Can you please look into it? I appreciate your help.
If applicable, a MRE
Use this template project to create a minimal reproducible example that you can link to here: https://sveltelab.dev/github.com/rayrw/superforms-checkbox-validation (right click to open in a new tab)