Is it possible to use Vuelidate outside of Vue.js component?


#1

I use Vuelidate in my project, which is great for validations inside components. However since I’ll be working with the same data in multiple places, even outside of Vue.js components, I need a way to reuse the validation mechanism.

Basically, I am looking for a method like validate() from Vuelidate library to which I’d pass my validations object and some sort-of value object, where I’d put all the values (instead taking them from data or computed properties in components).

Has anyone used Vuelidate like that? Is it possible?

Thanks!


#2

Vuelidate needs vue instance to work, but it doesn’t have to be a component. You can create a vue instance that only handles validation, and then make that validation state available to any component that needs it.


#3

I was afraid that this is the case. Thanks for the answer, @woodberry.


#4

Here is some related discussion on a recent github issue - maybe you can add to it:


This topic comes up quite often in relation to vuelidate.


#5

Because Vuelidate requires Vue.js instance, I decided to try validate.js instead and I wrote a blog post how I used it with Vue.js for others who might face the same problem: Using validate.js instead of Vuelidate in Vue.js applications.