🧑‍💻 create zod error instance in helper

This commit is contained in:
Rafi Arrafif
2025-07-17 00:05:35 +07:00
parent 29b76fb91a
commit 8bcde5518a
4 changed files with 30 additions and 19 deletions

View File

@ -1,17 +0,0 @@
import z from "zod";
export const createUserSchema = z.object({
name: z.string(),
username: z
.string()
.min(4) //Total all username character must over 4 character
.regex(/^[a-zA-Z0-9_-]+$/), //Prohibiting the use of spaces and symbols other than - and _
email: z.email(),
password: z
.string()
.min(8) //Total all password chaacter must over 8 character
.regex(/[A-Z]/) //Min has 1 uppercase letter
.regex(/[a-z]/) //Min has 1 lowercase letter
.regex(/[0-9]/) //Min has 1 number
.regex(/[^A-Za-z0-9"]/), //Min has 1 symbol character
});

View File

@ -0,0 +1,23 @@
import z from "zod";
export const createUserViaRegisterSchema = z.object({
name: z.string(),
username: z
.string()
.min(4, "username: must be 4 characters or longer.") //Total all username character must over 4 character
.regex(
/^[a-zA-Z0-9_-]+$/,
"username: symbols other than - and _ are not allowed"
), //Prohibiting the use of spaces and symbols other than - and _
email: z.email(),
password: z
.string()
.min(8, "password: must be 8 characters or longer.") //Total all password chaacter must over 8 character
.regex(/[A-Z]/, "password: have at least 1 uppercase letter") //Have at least 1 uppercase letter
.regex(/[a-z]/, "password: have at least 1 lowercase letter") //Have at least 1 lowercase letter
.regex(/[0-9]/, "password: have at least 1 number") //Have at least 1 number
.regex(
/[^A-Za-z0-9"]/,
"password: has at least 1 symbol except quotation marks"
), //Have at least 1 symbol character
});