Replies: 2 comments 2 replies
-
If we're talking about UX in the terms of "I want to show the error only for the fields where it makes sense" the advice is to play with the Validation is still fired for all fields as we're just passing the form state to the zod schema, but the user doesn't know what zod is (and probably doesn't care) |
Beta Was this translation helpful? Give feedback.
0 replies
-
example of reusable component displaying error only for related field:
|
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm using the cool useAppForm() returned from createFormHook() to start assembling a reusable set of components.
In an actual form component, I'll do something like this:
SignUpSchema is a Zod schema I have defined elsewhere, and SignUpSchemaType is its inferred type. Doing things this way means that TSF's inference magic works quite nicely.
However, when I enter a value into the very first field, it fires all of the field validations, even though I have not gotten to the rest of them yet. That isn't a very pleasant user experience.
Is there a way to declare my schema at the form level, as it is here, but at the field level have only the validation(s) for that particular field executed?
Beta Was this translation helpful? Give feedback.
All reactions