Skip to content

Instantly share code, notes, and snippets.

@bicky-tmg
Created September 20, 2022 08:06
Show Gist options
  • Save bicky-tmg/b0f40a227c36a42f354215b8cb45e372 to your computer and use it in GitHub Desktop.
Save bicky-tmg/b0f40a227c36a42f354215b8cb45e372 to your computer and use it in GitHub Desktop.
const validationSchema = z
.object({
firstName: z.string().min(1, { message: "Firstname is required" }),
lastName: z.string().min(1, { message: "Lastname is required" }),
email: z.string().min(1, { message: "Email is required" }).email({
message: "Must be a valid email",
}),
password: z
.string()
.min(6, { message: "Password must be atleast 6 characters" }),
confirmPassword: z
.string()
.min(1, { message: "Confirm Password is required" }),
terms: z.literal(true, {
errorMap: () => ({ message: "You must accept Terms and Conditions" }),
}),
})
.refine((data) => data.password === data.confirmPassword, {
path: ["confirmPassword"],
message: "Password don't match",
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment