|
2 | 2 |
|
3 | 3 | import * as z from 'zod/mini'; |
4 | 4 |
|
5 | | -export const zBaz = z._default(z.readonly(z.string().check(z.regex(/foo\nbar/)).register(z.globalRegistry, { |
6 | | - custom: 'value', |
7 | | - title: 'string' |
8 | | -})), 'baz'); |
| 5 | +export const zBaz = z._default(z.readonly(z.string().check(z.regex(/foo\nbar/)).register(z.globalRegistry, { custom: 'value', title: 'string' })), 'baz'); |
9 | 6 |
|
10 | 7 | export const zQux = z.record(z.string(), z.object({ |
11 | | - qux: z.optional(z.string().register(z.globalRegistry, { |
12 | | - custom: 'value', |
13 | | - title: 'string' |
14 | | - })) |
15 | | -}).register(z.globalRegistry, { |
16 | | - custom: 'value', |
17 | | - title: 'object' |
18 | | -})).register(z.globalRegistry, { |
19 | | - custom: 'value', |
20 | | - title: 'object' |
21 | | -}); |
| 8 | + qux: z.optional(z.string().register(z.globalRegistry, { custom: 'value', title: 'string' })) |
| 9 | +}).register(z.globalRegistry, { custom: 'value', title: 'object' })).register(z.globalRegistry, { custom: 'value', title: 'object' }); |
22 | 10 |
|
23 | 11 | /** |
24 | 12 | * This is Foo schema. |
25 | 13 | */ |
26 | 14 | export const zFoo = z._default(z.nullable(z.object({ |
27 | | - foo: z.optional(z.string().check(z.regex(/^\d{3}-\d{2}-\d{4}$/)).register(z.globalRegistry, { |
28 | | - custom: 'value', |
29 | | - title: 'This is foo property.' |
30 | | - })), |
| 15 | + foo: z.optional(z.string().check(z.regex(/^\d{3}-\d{2}-\d{4}$/)).register(z.globalRegistry, { custom: 'value', title: 'This is foo property.' })), |
31 | 16 | bar: z.optional(z.lazy((): any => zBar)), |
32 | | - baz: z.optional(z.array(z.lazy((): any => zFoo)).register(z.globalRegistry, { |
33 | | - custom: 'value', |
34 | | - title: 'This is baz property.' |
35 | | - })), |
36 | | - qux: z._default(z.optional(z.int().check(z.gt(0)).register(z.globalRegistry, { |
37 | | - custom: 'value', |
38 | | - title: 'This is qux property.' |
39 | | - })), 0) |
40 | | -}).register(z.globalRegistry, { |
41 | | - custom: 'value', |
42 | | - title: 'object' |
43 | | -})), null); |
| 17 | + baz: z.optional(z.array(z.lazy((): any => zFoo)).register(z.globalRegistry, { custom: 'value', title: 'This is baz property.' })), |
| 18 | + qux: z._default(z.optional(z.int().check(z.gt(0)).register(z.globalRegistry, { custom: 'value', title: 'This is qux property.' })), 0) |
| 19 | +}).register(z.globalRegistry, { custom: 'value', title: 'object' })), null); |
44 | 20 |
|
45 | 21 | /** |
46 | 22 | * This is Bar schema. |
47 | 23 | */ |
48 | 24 | export const zBar = z.object({ |
49 | 25 | foo: z.optional(zFoo) |
50 | | -}).register(z.globalRegistry, { |
51 | | - custom: 'value', |
52 | | - title: 'This is Bar schema.' |
53 | | -}); |
| 26 | +}).register(z.globalRegistry, { custom: 'value', title: 'This is Bar schema.' }); |
54 | 27 |
|
55 | 28 | /** |
56 | 29 | * This is Foo parameter. |
57 | 30 | */ |
58 | | -export const zFoo2 = z.string().register(z.globalRegistry, { |
59 | | - custom: 'value', |
60 | | - title: 'This is Foo parameter.' |
61 | | -}); |
| 31 | +export const zFoo2 = z.string().register(z.globalRegistry, { custom: 'value', title: 'This is Foo parameter.' }); |
62 | 32 |
|
63 | 33 | export const zFoo3 = z.object({ |
64 | 34 | foo: z.optional(zBar) |
65 | | -}).register(z.globalRegistry, { |
66 | | - custom: 'value', |
67 | | - title: 'object' |
68 | | -}); |
| 35 | +}).register(z.globalRegistry, { custom: 'value', title: 'object' }); |
69 | 36 |
|
70 | 37 | export const zPatchFooData = z.object({ |
71 | 38 | body: z.object({ |
72 | | - foo: z.optional(z.string().register(z.globalRegistry, { |
73 | | - custom: 'value', |
74 | | - title: 'string' |
75 | | - })) |
76 | | - }).register(z.globalRegistry, { |
77 | | - custom: 'value', |
78 | | - title: 'object' |
79 | | - }), |
80 | | - path: z.optional(z.never().register(z.globalRegistry, { |
81 | | - custom: 'value', |
82 | | - title: 'never' |
83 | | - })), |
| 39 | + foo: z.optional(z.string().register(z.globalRegistry, { custom: 'value', title: 'string' })) |
| 40 | + }).register(z.globalRegistry, { custom: 'value', title: 'object' }), |
| 41 | + path: z.optional(z.never().register(z.globalRegistry, { custom: 'value', title: 'never' })), |
84 | 42 | query: z.optional(z.object({ |
85 | | - foo: z.optional(z.string().register(z.globalRegistry, { |
86 | | - custom: 'value', |
87 | | - title: 'This is Foo parameter.' |
88 | | - })), |
| 43 | + foo: z.optional(z.string().register(z.globalRegistry, { custom: 'value', title: 'This is Foo parameter.' })), |
89 | 44 | bar: z.optional(zBar), |
90 | 45 | baz: z.optional(z.object({ |
91 | | - baz: z.optional(z.string().register(z.globalRegistry, { |
92 | | - custom: 'value', |
93 | | - title: 'string' |
94 | | - })) |
95 | | - }).register(z.globalRegistry, { |
96 | | - custom: 'value', |
97 | | - title: 'object' |
98 | | - })), |
99 | | - qux: z.optional(z.iso.date().register(z.globalRegistry, { |
100 | | - custom: 'value', |
101 | | - title: 'string' |
102 | | - })), |
103 | | - quux: z.optional(z.iso.datetime().register(z.globalRegistry, { |
104 | | - custom: 'value', |
105 | | - title: 'string' |
106 | | - })) |
107 | | - }).register(z.globalRegistry, { |
108 | | - custom: 'value', |
109 | | - title: 'object' |
110 | | - })) |
111 | | -}).register(z.globalRegistry, { |
112 | | - custom: 'value', |
113 | | - title: 'object' |
114 | | -}); |
| 46 | + baz: z.optional(z.string().register(z.globalRegistry, { custom: 'value', title: 'string' })) |
| 47 | + }).register(z.globalRegistry, { custom: 'value', title: 'object' })), |
| 48 | + qux: z.optional(z.iso.date().register(z.globalRegistry, { custom: 'value', title: 'string' })), |
| 49 | + quux: z.optional(z.iso.datetime().register(z.globalRegistry, { custom: 'value', title: 'string' })) |
| 50 | + }).register(z.globalRegistry, { custom: 'value', title: 'object' })) |
| 51 | +}).register(z.globalRegistry, { custom: 'value', title: 'object' }); |
115 | 52 |
|
116 | 53 | export const zPostFooData = z.object({ |
117 | 54 | body: zFoo3, |
118 | | - path: z.optional(z.never().register(z.globalRegistry, { |
119 | | - custom: 'value', |
120 | | - title: 'never' |
121 | | - })), |
122 | | - query: z.optional(z.never().register(z.globalRegistry, { |
123 | | - custom: 'value', |
124 | | - title: 'never' |
125 | | - })) |
126 | | -}).register(z.globalRegistry, { |
127 | | - custom: 'value', |
128 | | - title: 'object' |
129 | | -}); |
| 55 | + path: z.optional(z.never().register(z.globalRegistry, { custom: 'value', title: 'never' })), |
| 56 | + query: z.optional(z.never().register(z.globalRegistry, { custom: 'value', title: 'never' })) |
| 57 | +}).register(z.globalRegistry, { custom: 'value', title: 'object' }); |
0 commit comments