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
.
- [Vuejs]-Vuejs Global User Object from Laravel API
- [Vuejs]-VueJS 2 – Update modal component when passing in data
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)
},
Source:stackexchange.com