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

Multi step is merging validated data only on top level of the form data object. #533

Open
1 task done
ktarmyshov opened this issue Dec 17, 2024 · 1 comment
Open
1 task done
Labels
enhancement New feature or request
Milestone

Comments

@ktarmyshov
Copy link

  • Before posting an issue, read the FAQ and search the previous issues.

Description
If it's expected behaviour, then please close.
I have complex form (dataType: json), which is filled via several steps (multi step form). Some of the objects, that are processed, sit not in the top of the form object. So, when I set options.validators to the part I want to validate, I must ensure that I have everywhere z.catchall(z.record(z.any())), so the data in the same subtree will not be lost.

There is a code somewhere where the validated data is merged with the current data via {...currentData, ...newValidatedData} on top level - similar issue to #532.

const complexSchema = z.object({
  someTop1: z.object({}),
  someTop2: z.object({
     someLow2: z.record(z.string(), MyStepSchema),  // these are the steps I am processing
  }),
})

const stepValidationSchema = z.object({
    someTop2: z.object({
      someLow2: z.object({
        [myStepId]: MyStepSchema
      }).catchall(z.record(z.any()))
    }).catchall(z.record(z.any()))
  }).catchall(z.record(z.any()));

Maybe it's not a bug, but it would certainly be helpful, if there would be a way to say to superforms - "hey, this is not final validation, but just a step/partial, please merge, not overwrite". Would have less boilerplate to handle.

Thank you!
Konstantin

If applicable, a MRE
See above

@ktarmyshov ktarmyshov added the bug Something isn't working label Dec 17, 2024
@ciscoheat ciscoheat added enhancement New feature or request and removed bug Something isn't working labels Dec 26, 2024
@ciscoheat ciscoheat added this to the v3 milestone Dec 26, 2024
@ciscoheat
Copy link
Owner

Related to #449

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

No branches or pull requests

2 participants