I am working on Vue.js template and on the sign up page, I need to compare password while user signup so, I added custom validation rule like the following code:
<v-text-field
label="Password"
v-model="password"
:rules="passwordRules"
type="password"
required
></v-text-field>
<v-text-field
label="Confirm Password"
v-model="confirmPassword"
:rules="[confirmPasswordRules,passwordConfirmationRule]"
type="password"
required
></v-text-field>
script:
data() {
return {
password: "",
confirmPassword: "",
passwordRules: [v => !!v || "Password is required"],
confirmPasswordRules: [v => !!v || "Password is required"],
};
},
Compare password method in computed:
computed: {
passwordConfirmationRule() {
return () => (this.password === this.confirmPassword) || 'Password must match'
},
}
I use the computed method for confirm password its working fine and compare the password perfectly but it shows error in console [Vuetify] Rules should return a string or boolean, received 'object' instead so how can I solve this ??