forked from TomDoesTech/Testing-Express-REST-API
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser.schema.ts
More file actions
26 lines (24 loc) · 762 Bytes
/
Copy pathuser.schema.ts
File metadata and controls
26 lines (24 loc) · 762 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { object, string, TypeOf } from "zod";
export const createUserSchema = object({
body: object({
name: string({
required_error: "Name is required",
}),
password: string({
required_error: "Name is required",
}).min(6, "Password too short - should be 6 chars minimum"),
passwordConfirmation: string({
required_error: "passwordConfirmation is required",
}),
email: string({
required_error: "Email is required",
}).email("Not a valid email"),
}).refine((data) => data.password === data.passwordConfirmation, {
message: "Passwords do not match",
path: ["passwordConfirmation"],
}),
});
export type CreateUserInput = Omit<
TypeOf<typeof createUserSchema>,
"body.passwordConfirmation"
>;