-
Notifications
You must be signed in to change notification settings - Fork 18
/
userSchemas.ts
46 lines (36 loc) · 1.44 KB
/
userSchemas.ts
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { toNumberPreprocessor } from '@lokalise/zod-extras'
import z from 'zod'
export const CREATE_USER_BODY_SCHEMA = z.object({
name: z.string(),
age: z.optional(z.nullable(z.preprocess(toNumberPreprocessor, z.number()))),
email: z.string().email(),
})
export const UPDATE_USER_BODY_SCHEMA = z.object({
name: z.optional(z.string()),
email: z.optional(z.string().email()),
})
export const GET_USER_PARAMS_SCHEMA = z.object({
userId: z.string(),
})
export const UPDATE_USER_PARAMS_SCHEMA = z.object({
userId: z.string(),
})
export const DELETE_USER_PARAMS_SCHEMA = z.object({
userId: z.string(),
})
export const USER_SCHEMA = z.object({
id: z.string(),
name: z.string(),
age: z.optional(z.nullable(z.preprocess(toNumberPreprocessor, z.number()))),
email: z.string().email(),
})
export const GET_USER_SCHEMA_RESPONSE_SCHEMA = z.object({
data: USER_SCHEMA,
})
export type USER_SCHEMA_TYPE = z.infer<typeof USER_SCHEMA>
export type CREATE_USER_BODY_SCHEMA_TYPE = z.infer<typeof CREATE_USER_BODY_SCHEMA>
export type UPDATE_USER_BODY_SCHEMA_TYPE = z.infer<typeof UPDATE_USER_BODY_SCHEMA>
export type GET_USER_PARAMS_SCHEMA_TYPE = z.infer<typeof GET_USER_PARAMS_SCHEMA>
export type UPDATE_USER_PARAMS_SCHEMA_TYPE = z.infer<typeof UPDATE_USER_PARAMS_SCHEMA>
export type DELETE_USER_PARAMS_SCHEMA_TYPE = z.infer<typeof DELETE_USER_PARAMS_SCHEMA>
export type GET_USER_SCHEMA_RESPONSE_SCHEMA_TYPE = z.infer<typeof GET_USER_SCHEMA_RESPONSE_SCHEMA>