-
-
Notifications
You must be signed in to change notification settings - Fork 582
Closed
Description
Describe the bug
When calling form.validate('change') manually (e.g., after mounting conditional fields), field.errors contains a different structure than when validation runs through normal onChange events.
- Normal onChange validation:
field.errors=[{ "code": "too_small", ...restOfZodError }] - Manual
form.validate('change')call:field.errors=[[{ "code": "too_small", ...restOfZodError }]]
The errors are wrapped in an extra array when using the manual validate call.
Your minimal, reproducible example
https://stackblitz.com/edit/tanstack-form-wawszjkd?file=src%2Findex.tsx
Steps to reproduce
- Click checkbox to mount conditional fields
- Expect error to show up, but error is wrapped in array (see logs for more info)
Expected behavior
For errors from form.validate(...) to have the same output as an organic change event. I'd expect to see an error immediately after clicking the checkbox.
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
- Stackblitz
- Mac
TanStack Form adapter
react-form
TanStack Form version
1.27.7
TypeScript version
No response
Additional context
Chatting through this in Discord as well: convo
It also seems like if mount, unmount, then mount again, form.validate(...) produces the correct result.
Bernardo-ive and Kyujenius
Metadata
Metadata
Assignees
Labels
No labels