Compare two fields like password and passwordConfirmation #361
Unanswered
xavierBizoux
asked this question in
Q&A
Replies: 1 comment
-
You can use a const passwordForm = z
.object({
password: z.string(),
confirmPassword: z.string(),
})
.refine((data) => data.password === data.confirmPassword, {
message: "Passwords don't match",
path: ["confirmPassword"], // path of error
}); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm new to this library and I'm trying to figure out how to compare two fields for validation.
I have a registration form on my site and I want the new users to specify the password and a confirmation password. Of course the two should match in order to create a new user. If I'm correct, it can be done using refine in zod, but I can't find a way to it using this package.
Any help/example will be appreciated.
Beta Was this translation helpful? Give feedback.
All reactions