#Activate onChange validation only after submitting once?
8 messages · Page 1 of 1 (latest)
this is assigned once on mount, in which case it's always going to be false.
you'll have to manually write the login schema safeParse if you want it to act conditionally
is there a way to achieve the same StandardSchema behaviour conditionally?
As in not having to manually return the error object?
I got it to work but it seems hacky
useForm({
...
validators: {
onChange: ({ value, formApi }) => {
if (formApi.state.submissionAttempts > 0) {
return standardSchemaValidators.validate(
{
value,
validationSource: "form",
},
loginSchema
);
}
return undefined;
},
onSubmit: loginSchema,
...
I think there should be a better example of using standardSchemaValidators
I might make a PR for the example