Skip to content

Commit

Permalink
fix(authentication): fix form validation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
gravitano committed Sep 14, 2021
1 parent d588f5c commit 05a7cc4
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/pages/auth/Activation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import VBtn from '../../components/VBtn/VBtn.vue';
import VInputGroup from '../../components/VInputGroup/VInputGroup.vue';
import {useForm, useField} from 'vee-validate';
import * as zod from 'zod';
import {toFormValidator} from '@vee-validate/zod';
const props = defineProps({
title: {
Expand Down Expand Up @@ -40,14 +41,17 @@ watch(
{immediate: true},
);
const schema = zod.object({
password: zod.string().required().min(8).label('Password'),
passwordConfirmation: zod
.string()
.required()
.oneOf([YupRef('password'), null], 'Passwords must match')
.label('Password Confirmation'),
});
const schema = toFormValidator(
zod
.object({
password: zod.string(),
passwordConfirmation: zod.string(),
})
.refine((data) => data.password === data.passwordConfirmation, {
message: "Passwords don't match",
path: ['passwordConfirmation'], // path of error
}),
);
const {errors, handleSubmit} = useForm({
validationSchema: schema,
Expand Down

0 comments on commit 05a7cc4

Please sign in to comment.