-
Notifications
You must be signed in to change notification settings - Fork 1
/
model.ts
45 lines (40 loc) · 909 Bytes
/
model.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
import { z } from 'zod';
export const numberSchema = z.union([
z
.string()
.refine((number) => !Number.isNaN(parseInt(number, 10)))
.transform((number) => parseInt(number, 10)),
z.number(),
]);
export const linkSchema = z
.object({
href: z.string(),
attributes: z
.object({
method: z.string(),
})
.optional(),
})
.strict();
export const modelSchema = z
.object({
id: z.string(),
createdAt: z.date(),
updatedAt: z.date().optional(),
})
.strict();
export const modelResponseSchema = z
.object({
id: z.string(),
createdAt: z.string(),
updatedAt: z.string().optional(),
})
.strict();
export const listRequestSchema = z
.object({
offset: numberSchema.default(0),
limit: numberSchema.default(20),
filters: z.object({}).strict().default({}),
sort: z.object({}).strict().default({}),
})
.strict();