Created
September 20, 2022 08:06
-
-
Save bicky-tmg/b0f40a227c36a42f354215b8cb45e372 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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