-
-
Notifications
You must be signed in to change notification settings - Fork 347
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
zod-form-adapter turns all errors into one comma separated string, meta.errors assumes an array #942
Comments
refs TanStack#942 Signed-off-by: Pascal Küsgen <[email protected]>
I think there is a bug in the definition of the It is currently defined as: export type ValidationError = undefined | false | null | string Searching through the codebase there are places where const validatesPromises: Promise<ValidationError | undefined>[] = []
const linkedPromises: Promise<ValidationError | undefined>[] = [] This doesn't make sense as Then there's this:
where errors is an array of ValidationError - where the items of the array could be of type How to fix it?My guess is that the ValidationError should be Related Issues
|
refs TanStack#942 Signed-off-by: Pascal Küsgen <[email protected]>
Describe the bug
At the moment the zod-form-adapter's zodValidator
validate
andvalidateAsync
functions turn the errors that zod reports into a comma separated string:When we want to display the Error(s) to the User the
field.state.meta.errors
field returns an arrayValidationError[]
which now only has one entry (the comma separated string.Your minimal, reproducible example
https://stackblitz.com/edit/tanstack-form-r8vroz?file=src%2Findex.tsx
Steps to reproduce
#
does not match the min-length nor the regex (letters a-Z)Expected behavior
As a User
I expect
field.state.meta.errors
to be an array (type:ValidationError[]
) with a length that matches the number of errors that resulted from the zod schema validationBUT
I'm seeing an array (type:
ValidationError[]
) with the length of1
no matter how many validation errors occurred.How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
Not platform related
TanStack Form adapter
react-form
TanStack Form version
0.32.0
TypeScript version
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: