[Vuejs]-Vuelidate using Vue 2.6 and Composition API

5👍

Built-in validators such as sameAs don’t have access to the state, so they aren’t supposed to be workable when used like sameAs('email').

This way validators are supposed to be defined in setup function in order to access the state:

 const emailRef = computed(() => state.email);
 const validations = {
   ...
   repeatEmail: {
     ...
     sameAsEmail: sameAs(emailRef)
   },

Otherwise this needs to be done with custom validators instead of built-ins that will access the state on component instance with getCurrentInstance.

0👍

if you can use the same validation in vuejs 3 with composition syntax because using compute function get update state

 code  password = computed(() => state.password);
 const validations = {
   ...
   confirm-password: {
     ...
     sameAs: sameAs(emailRef)
   }, 

Leave a comment