TanStackT
TanStack7mo ago
49 replies
faint-white

Form Validation scope

Is the scope of form.store.state.isValid for the whole form including all withForm components or is it for the currently mounted component? I'm trying to find a way to track which steps have errors by setting a Zustand property if that mounted withForm component has any field errors without having to check every single field. So I was hoping to use the isValid property from the store state via useStore. But if that's for all fields across all components, then it's not as useful.

What I'm doing is using field level validations of onSubmit and onChange. I'm probably going to change the onSubmit to onBlur instead. So if there's an error, the user will know right away and that should update the form isValid to false. But again, if that's for the whole form regardless of mounted withForm component, I'll need to find an alternative.
Was this page helpful?