Replies: 3 comments 2 replies
-
Check this entry: https://vee-validate.logaretm.com/v4/guide/composition-api/getting-started/#dynamic-form-schemas You can also use |
Beta Was this translation helpful? Give feedback.
-
@logaretm How would we do this using Valibot? I'm noticing this might be more complicated than it looks. If you infer type using What I'd like to do is put the Vaibot schema and inferred type in a separate file for reusability, but this makes it so I wouldn't be able to dynamically make modifications to some properties. |
Beta Was this translation helpful? Give feedback.
-
I'v found en easy way, in fact it's possible to create different validation schema and change the content of the validation schema with the one you want. By ex you have 2 fields. Radio is required but textarea is required only if radio is set to Yes. So first schema { Second { So you set to variable attach to form "validation-schema" attribute one value or the other depending of the value of "radio". Simple ;) |
Beta Was this translation helpful? Give feedback.
-
Hello all,
I explain my case.
In my form i'v got some fields like the email that is not mandatory till it's not fill. So when it's empty it's ok.
And when you start to enter something into the email input it should check if the value is a correct email or not.
"schema" :
{
email : "notMandatoryIfEmpty|email"
}
When you define a custom rule the functions return "true" or a dedicated label for the error.
Is it possible to return a third case like "null" that stop the check of the next rules attach to the input ?
So in my case my custom rule "notMandatoryIfEmpty" could return "null" and the validation rule "email" should never be executed.
Best regards
Beta Was this translation helpful? Give feedback.
All reactions