vee-validate icon indicating copy to clipboard operation
vee-validate copied to clipboard

Be able to use validators from `useForms`'s `validationSchema` as well as validator from `useField`

Open joezimjs opened this issue 2 years ago • 2 comments

Is your feature request related to a problem? Please describe.

I have some custom component inputs that have validation that is specific to that component (e.g. SocialSecurityInput that always needs to validate that it's a valid social security number), but I also want to specify additional validation from "higher up" (e.g. to mark that field as required).

Describe the solution you'd like

I've developed a simple demo: https://stackblitz.com/edit/nuxt-starter-19vgxm?file=app.vue

I want to specify a validation schema - as in app.vue in the demo - but I want the custom input component to also be able to specify additional validators via useField - as in TextField.vue in the demo.

Describe alternatives you've considered

I've thought about exposing the validator as a property on the component so it can get mixed in to the validationSchema, but that requires the developer to remember to grab the validator and add it for every single field.

joezimjs avatar Aug 09 '23 17:08 joezimjs

Similar to https://github.com/logaretm/vee-validate/issues/4142

Still need to find a way to do this seamlessly otherwise it will be confusing.

logaretm avatar Aug 13 '23 23:08 logaretm

I would like to have this feature too. In my case, I have the expensive validation in useForm, but only for a specific field. Currently, it is runs every time the value of the any form field is changed, and this is not very efficient. It would be really nice to specify this check only for changing this specific field, but now, as I understand, I can't do that.

If there is any other way to achieve this effect, I would appreciate any help.

MellKam avatar Sep 16 '23 14:09 MellKam