#serverValidation with zod
1 messages · Page 1 of 1 (latest)
It should be. Whether you write the field level errors manually or have it generated from a schema's response, it should allow for server responses to map to fields.
The issue points at this not happening though, so this cannot be avoided by simply doing it manually. It seems to be a problem of actually parsing the errors to have it be field level errors
Thanks for the quick clarification!
Since server responses should map to field-level errors, I’d like to open a PR to implement the parsing step.
Does this approach look good?
Plan:
1. Add a parser that converts schema errors (e.g. Zod ZodError.issues) into the same field-error map used on the client (form/global vs field-scoped).
2. Use it in the server-validation path so field.state.meta.errors updates and subscribed inputs re-render.
3. Add tests and a short docs example for “Server validation with Zod”.
Sounds good! Here's some pointers in case you go forward with it:
- There is already a helper for parsing standard schemas which client-side validators use. Hopefully it's accessible for server stuff. Check
standardSchemaValidatorfor reference - Use the client-side parsing as example. What's likely happening is that the server error is not doing the same parsing as the client-side errors.
- Unit tests would be great! We're lacking them for general framework e2e, let alone SSR examples.
Hi! I'm working on server-side validation error propagation to fields.
I found that we can use validators.onSubmit to server validation.
Would it be appropriate to use the onSubmit validator to handle server-side validation errors and let them propagate naturally through the existing validation flow? This would avoid the need for manual state manipulation and provide a cleaner, more consistent approach.
Or is there a different recommended pattern for server-side field error propagation?
Thanks!
I have PR that already resolved the that issue.
so i suggest some new way to solve the problem
hmm … code coverage aside, has someone reached out to confirm that their issue is fixed with this PR?