Duplicate Errors when using same Schema for onChange and onMount validation
Hello! I'm trying to run the same validation onMount and onChange:
As soon as i start typing in the "firstName" Field I get the error for "lastName" twice.
I thought i might have to start by clearing all errors in the onChange handler but I have no Idea how i could "compose" a custom onChange validator function with a StandardSchemaValidator.
Somthing like:
5 Replies
grumpy-cyan•7mo ago
How are you displaying the Error(s)?
adverse-sapphireOP•7mo ago
currently like this
grumpy-cyan•7mo ago
That sounds weird…
should remove onMount error when the form is touched – https://github.com/TanStack/form/blob/v1.0.0/packages/form-core/tests/FormApi.spec.ts#L1576-L1603Can you make a Stackblitz reproduction?
adverse-sapphireOP•7mo ago
Sure:
https://stackblitz.com/edit/vitejs-vite-ynrth1qu?file=src%2Fcomponents%2Ftext-fields.tsx
steps:
- enter something in firstName field
- see that lastName has duplicate Validation messages.
grumpy-cyan•7mo ago
Might be worth opening an Issue for that on Github
This might be the Issue I ran into as well when I upgraded to v1
I moved my onChange validations to the fields and only use onMount and onSubmit on the form