@temporary-name/zod 1.9.3-alpha.e09726e1bf5340c7b7052eeabcb4935b3c85ce93 → 1.9.3-alpha.e2d8d164da72fb570c2b14a4fa956c80f9e33cdc
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +739 -78
- package/dist/index.d.ts +739 -78
- package/dist/index.mjs +1479 -860
- package/package.json +6 -14
- package/dist/zod4/index.d.mts +0 -314
- package/dist/zod4/index.d.ts +0 -314
- package/dist/zod4/index.mjs +0 -743
package/dist/index.mjs
CHANGED
|
@@ -1,42 +1,320 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
1
|
+
import * as core from 'zod/v4/core';
|
|
2
|
+
import { $ZodError, util, _overwrite, _regex, _includes, _startsWith, _endsWith, _minLength, _maxLength, _length, _lowercase, _uppercase, _trim, _normalize, _toLowerCase, _toUpperCase, _gt, _gte, _lt, _lte, _multipleOf } from 'zod/v4/core';
|
|
3
|
+
export { core };
|
|
4
|
+
export { _endsWith as endsWith, _gt as gt, _gte as gte, _includes as includes, _length as length, _lowercase as lowercase, _lt as lt, _lte as lte, _maxLength as maxLength, _maxSize as maxSize, _mime as mime, _minLength as minLength, _minSize as minSize, _multipleOf as multipleOf, _negative as negative, _nonnegative as nonnegative, _nonpositive as nonpositive, _normalize as normalize, _overwrite as overwrite, _positive as positive, _property as property, _regex as regex, _size as size, _startsWith as startsWith, _toLowerCase as toLowerCase, _toUpperCase as toUpperCase, _trim as trim, _uppercase as uppercase } from 'zod/v4/core';
|
|
5
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
6
|
+
import { custom as custom$1 } from 'zod/v3';
|
|
7
7
|
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
const initializer = (inst, issues) => {
|
|
9
|
+
$ZodError.init(inst, issues);
|
|
10
|
+
inst.name = "ZodError";
|
|
11
|
+
Object.defineProperties(inst, {
|
|
12
|
+
format: {
|
|
13
|
+
value: (mapper) => core.formatError(inst, mapper)
|
|
14
|
+
// enumerable: false,
|
|
15
|
+
},
|
|
16
|
+
flatten: {
|
|
17
|
+
value: (mapper) => core.flattenError(inst, mapper)
|
|
18
|
+
// enumerable: false,
|
|
19
|
+
},
|
|
20
|
+
addIssue: {
|
|
21
|
+
value: (issue) => {
|
|
22
|
+
inst.issues.push(issue);
|
|
23
|
+
inst.message = JSON.stringify(inst.issues, core.util.jsonStringifyReplacer, 2);
|
|
24
|
+
}
|
|
25
|
+
// enumerable: false,
|
|
26
|
+
},
|
|
27
|
+
addIssues: {
|
|
28
|
+
value: (issues2) => {
|
|
29
|
+
inst.issues.push(...issues2);
|
|
30
|
+
inst.message = JSON.stringify(inst.issues, core.util.jsonStringifyReplacer, 2);
|
|
31
|
+
}
|
|
32
|
+
// enumerable: false,
|
|
33
|
+
},
|
|
34
|
+
isEmpty: {
|
|
35
|
+
get() {
|
|
36
|
+
return inst.issues.length === 0;
|
|
37
|
+
}
|
|
38
|
+
// enumerable: false,
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
const ZodError = core.$constructor("ZodError", initializer);
|
|
43
|
+
const ZodRealError = core.$constructor("ZodError", initializer, {
|
|
44
|
+
Parent: Error
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const parse = /* @__PURE__ */ core._parse(ZodRealError);
|
|
48
|
+
const parseAsync = /* @__PURE__ */ core._parseAsync(ZodRealError);
|
|
49
|
+
const safeParse = /* @__PURE__ */ core._safeParse(ZodRealError);
|
|
50
|
+
const safeParseAsync = /* @__PURE__ */ core._safeParseAsync(ZodRealError);
|
|
51
|
+
const encode = /* @__PURE__ */ core._encode(ZodRealError);
|
|
52
|
+
const decode = /* @__PURE__ */ core._decode(ZodRealError);
|
|
53
|
+
const encodeAsync = /* @__PURE__ */ core._encodeAsync(ZodRealError);
|
|
54
|
+
const decodeAsync = /* @__PURE__ */ core._decodeAsync(ZodRealError);
|
|
55
|
+
const safeEncode = /* @__PURE__ */ core._safeEncode(ZodRealError);
|
|
56
|
+
const safeDecode = /* @__PURE__ */ core._safeDecode(ZodRealError);
|
|
57
|
+
const safeEncodeAsync = /* @__PURE__ */ core._safeEncodeAsync(ZodRealError);
|
|
58
|
+
const safeDecodeAsync = /* @__PURE__ */ core._safeDecodeAsync(ZodRealError);
|
|
59
|
+
|
|
60
|
+
const ZodISODateTime = /* @__PURE__ */ core.$constructor(
|
|
61
|
+
"ZodISODateTime",
|
|
62
|
+
(inst, def) => {
|
|
63
|
+
const coreInit = core.$ZodISODateTime.init;
|
|
64
|
+
coreInit(inst, def);
|
|
65
|
+
ZodStringFormat.init(inst, def);
|
|
66
|
+
}
|
|
67
|
+
);
|
|
68
|
+
function datetime(params) {
|
|
69
|
+
return core._isoDateTime(ZodISODateTime, params);
|
|
70
|
+
}
|
|
71
|
+
const ZodISODate = /* @__PURE__ */ core.$constructor(
|
|
72
|
+
"ZodISODate",
|
|
73
|
+
(inst, def) => {
|
|
74
|
+
const coreInit = core.$ZodISODate.init;
|
|
75
|
+
coreInit(inst, def);
|
|
76
|
+
ZodStringFormat.init(inst, def);
|
|
77
|
+
}
|
|
78
|
+
);
|
|
79
|
+
function date$1(params) {
|
|
80
|
+
return core._isoDate(ZodISODate, params);
|
|
81
|
+
}
|
|
82
|
+
const ZodISOTime = /* @__PURE__ */ core.$constructor(
|
|
83
|
+
"ZodISOTime",
|
|
84
|
+
(inst, def) => {
|
|
85
|
+
const coreInit = core.$ZodISOTime.init;
|
|
86
|
+
coreInit(inst, def);
|
|
87
|
+
ZodStringFormat.init(inst, def);
|
|
88
|
+
}
|
|
89
|
+
);
|
|
90
|
+
function time(params) {
|
|
91
|
+
return core._isoTime(ZodISOTime, params);
|
|
92
|
+
}
|
|
93
|
+
const ZodISODuration = /* @__PURE__ */ core.$constructor(
|
|
94
|
+
"ZodISODuration",
|
|
95
|
+
(inst, def) => {
|
|
96
|
+
const coreInit = core.$ZodISODuration.init;
|
|
97
|
+
coreInit(inst, def);
|
|
98
|
+
ZodStringFormat.init(inst, def);
|
|
99
|
+
}
|
|
100
|
+
);
|
|
101
|
+
function duration(params) {
|
|
102
|
+
return core._isoDuration(ZodISODuration, params);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const gatingContext = new AsyncLocalStorage();
|
|
106
|
+
function isGateIssueRaw(issue) {
|
|
107
|
+
return issue.code === "invalid_type" && issue.expected === "never" && issue.inst instanceof ZodGate;
|
|
108
|
+
}
|
|
109
|
+
function isGateIssue(issue) {
|
|
110
|
+
return issue.code === "invalid_type" && issue.expected === "never" && issue.path?.length === 0;
|
|
111
|
+
}
|
|
112
|
+
const ZodGate = /* @__PURE__ */ core.$constructor("ZodGate", (inst, def) => {
|
|
113
|
+
const coreInit = core.$ZodOptional.init;
|
|
114
|
+
coreInit(inst, def);
|
|
115
|
+
KrustyType.init(inst, def);
|
|
116
|
+
inst._zod.parse = (payload, ctx) => {
|
|
117
|
+
const gateEnabled = gatingContext.getStore()?.(def.gateName);
|
|
118
|
+
if (gateEnabled) {
|
|
119
|
+
return def.innerType._zod.run(payload, ctx);
|
|
120
|
+
} else if (payload.value !== void 0) {
|
|
121
|
+
payload.issues.push({
|
|
122
|
+
expected: "never",
|
|
123
|
+
code: "invalid_type",
|
|
124
|
+
input: payload.value,
|
|
125
|
+
inst
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
return payload;
|
|
129
|
+
};
|
|
130
|
+
});
|
|
131
|
+
function gate(innerType, gateName) {
|
|
132
|
+
return new ZodGate({
|
|
133
|
+
type: "optional",
|
|
134
|
+
innerType,
|
|
135
|
+
gateName
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function handleGating(payload) {
|
|
140
|
+
for (let i = 0; i < payload.issues.length; i++) {
|
|
141
|
+
const issue = payload.issues[i];
|
|
142
|
+
if (issue?.code === "invalid_union") {
|
|
143
|
+
const newErrors = issue.errors.filter((innerIssues) => !innerIssues.some(isGateIssue));
|
|
144
|
+
issue.errors.splice(0, Infinity, ...newErrors);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return payload;
|
|
148
|
+
}
|
|
149
|
+
const ZodUnion = /* @__PURE__ */ core.$constructor(
|
|
150
|
+
"ZodUnion",
|
|
151
|
+
(inst, def) => {
|
|
152
|
+
const coreInit = core.$ZodUnion.init;
|
|
153
|
+
coreInit(inst, def);
|
|
154
|
+
KrustyType.init(inst, def);
|
|
155
|
+
inst.options = def.options;
|
|
156
|
+
const origParse = inst._zod.parse;
|
|
157
|
+
inst._zod.parse = (payload, ctx) => {
|
|
158
|
+
const res = origParse(payload, ctx);
|
|
159
|
+
if (res instanceof Promise) {
|
|
160
|
+
return res.then((r) => handleGating(r));
|
|
161
|
+
} else {
|
|
162
|
+
return handleGating(res);
|
|
163
|
+
}
|
|
164
|
+
};
|
|
14
165
|
}
|
|
15
|
-
|
|
16
|
-
|
|
166
|
+
);
|
|
167
|
+
function union(options, params) {
|
|
168
|
+
return new ZodUnion({
|
|
169
|
+
type: "union",
|
|
170
|
+
options,
|
|
171
|
+
...util.normalizeParams(params)
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
const ZodDiscriminatedUnion = /* @__PURE__ */ core.$constructor("ZodDiscriminatedUnion", (inst, def) => {
|
|
175
|
+
ZodUnion.init(inst, def);
|
|
176
|
+
const coreInit = core.$ZodDiscriminatedUnion.init;
|
|
177
|
+
coreInit(inst, def);
|
|
178
|
+
});
|
|
179
|
+
function discriminatedUnion(discriminator, options, params) {
|
|
180
|
+
return new ZodDiscriminatedUnion({
|
|
181
|
+
type: "union",
|
|
182
|
+
options,
|
|
183
|
+
discriminator,
|
|
184
|
+
...util.normalizeParams(params)
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function handlePropertyResult(result, final, key, input) {
|
|
189
|
+
if (result.issues.length) {
|
|
190
|
+
final.issues.push(...util.prefixIssues(key, result.issues));
|
|
17
191
|
}
|
|
18
|
-
if (
|
|
19
|
-
|
|
192
|
+
if (result.value === void 0) {
|
|
193
|
+
if (key in input) {
|
|
194
|
+
final.value[key] = void 0;
|
|
195
|
+
}
|
|
196
|
+
} else {
|
|
197
|
+
final.value[key] = result.value;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
const ZodObject = /* @__PURE__ */ core.$constructor(
|
|
201
|
+
"ZodObject",
|
|
202
|
+
(inst, def) => {
|
|
203
|
+
const coreInit = core.$ZodObjectJIT.init;
|
|
204
|
+
coreInit(inst, def);
|
|
205
|
+
KrustyType.init(inst, def);
|
|
206
|
+
util.defineLazy(inst, "shape", () => {
|
|
207
|
+
return def.shape;
|
|
208
|
+
});
|
|
209
|
+
inst.keyof = () => _enum(Object.keys(inst._zod.def.shape));
|
|
210
|
+
inst.catchall = (catchall) => inst.clone({ ...inst._zod.def, catchall });
|
|
211
|
+
inst.passthrough = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
|
|
212
|
+
inst.loose = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
|
|
213
|
+
inst.strict = () => inst.clone({ ...inst._zod.def, catchall: never() });
|
|
214
|
+
inst.strip = () => inst.clone({ ...inst._zod.def, catchall: void 0 });
|
|
215
|
+
inst.extend = (incoming) => {
|
|
216
|
+
return util.extend(inst, incoming);
|
|
217
|
+
};
|
|
218
|
+
inst.safeExtend = (incoming) => {
|
|
219
|
+
return util.safeExtend(inst, incoming);
|
|
220
|
+
};
|
|
221
|
+
inst.merge = (other) => util.merge(inst, other);
|
|
222
|
+
inst.pick = (mask) => util.pick(inst, mask);
|
|
223
|
+
inst.omit = (mask) => util.omit(inst, mask);
|
|
224
|
+
inst.partial = (...args) => util.partial(ZodOptional, inst, args[0]);
|
|
225
|
+
inst.required = (...args) => util.required(ZodNonOptional, inst, args[0]);
|
|
226
|
+
function handleGating(input, payload, ctx) {
|
|
227
|
+
const _catchall = def.catchall?._zod;
|
|
228
|
+
const t = _catchall?.def.type;
|
|
229
|
+
let newIssues = null;
|
|
230
|
+
const proms = [];
|
|
231
|
+
const newUnrecognizedKeys = [];
|
|
232
|
+
for (let i = 0; i < payload.issues.length; i++) {
|
|
233
|
+
const issue = payload.issues[i];
|
|
234
|
+
if (!isGateIssueRaw(issue)) {
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
237
|
+
newIssues ??= [...payload.issues];
|
|
238
|
+
newIssues[i] = null;
|
|
239
|
+
const key = issue.path[0];
|
|
240
|
+
if (!_catchall) {
|
|
241
|
+
delete payload.value[key];
|
|
242
|
+
} else if (t === "never") {
|
|
243
|
+
newUnrecognizedKeys.push(key);
|
|
244
|
+
} else {
|
|
245
|
+
const r = _catchall.run({ value: input[key], issues: [] }, ctx);
|
|
246
|
+
if (r instanceof Promise) {
|
|
247
|
+
proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input)));
|
|
248
|
+
} else {
|
|
249
|
+
handlePropertyResult(r, payload, key, input);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
if (newIssues) {
|
|
254
|
+
payload.issues = newIssues.filter(Boolean);
|
|
255
|
+
}
|
|
256
|
+
if (newUnrecognizedKeys.length > 0) {
|
|
257
|
+
const missingKeyIssue = payload.issues.find(
|
|
258
|
+
(issue) => issue.code === "unrecognized_keys" && !issue.path
|
|
259
|
+
);
|
|
260
|
+
if (missingKeyIssue) {
|
|
261
|
+
missingKeyIssue.keys.push(...newUnrecognizedKeys);
|
|
262
|
+
} else {
|
|
263
|
+
payload.issues.push({
|
|
264
|
+
code: "unrecognized_keys",
|
|
265
|
+
keys: newUnrecognizedKeys,
|
|
266
|
+
input,
|
|
267
|
+
inst
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
if (proms.length > 0) {
|
|
272
|
+
return Promise.all(proms).then(() => payload);
|
|
273
|
+
} else {
|
|
274
|
+
return payload;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
const origParse = inst._zod.parse;
|
|
278
|
+
inst._zod.parse = (payload, ctx) => {
|
|
279
|
+
const input = payload.value;
|
|
280
|
+
const res = origParse(payload, ctx);
|
|
281
|
+
if (res instanceof Promise) {
|
|
282
|
+
return res.then((r) => handleGating(input, r, ctx));
|
|
283
|
+
} else {
|
|
284
|
+
return handleGating(input, res, ctx);
|
|
285
|
+
}
|
|
286
|
+
};
|
|
20
287
|
}
|
|
21
|
-
|
|
288
|
+
);
|
|
289
|
+
function object(shape, params) {
|
|
290
|
+
const def = {
|
|
291
|
+
type: "object",
|
|
292
|
+
shape: shape ?? {},
|
|
293
|
+
...util.normalizeParams(params)
|
|
294
|
+
};
|
|
295
|
+
return new ZodObject(def);
|
|
296
|
+
}
|
|
297
|
+
function strictObject(shape, params) {
|
|
298
|
+
return new ZodObject({
|
|
299
|
+
type: "object",
|
|
300
|
+
shape,
|
|
301
|
+
catchall: never(),
|
|
302
|
+
...util.normalizeParams(params)
|
|
303
|
+
});
|
|
22
304
|
}
|
|
23
|
-
function
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
305
|
+
function looseObject(shape, params) {
|
|
306
|
+
return new ZodObject({
|
|
307
|
+
type: "object",
|
|
308
|
+
shape,
|
|
309
|
+
catchall: unknown(),
|
|
310
|
+
...util.normalizeParams(params)
|
|
29
311
|
});
|
|
30
|
-
return newSchema;
|
|
31
312
|
}
|
|
32
313
|
|
|
33
314
|
const CUSTOM_ZOD_DEF_SYMBOL = Symbol("ORPC_CUSTOM_ZOD_DEF");
|
|
34
315
|
function setCustomZodDef(def, custom) {
|
|
35
316
|
Object.assign(def, { [CUSTOM_ZOD_DEF_SYMBOL]: custom });
|
|
36
317
|
}
|
|
37
|
-
function getCustomZodDef(def) {
|
|
38
|
-
return def[CUSTOM_ZOD_DEF_SYMBOL];
|
|
39
|
-
}
|
|
40
318
|
function composeParams(defaultMessage, params) {
|
|
41
319
|
return (val) => {
|
|
42
320
|
const message = defaultMessage(val);
|
|
@@ -64,7 +342,7 @@ function composeParams(defaultMessage, params) {
|
|
|
64
342
|
}
|
|
65
343
|
|
|
66
344
|
function blob(params) {
|
|
67
|
-
const schema = custom(
|
|
345
|
+
const schema = custom$1(
|
|
68
346
|
(val) => val instanceof Blob,
|
|
69
347
|
composeParams(
|
|
70
348
|
() => "Input is not a blob",
|
|
@@ -75,33 +353,8 @@ function blob(params) {
|
|
|
75
353
|
return schema;
|
|
76
354
|
}
|
|
77
355
|
|
|
78
|
-
function file(params) {
|
|
79
|
-
const schema = custom(
|
|
80
|
-
(val) => val instanceof File,
|
|
81
|
-
composeParams(
|
|
82
|
-
() => "Input is not a file",
|
|
83
|
-
params
|
|
84
|
-
)
|
|
85
|
-
);
|
|
86
|
-
setCustomZodDef(schema._def, { type: "file" });
|
|
87
|
-
return Object.assign(schema, {
|
|
88
|
-
type: (mimeType, params2) => {
|
|
89
|
-
const isMatch = wcmatch(mimeType);
|
|
90
|
-
const refinedSchema = schema.refine(
|
|
91
|
-
(val) => isMatch(val.type.split(";")[0]),
|
|
92
|
-
composeParams(
|
|
93
|
-
(val) => `Expected a file of type ${mimeType} but got a file of type ${val.type || "unknown"}`,
|
|
94
|
-
params2
|
|
95
|
-
)
|
|
96
|
-
);
|
|
97
|
-
setCustomZodDef(refinedSchema._def, { type: "file", mimeType });
|
|
98
|
-
return refinedSchema;
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
|
|
103
356
|
function regexp(params) {
|
|
104
|
-
const schema = custom(
|
|
357
|
+
const schema = custom$1(
|
|
105
358
|
(val) => val instanceof RegExp,
|
|
106
359
|
composeParams(
|
|
107
360
|
() => "Input is not a regexp",
|
|
@@ -112,844 +365,1210 @@ function regexp(params) {
|
|
|
112
365
|
return schema;
|
|
113
366
|
}
|
|
114
367
|
|
|
368
|
+
const KrustyType = /* @__PURE__ */ core.$constructor(
|
|
369
|
+
"KrustyType",
|
|
370
|
+
(inst, def) => {
|
|
371
|
+
const coreInit = core.$ZodType.init;
|
|
372
|
+
coreInit(inst, def);
|
|
373
|
+
inst.def = def;
|
|
374
|
+
inst.type = def.type;
|
|
375
|
+
Object.defineProperty(inst, "_def", { value: def });
|
|
376
|
+
inst.check = (...checks2) => {
|
|
377
|
+
return inst.clone(
|
|
378
|
+
util.mergeDefs(def, {
|
|
379
|
+
checks: [
|
|
380
|
+
...def.checks ?? [],
|
|
381
|
+
...checks2.map(
|
|
382
|
+
(ch) => typeof ch === "function" ? { _zod: { check: ch, def: { check: "custom" }, onattach: [] } } : ch
|
|
383
|
+
)
|
|
384
|
+
]
|
|
385
|
+
})
|
|
386
|
+
);
|
|
387
|
+
};
|
|
388
|
+
inst.clone = (def2, params) => core.clone(inst, def2, params);
|
|
389
|
+
inst.brand = () => inst;
|
|
390
|
+
inst.register = ((reg, meta) => {
|
|
391
|
+
reg.add(inst, meta);
|
|
392
|
+
return inst;
|
|
393
|
+
});
|
|
394
|
+
inst.parse = (data, params) => parse(inst, data, params, { callee: inst.parse });
|
|
395
|
+
inst.safeParse = (data, params) => safeParse(inst, data, params);
|
|
396
|
+
inst.parseAsync = async (data, params) => parseAsync(inst, data, params, { callee: inst.parseAsync });
|
|
397
|
+
inst.safeParseAsync = async (data, params) => safeParseAsync(inst, data, params);
|
|
398
|
+
inst.spa = inst.safeParseAsync;
|
|
399
|
+
inst.encode = (data, params) => encode(inst, data, params);
|
|
400
|
+
inst.decode = (data, params) => decode(inst, data, params);
|
|
401
|
+
inst.encodeAsync = async (data, params) => encodeAsync(inst, data, params);
|
|
402
|
+
inst.decodeAsync = async (data, params) => decodeAsync(inst, data, params);
|
|
403
|
+
inst.safeEncode = (data, params) => safeEncode(inst, data, params);
|
|
404
|
+
inst.safeDecode = (data, params) => safeDecode(inst, data, params);
|
|
405
|
+
inst.safeEncodeAsync = async (data, params) => safeEncodeAsync(inst, data, params);
|
|
406
|
+
inst.safeDecodeAsync = async (data, params) => safeDecodeAsync(inst, data, params);
|
|
407
|
+
inst.refine = (check2, params) => inst.check(refine(check2, params));
|
|
408
|
+
inst.superRefine = (refinement) => inst.check(superRefine(refinement));
|
|
409
|
+
inst.overwrite = (fn) => inst.check(_overwrite(fn));
|
|
410
|
+
inst.gate = (gateName) => gate(inst, gateName);
|
|
411
|
+
inst.optional = () => optional(inst);
|
|
412
|
+
inst.nullable = () => nullable(inst);
|
|
413
|
+
inst.nullish = () => optional(nullable(inst));
|
|
414
|
+
inst.nonoptional = (params) => nonoptional(inst, params);
|
|
415
|
+
inst.array = () => array(inst);
|
|
416
|
+
inst.or = (arg) => union([inst, arg]);
|
|
417
|
+
inst.and = (arg) => intersection(inst, arg);
|
|
418
|
+
inst.transform = (tx) => pipe(inst, transform(tx));
|
|
419
|
+
inst.default = (def2) => _default(inst, def2);
|
|
420
|
+
inst.prefault = (def2) => prefault(inst, def2);
|
|
421
|
+
return inst;
|
|
422
|
+
}
|
|
423
|
+
);
|
|
424
|
+
const _ZodString = /* @__PURE__ */ core.$constructor(
|
|
425
|
+
"_ZodString",
|
|
426
|
+
(inst, def) => {
|
|
427
|
+
const coreInit = core.$ZodString.init;
|
|
428
|
+
coreInit(inst, def);
|
|
429
|
+
KrustyType.init(inst, def);
|
|
430
|
+
const bag = inst._zod.bag;
|
|
431
|
+
inst.format = bag.format ?? null;
|
|
432
|
+
inst.minLength = bag.minimum ?? null;
|
|
433
|
+
inst.maxLength = bag.maximum ?? null;
|
|
434
|
+
inst.regex = (...args) => inst.check(_regex(...args));
|
|
435
|
+
inst.includes = (...args) => inst.check(_includes(...args));
|
|
436
|
+
inst.startsWith = (...args) => inst.check(_startsWith(...args));
|
|
437
|
+
inst.endsWith = (...args) => inst.check(_endsWith(...args));
|
|
438
|
+
inst.min = (...args) => inst.check(_minLength(...args));
|
|
439
|
+
inst.max = (...args) => inst.check(_maxLength(...args));
|
|
440
|
+
inst.length = (...args) => inst.check(_length(...args));
|
|
441
|
+
inst.nonempty = (...args) => inst.check(_minLength(1, ...args));
|
|
442
|
+
inst.lowercase = (params) => inst.check(_lowercase(params));
|
|
443
|
+
inst.uppercase = (params) => inst.check(_uppercase(params));
|
|
444
|
+
inst.trim = () => inst.check(_trim());
|
|
445
|
+
inst.normalize = (...args) => inst.check(_normalize(...args));
|
|
446
|
+
inst.toLowerCase = () => inst.check(_toLowerCase());
|
|
447
|
+
inst.toUpperCase = () => inst.check(_toUpperCase());
|
|
448
|
+
}
|
|
449
|
+
);
|
|
450
|
+
const ZodString = /* @__PURE__ */ core.$constructor(
|
|
451
|
+
"ZodString",
|
|
452
|
+
(inst, def) => {
|
|
453
|
+
const coreInit = core.$ZodString.init;
|
|
454
|
+
coreInit(inst, def);
|
|
455
|
+
_ZodString.init(inst, def);
|
|
456
|
+
inst.email = (params) => inst.check(core._email(ZodEmail, params));
|
|
457
|
+
inst.url = (params) => inst.check(core._url(ZodURL, params));
|
|
458
|
+
inst.jwt = (params) => inst.check(core._jwt(ZodJWT, params));
|
|
459
|
+
inst.emoji = (params) => inst.check(core._emoji(ZodEmoji, params));
|
|
460
|
+
inst.guid = (params) => inst.check(core._guid(ZodGUID, params));
|
|
461
|
+
inst.uuid = (params) => inst.check(core._uuid(ZodUUID, params));
|
|
462
|
+
inst.uuidv4 = (params) => inst.check(core._uuidv4(ZodUUID, params));
|
|
463
|
+
inst.uuidv6 = (params) => inst.check(core._uuidv6(ZodUUID, params));
|
|
464
|
+
inst.uuidv7 = (params) => inst.check(core._uuidv7(ZodUUID, params));
|
|
465
|
+
inst.nanoid = (params) => inst.check(core._nanoid(ZodNanoID, params));
|
|
466
|
+
inst.guid = (params) => inst.check(core._guid(ZodGUID, params));
|
|
467
|
+
inst.cuid = (params) => inst.check(core._cuid(ZodCUID, params));
|
|
468
|
+
inst.cuid2 = (params) => inst.check(core._cuid2(ZodCUID2, params));
|
|
469
|
+
inst.ulid = (params) => inst.check(core._ulid(ZodULID, params));
|
|
470
|
+
inst.base64 = (params) => inst.check(core._base64(ZodBase64, params));
|
|
471
|
+
inst.base64url = (params) => inst.check(core._base64url(ZodBase64URL, params));
|
|
472
|
+
inst.xid = (params) => inst.check(core._xid(ZodXID, params));
|
|
473
|
+
inst.ksuid = (params) => inst.check(core._ksuid(ZodKSUID, params));
|
|
474
|
+
inst.ipv4 = (params) => inst.check(core._ipv4(ZodIPv4, params));
|
|
475
|
+
inst.ipv6 = (params) => inst.check(core._ipv6(ZodIPv6, params));
|
|
476
|
+
inst.cidrv4 = (params) => inst.check(core._cidrv4(ZodCIDRv4, params));
|
|
477
|
+
inst.cidrv6 = (params) => inst.check(core._cidrv6(ZodCIDRv6, params));
|
|
478
|
+
inst.e164 = (params) => inst.check(core._e164(ZodE164, params));
|
|
479
|
+
inst.datetime = (params) => inst.check(datetime(params));
|
|
480
|
+
inst.date = (params) => inst.check(date$1(params));
|
|
481
|
+
inst.time = (params) => inst.check(time(params));
|
|
482
|
+
inst.duration = (params) => inst.check(duration(params));
|
|
483
|
+
}
|
|
484
|
+
);
|
|
485
|
+
function string(params) {
|
|
486
|
+
return core._string(ZodString, params);
|
|
487
|
+
}
|
|
488
|
+
const ZodStringFormat = /* @__PURE__ */ core.$constructor(
|
|
489
|
+
"ZodStringFormat",
|
|
490
|
+
(inst, def) => {
|
|
491
|
+
const coreInit = core.$ZodStringFormat.init;
|
|
492
|
+
coreInit(inst, def);
|
|
493
|
+
_ZodString.init(inst, def);
|
|
494
|
+
}
|
|
495
|
+
);
|
|
496
|
+
const ZodEmail = /* @__PURE__ */ core.$constructor(
|
|
497
|
+
"ZodEmail",
|
|
498
|
+
(inst, def) => {
|
|
499
|
+
const coreInit = core.$ZodEmail.init;
|
|
500
|
+
coreInit(inst, def);
|
|
501
|
+
ZodStringFormat.init(inst, def);
|
|
502
|
+
}
|
|
503
|
+
);
|
|
504
|
+
function email(params) {
|
|
505
|
+
return core._email(ZodEmail, params);
|
|
506
|
+
}
|
|
507
|
+
const ZodGUID = /* @__PURE__ */ core.$constructor("ZodGUID", (inst, def) => {
|
|
508
|
+
const coreInit = core.$ZodGUID.init;
|
|
509
|
+
coreInit(inst, def);
|
|
510
|
+
ZodStringFormat.init(inst, def);
|
|
511
|
+
});
|
|
512
|
+
function guid(params) {
|
|
513
|
+
return core._guid(ZodGUID, params);
|
|
514
|
+
}
|
|
515
|
+
const ZodUUID = /* @__PURE__ */ core.$constructor("ZodUUID", (inst, def) => {
|
|
516
|
+
const coreInit = core.$ZodUUID.init;
|
|
517
|
+
coreInit(inst, def);
|
|
518
|
+
ZodStringFormat.init(inst, def);
|
|
519
|
+
});
|
|
520
|
+
function uuid(params) {
|
|
521
|
+
return core._uuid(ZodUUID, params);
|
|
522
|
+
}
|
|
523
|
+
function uuidv4(params) {
|
|
524
|
+
return core._uuidv4(ZodUUID, params);
|
|
525
|
+
}
|
|
526
|
+
function uuidv6(params) {
|
|
527
|
+
return core._uuidv6(ZodUUID, params);
|
|
528
|
+
}
|
|
529
|
+
function uuidv7(params) {
|
|
530
|
+
return core._uuidv7(ZodUUID, params);
|
|
531
|
+
}
|
|
532
|
+
const ZodURL = /* @__PURE__ */ core.$constructor("ZodURL", (inst, def) => {
|
|
533
|
+
const coreInit = core.$ZodURL.init;
|
|
534
|
+
coreInit(inst, def);
|
|
535
|
+
ZodStringFormat.init(inst, def);
|
|
536
|
+
});
|
|
115
537
|
function url(params) {
|
|
116
|
-
|
|
117
|
-
(val) => val instanceof URL,
|
|
118
|
-
composeParams(
|
|
119
|
-
() => "Input is not a URL",
|
|
120
|
-
params
|
|
121
|
-
)
|
|
122
|
-
);
|
|
123
|
-
setCustomZodDef(schema._def, { type: "url" });
|
|
124
|
-
return schema;
|
|
538
|
+
return core._url(ZodURL, params);
|
|
125
539
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
540
|
+
function httpUrl(params) {
|
|
541
|
+
return core._url(ZodURL, {
|
|
542
|
+
protocol: /^https?$/,
|
|
543
|
+
hostname: core.regexes.domain,
|
|
544
|
+
...util.normalizeParams(params)
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
const ZodEmoji = /* @__PURE__ */ core.$constructor(
|
|
548
|
+
"ZodEmoji",
|
|
549
|
+
(inst, def) => {
|
|
550
|
+
const coreInit = core.$ZodEmoji.init;
|
|
551
|
+
coreInit(inst, def);
|
|
552
|
+
ZodStringFormat.init(inst, def);
|
|
553
|
+
}
|
|
554
|
+
);
|
|
555
|
+
function emoji(params) {
|
|
556
|
+
return core._emoji(ZodEmoji, params);
|
|
557
|
+
}
|
|
558
|
+
const ZodNanoID = /* @__PURE__ */ core.$constructor(
|
|
559
|
+
"ZodNanoID",
|
|
560
|
+
(inst, def) => {
|
|
561
|
+
const coreInit = core.$ZodNanoID.init;
|
|
562
|
+
coreInit(inst, def);
|
|
563
|
+
ZodStringFormat.init(inst, def);
|
|
564
|
+
}
|
|
565
|
+
);
|
|
566
|
+
function nanoid(params) {
|
|
567
|
+
return core._nanoid(ZodNanoID, params);
|
|
568
|
+
}
|
|
569
|
+
const ZodCUID = /* @__PURE__ */ core.$constructor("ZodCUID", (inst, def) => {
|
|
570
|
+
const coreInit = core.$ZodCUID.init;
|
|
571
|
+
coreInit(inst, def);
|
|
572
|
+
ZodStringFormat.init(inst, def);
|
|
573
|
+
});
|
|
574
|
+
function cuid(params) {
|
|
575
|
+
return core._cuid(ZodCUID, params);
|
|
576
|
+
}
|
|
577
|
+
const ZodCUID2 = /* @__PURE__ */ core.$constructor(
|
|
578
|
+
"ZodCUID2",
|
|
579
|
+
(inst, def) => {
|
|
580
|
+
const coreInit = core.$ZodCUID2.init;
|
|
581
|
+
coreInit(inst, def);
|
|
582
|
+
ZodStringFormat.init(inst, def);
|
|
583
|
+
}
|
|
584
|
+
);
|
|
585
|
+
function cuid2(params) {
|
|
586
|
+
return core._cuid2(ZodCUID2, params);
|
|
587
|
+
}
|
|
588
|
+
const ZodULID = /* @__PURE__ */ core.$constructor("ZodULID", (inst, def) => {
|
|
589
|
+
const coreInit = core.$ZodULID.init;
|
|
590
|
+
coreInit(inst, def);
|
|
591
|
+
ZodStringFormat.init(inst, def);
|
|
592
|
+
});
|
|
593
|
+
function ulid(params) {
|
|
594
|
+
return core._ulid(ZodULID, params);
|
|
595
|
+
}
|
|
596
|
+
const ZodXID = /* @__PURE__ */ core.$constructor("ZodXID", (inst, def) => {
|
|
597
|
+
const coreInit = core.$ZodXID.init;
|
|
598
|
+
coreInit(inst, def);
|
|
599
|
+
ZodStringFormat.init(inst, def);
|
|
600
|
+
});
|
|
601
|
+
function xid(params) {
|
|
602
|
+
return core._xid(ZodXID, params);
|
|
603
|
+
}
|
|
604
|
+
const ZodKSUID = /* @__PURE__ */ core.$constructor(
|
|
605
|
+
"ZodKSUID",
|
|
606
|
+
(inst, def) => {
|
|
607
|
+
const coreInit = core.$ZodKSUID.init;
|
|
608
|
+
coreInit(inst, def);
|
|
609
|
+
ZodStringFormat.init(inst, def);
|
|
610
|
+
}
|
|
611
|
+
);
|
|
612
|
+
function ksuid(params) {
|
|
613
|
+
return core._ksuid(ZodKSUID, params);
|
|
614
|
+
}
|
|
615
|
+
const ZodIPv4 = /* @__PURE__ */ core.$constructor("ZodIPv4", (inst, def) => {
|
|
616
|
+
const coreInit = core.$ZodIPv4.init;
|
|
617
|
+
coreInit(inst, def);
|
|
618
|
+
ZodStringFormat.init(inst, def);
|
|
619
|
+
});
|
|
620
|
+
function ipv4(params) {
|
|
621
|
+
return core._ipv4(ZodIPv4, params);
|
|
622
|
+
}
|
|
623
|
+
const ZodIPv6 = /* @__PURE__ */ core.$constructor("ZodIPv6", (inst, def) => {
|
|
624
|
+
const coreInit = core.$ZodIPv6.init;
|
|
625
|
+
coreInit(inst, def);
|
|
626
|
+
ZodStringFormat.init(inst, def);
|
|
627
|
+
});
|
|
628
|
+
function ipv6(params) {
|
|
629
|
+
return core._ipv6(ZodIPv6, params);
|
|
630
|
+
}
|
|
631
|
+
const ZodCIDRv4 = /* @__PURE__ */ core.$constructor(
|
|
632
|
+
"ZodCIDRv4",
|
|
633
|
+
(inst, def) => {
|
|
634
|
+
const coreInit = core.$ZodCIDRv4.init;
|
|
635
|
+
coreInit(inst, def);
|
|
636
|
+
ZodStringFormat.init(inst, def);
|
|
637
|
+
}
|
|
638
|
+
);
|
|
639
|
+
function cidrv4(params) {
|
|
640
|
+
return core._cidrv4(ZodCIDRv4, params);
|
|
641
|
+
}
|
|
642
|
+
const ZodCIDRv6 = /* @__PURE__ */ core.$constructor(
|
|
643
|
+
"ZodCIDRv6",
|
|
644
|
+
(inst, def) => {
|
|
645
|
+
const coreInit = core.$ZodCIDRv6.init;
|
|
646
|
+
coreInit(inst, def);
|
|
647
|
+
ZodStringFormat.init(inst, def);
|
|
648
|
+
}
|
|
649
|
+
);
|
|
650
|
+
function cidrv6(params) {
|
|
651
|
+
return core._cidrv6(ZodCIDRv6, params);
|
|
652
|
+
}
|
|
653
|
+
const ZodBase64 = /* @__PURE__ */ core.$constructor(
|
|
654
|
+
"ZodBase64",
|
|
655
|
+
(inst, def) => {
|
|
656
|
+
const coreInit = core.$ZodBase64.init;
|
|
657
|
+
coreInit(inst, def);
|
|
658
|
+
ZodStringFormat.init(inst, def);
|
|
659
|
+
}
|
|
660
|
+
);
|
|
661
|
+
function base64(params) {
|
|
662
|
+
return core._base64(ZodBase64, params);
|
|
663
|
+
}
|
|
664
|
+
const ZodBase64URL = /* @__PURE__ */ core.$constructor(
|
|
665
|
+
"ZodBase64URL",
|
|
666
|
+
(inst, def) => {
|
|
667
|
+
const coreInit = core.$ZodBase64URL.init;
|
|
668
|
+
coreInit(inst, def);
|
|
669
|
+
ZodStringFormat.init(inst, def);
|
|
670
|
+
}
|
|
671
|
+
);
|
|
672
|
+
function base64url(params) {
|
|
673
|
+
return core._base64url(ZodBase64URL, params);
|
|
674
|
+
}
|
|
675
|
+
const ZodE164 = /* @__PURE__ */ core.$constructor("ZodE164", (inst, def) => {
|
|
676
|
+
const coreInit = core.$ZodE164.init;
|
|
677
|
+
coreInit(inst, def);
|
|
678
|
+
ZodStringFormat.init(inst, def);
|
|
679
|
+
});
|
|
680
|
+
function e164(params) {
|
|
681
|
+
return core._e164(ZodE164, params);
|
|
682
|
+
}
|
|
683
|
+
const ZodJWT = /* @__PURE__ */ core.$constructor("ZodJWT", (inst, def) => {
|
|
684
|
+
const coreInit = core.$ZodJWT.init;
|
|
685
|
+
coreInit(inst, def);
|
|
686
|
+
ZodStringFormat.init(inst, def);
|
|
687
|
+
});
|
|
688
|
+
function jwt(params) {
|
|
689
|
+
return core._jwt(ZodJWT, params);
|
|
690
|
+
}
|
|
691
|
+
const ZodCustomStringFormat = /* @__PURE__ */ core.$constructor("ZodCustomStringFormat", (inst, def) => {
|
|
692
|
+
const coreInit = core.$ZodCustomStringFormat.init;
|
|
693
|
+
coreInit(inst, def);
|
|
694
|
+
ZodStringFormat.init(inst, def);
|
|
695
|
+
});
|
|
696
|
+
function stringFormat(format, fnOrRegex, _params = {}) {
|
|
697
|
+
return core._stringFormat(ZodCustomStringFormat, format, fnOrRegex, _params);
|
|
698
|
+
}
|
|
699
|
+
function hostname(_params) {
|
|
700
|
+
return core._stringFormat(ZodCustomStringFormat, "hostname", core.regexes.hostname, _params);
|
|
701
|
+
}
|
|
702
|
+
function hex(_params) {
|
|
703
|
+
return core._stringFormat(ZodCustomStringFormat, "hex", core.regexes.hex, _params);
|
|
704
|
+
}
|
|
705
|
+
function hash(alg, params) {
|
|
706
|
+
const enc = params?.enc ?? "hex";
|
|
707
|
+
const format = `${alg}_${enc}`;
|
|
708
|
+
const regex = core.regexes[format];
|
|
709
|
+
if (!regex) throw new Error(`Unrecognized hash format: ${format}`);
|
|
710
|
+
return core._stringFormat(ZodCustomStringFormat, format, regex, params);
|
|
711
|
+
}
|
|
712
|
+
const ZodNumber = /* @__PURE__ */ core.$constructor(
|
|
713
|
+
"ZodNumber",
|
|
714
|
+
(inst, def) => {
|
|
715
|
+
const coreInit = core.$ZodNumber.init;
|
|
716
|
+
coreInit(inst, def);
|
|
717
|
+
KrustyType.init(inst, def);
|
|
718
|
+
inst.gt = (value, params) => inst.check(_gt(value, params));
|
|
719
|
+
inst.gte = (value, params) => inst.check(_gte(value, params));
|
|
720
|
+
inst.min = (value, params) => inst.check(_gte(value, params));
|
|
721
|
+
inst.lt = (value, params) => inst.check(_lt(value, params));
|
|
722
|
+
inst.lte = (value, params) => inst.check(_lte(value, params));
|
|
723
|
+
inst.max = (value, params) => inst.check(_lte(value, params));
|
|
724
|
+
inst.int = (params) => inst.check(int(params));
|
|
725
|
+
inst.safe = (params) => inst.check(int(params));
|
|
726
|
+
inst.positive = (params) => inst.check(_gt(0, params));
|
|
727
|
+
inst.nonnegative = (params) => inst.check(_gte(0, params));
|
|
728
|
+
inst.negative = (params) => inst.check(_lt(0, params));
|
|
729
|
+
inst.nonpositive = (params) => inst.check(_lte(0, params));
|
|
730
|
+
inst.multipleOf = (value, params) => inst.check(_multipleOf(value, params));
|
|
731
|
+
inst.step = (value, params) => inst.check(_multipleOf(value, params));
|
|
732
|
+
inst.finite = () => inst;
|
|
733
|
+
const bag = inst._zod.bag;
|
|
734
|
+
inst.minValue = Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;
|
|
735
|
+
inst.maxValue = Math.min(bag.maximum ?? Number.POSITIVE_INFINITY, bag.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null;
|
|
736
|
+
inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? 0.5);
|
|
737
|
+
inst.isFinite = true;
|
|
738
|
+
inst.format = bag.format ?? null;
|
|
739
|
+
}
|
|
740
|
+
);
|
|
741
|
+
function number(params) {
|
|
742
|
+
return core._number(ZodNumber, params);
|
|
743
|
+
}
|
|
744
|
+
const ZodNumberFormat = /* @__PURE__ */ core.$constructor(
|
|
745
|
+
"ZodNumberFormat",
|
|
746
|
+
(inst, def) => {
|
|
747
|
+
const coreInit = core.$ZodNumberFormat.init;
|
|
748
|
+
coreInit(inst, def);
|
|
749
|
+
ZodNumber.init(inst, def);
|
|
750
|
+
}
|
|
751
|
+
);
|
|
752
|
+
function int(params) {
|
|
753
|
+
return core._int(ZodNumberFormat, params);
|
|
754
|
+
}
|
|
755
|
+
function float32(params) {
|
|
756
|
+
return core._float32(ZodNumberFormat, params);
|
|
757
|
+
}
|
|
758
|
+
function float64(params) {
|
|
759
|
+
return core._float64(ZodNumberFormat, params);
|
|
760
|
+
}
|
|
761
|
+
function int32(params) {
|
|
762
|
+
return core._int32(ZodNumberFormat, params);
|
|
763
|
+
}
|
|
764
|
+
function uint32(params) {
|
|
765
|
+
return core._uint32(ZodNumberFormat, params);
|
|
766
|
+
}
|
|
767
|
+
const ZodBoolean = /* @__PURE__ */ core.$constructor(
|
|
768
|
+
"ZodBoolean",
|
|
769
|
+
(inst, def) => {
|
|
770
|
+
const coreInit = core.$ZodBoolean.init;
|
|
771
|
+
coreInit(inst, def);
|
|
772
|
+
KrustyType.init(inst, def);
|
|
773
|
+
}
|
|
774
|
+
);
|
|
775
|
+
function boolean(params) {
|
|
776
|
+
return core._boolean(ZodBoolean, params);
|
|
777
|
+
}
|
|
778
|
+
const ZodBigInt = /* @__PURE__ */ core.$constructor(
|
|
779
|
+
"ZodBigInt",
|
|
780
|
+
(inst, def) => {
|
|
781
|
+
const coreInit = core.$ZodBigInt.init;
|
|
782
|
+
coreInit(inst, def);
|
|
783
|
+
KrustyType.init(inst, def);
|
|
784
|
+
inst.gte = (value, params) => inst.check(_gte(value, params));
|
|
785
|
+
inst.min = (value, params) => inst.check(_gte(value, params));
|
|
786
|
+
inst.gt = (value, params) => inst.check(_gt(value, params));
|
|
787
|
+
inst.gte = (value, params) => inst.check(_gte(value, params));
|
|
788
|
+
inst.min = (value, params) => inst.check(_gte(value, params));
|
|
789
|
+
inst.lt = (value, params) => inst.check(_lt(value, params));
|
|
790
|
+
inst.lte = (value, params) => inst.check(_lte(value, params));
|
|
791
|
+
inst.max = (value, params) => inst.check(_lte(value, params));
|
|
792
|
+
inst.positive = (params) => inst.check(_gt(BigInt(0), params));
|
|
793
|
+
inst.negative = (params) => inst.check(_lt(BigInt(0), params));
|
|
794
|
+
inst.nonpositive = (params) => inst.check(_lte(BigInt(0), params));
|
|
795
|
+
inst.nonnegative = (params) => inst.check(_gte(BigInt(0), params));
|
|
796
|
+
inst.multipleOf = (value, params) => inst.check(_multipleOf(value, params));
|
|
797
|
+
const bag = inst._zod.bag;
|
|
798
|
+
inst.minValue = bag.minimum ?? null;
|
|
799
|
+
inst.maxValue = bag.maximum ?? null;
|
|
800
|
+
inst.format = bag.format ?? null;
|
|
801
|
+
}
|
|
802
|
+
);
|
|
803
|
+
function bigint(params) {
|
|
804
|
+
return core._bigint(ZodBigInt, params);
|
|
805
|
+
}
|
|
806
|
+
const ZodBigIntFormat = /* @__PURE__ */ core.$constructor(
|
|
807
|
+
"ZodBigIntFormat",
|
|
808
|
+
(inst, def) => {
|
|
809
|
+
const coreInit = core.$ZodBigIntFormat.init;
|
|
810
|
+
coreInit(inst, def);
|
|
811
|
+
ZodBigInt.init(inst, def);
|
|
812
|
+
}
|
|
813
|
+
);
|
|
814
|
+
function int64(params) {
|
|
815
|
+
return core._int64(ZodBigIntFormat, params);
|
|
816
|
+
}
|
|
817
|
+
function uint64(params) {
|
|
818
|
+
return core._uint64(ZodBigIntFormat, params);
|
|
819
|
+
}
|
|
820
|
+
const ZodSymbol = /* @__PURE__ */ core.$constructor(
|
|
821
|
+
"ZodSymbol",
|
|
822
|
+
(inst, def) => {
|
|
823
|
+
const coreInit = core.$ZodSymbol.init;
|
|
824
|
+
coreInit(inst, def);
|
|
825
|
+
KrustyType.init(inst, def);
|
|
826
|
+
}
|
|
827
|
+
);
|
|
828
|
+
function symbol(params) {
|
|
829
|
+
return core._symbol(ZodSymbol, params);
|
|
830
|
+
}
|
|
831
|
+
const ZodUndefined = /* @__PURE__ */ core.$constructor(
|
|
832
|
+
"ZodUndefined",
|
|
833
|
+
(inst, def) => {
|
|
834
|
+
const coreInit = core.$ZodUndefined.init;
|
|
835
|
+
coreInit(inst, def);
|
|
836
|
+
KrustyType.init(inst, def);
|
|
837
|
+
}
|
|
838
|
+
);
|
|
839
|
+
function _undefined(params) {
|
|
840
|
+
return core._undefined(ZodUndefined, params);
|
|
841
|
+
}
|
|
842
|
+
const ZodNull = /* @__PURE__ */ core.$constructor("ZodNull", (inst, def) => {
|
|
843
|
+
const coreInit = core.$ZodNull.init;
|
|
844
|
+
coreInit(inst, def);
|
|
845
|
+
KrustyType.init(inst, def);
|
|
846
|
+
});
|
|
847
|
+
function _null(params) {
|
|
848
|
+
return core._null(ZodNull, params);
|
|
849
|
+
}
|
|
850
|
+
const ZodAny = /* @__PURE__ */ core.$constructor("ZodAny", (inst, def) => {
|
|
851
|
+
const coreInit = core.$ZodAny.init;
|
|
852
|
+
coreInit(inst, def);
|
|
853
|
+
KrustyType.init(inst, def);
|
|
854
|
+
});
|
|
855
|
+
function any() {
|
|
856
|
+
return core._any(ZodAny);
|
|
857
|
+
}
|
|
858
|
+
const ZodUnknown = /* @__PURE__ */ core.$constructor(
|
|
859
|
+
"ZodUnknown",
|
|
860
|
+
(inst, def) => {
|
|
861
|
+
const coreInit = core.$ZodUnknown.init;
|
|
862
|
+
coreInit(inst, def);
|
|
863
|
+
KrustyType.init(inst, def);
|
|
864
|
+
}
|
|
865
|
+
);
|
|
866
|
+
function unknown() {
|
|
867
|
+
return core._unknown(ZodUnknown);
|
|
868
|
+
}
|
|
869
|
+
const ZodNever = /* @__PURE__ */ core.$constructor(
|
|
870
|
+
"ZodNever",
|
|
871
|
+
(inst, def) => {
|
|
872
|
+
const coreInit = core.$ZodNever.init;
|
|
873
|
+
coreInit(inst, def);
|
|
874
|
+
KrustyType.init(inst, def);
|
|
875
|
+
}
|
|
876
|
+
);
|
|
877
|
+
function never(params) {
|
|
878
|
+
return core._never(ZodNever, params);
|
|
879
|
+
}
|
|
880
|
+
const ZodVoid = /* @__PURE__ */ core.$constructor("ZodVoid", (inst, def) => {
|
|
881
|
+
const coreInit = core.$ZodVoid.init;
|
|
882
|
+
coreInit(inst, def);
|
|
883
|
+
KrustyType.init(inst, def);
|
|
884
|
+
});
|
|
885
|
+
function _void(params) {
|
|
886
|
+
return core._void(ZodVoid, params);
|
|
887
|
+
}
|
|
888
|
+
const ZodDate = /* @__PURE__ */ core.$constructor("ZodDate", (inst, def) => {
|
|
889
|
+
const coreInit = core.$ZodDate.init;
|
|
890
|
+
coreInit(inst, def);
|
|
891
|
+
KrustyType.init(inst, def);
|
|
892
|
+
inst.min = (value, params) => inst.check(_gte(value, params));
|
|
893
|
+
inst.max = (value, params) => inst.check(_lte(value, params));
|
|
894
|
+
const c = inst._zod.bag;
|
|
895
|
+
inst.minDate = c.minimum ? new Date(c.minimum) : null;
|
|
896
|
+
inst.maxDate = c.maximum ? new Date(c.maximum) : null;
|
|
897
|
+
});
|
|
898
|
+
function date(params) {
|
|
899
|
+
return core._date(ZodDate, params);
|
|
900
|
+
}
|
|
901
|
+
const ZodArray = /* @__PURE__ */ core.$constructor(
|
|
902
|
+
"ZodArray",
|
|
903
|
+
(inst, def) => {
|
|
904
|
+
const coreInit = core.$ZodArray.init;
|
|
905
|
+
coreInit(inst, def);
|
|
906
|
+
KrustyType.init(inst, def);
|
|
907
|
+
inst.element = def.element;
|
|
908
|
+
inst.min = (minLength, params) => inst.check(_minLength(minLength, params));
|
|
909
|
+
inst.nonempty = (params) => inst.check(_minLength(1, params));
|
|
910
|
+
inst.max = (maxLength, params) => inst.check(_maxLength(maxLength, params));
|
|
911
|
+
inst.length = (len, params) => inst.check(_length(len, params));
|
|
912
|
+
inst.unwrap = () => inst.element;
|
|
913
|
+
}
|
|
914
|
+
);
|
|
915
|
+
function array(element, params) {
|
|
916
|
+
return core._array(ZodArray, element, params);
|
|
917
|
+
}
|
|
918
|
+
function keyof(schema) {
|
|
919
|
+
const shape = schema._zod.def.shape;
|
|
920
|
+
return _enum(Object.keys(shape));
|
|
921
|
+
}
|
|
922
|
+
const ZodIntersection = /* @__PURE__ */ core.$constructor(
|
|
923
|
+
"ZodIntersection",
|
|
924
|
+
(inst, def) => {
|
|
925
|
+
const coreInit = core.$ZodIntersection.init;
|
|
926
|
+
coreInit(inst, def);
|
|
927
|
+
KrustyType.init(inst, def);
|
|
928
|
+
}
|
|
929
|
+
);
|
|
930
|
+
function intersection(left, right) {
|
|
931
|
+
return new ZodIntersection({
|
|
932
|
+
type: "intersection",
|
|
933
|
+
left,
|
|
934
|
+
right
|
|
935
|
+
});
|
|
936
|
+
}
|
|
937
|
+
const ZodTuple = /* @__PURE__ */ core.$constructor(
|
|
938
|
+
"ZodTuple",
|
|
939
|
+
(inst, def) => {
|
|
940
|
+
const coreInit = core.$ZodTuple.init;
|
|
941
|
+
coreInit(inst, def);
|
|
942
|
+
KrustyType.init(inst, def);
|
|
943
|
+
inst.rest = (rest) => inst.clone({
|
|
944
|
+
...inst._zod.def,
|
|
945
|
+
rest
|
|
137
946
|
});
|
|
138
947
|
}
|
|
948
|
+
);
|
|
949
|
+
function tuple(items, _paramsOrRest, _params) {
|
|
950
|
+
const hasRest = _paramsOrRest instanceof core.$ZodType;
|
|
951
|
+
const params = hasRest ? _params : _paramsOrRest;
|
|
952
|
+
const rest = hasRest ? _paramsOrRest : null;
|
|
953
|
+
return new ZodTuple({
|
|
954
|
+
type: "tuple",
|
|
955
|
+
items,
|
|
956
|
+
rest,
|
|
957
|
+
...util.normalizeParams(params)
|
|
958
|
+
});
|
|
139
959
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
case "url": {
|
|
150
|
-
if (typeof value === "string") {
|
|
151
|
-
return safeToURL(value);
|
|
152
|
-
}
|
|
153
|
-
return value;
|
|
154
|
-
}
|
|
960
|
+
const ZodRecord = /* @__PURE__ */ core.$constructor(
|
|
961
|
+
"ZodRecord",
|
|
962
|
+
(inst, def) => {
|
|
963
|
+
const coreInit = core.$ZodRecord.init;
|
|
964
|
+
coreInit(inst, def);
|
|
965
|
+
KrustyType.init(inst, def);
|
|
966
|
+
inst.keyType = def.keyType;
|
|
967
|
+
inst.valueType = def.valueType;
|
|
155
968
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
969
|
+
);
|
|
970
|
+
function record(keyType, valueType, params) {
|
|
971
|
+
return new ZodRecord({
|
|
972
|
+
type: "record",
|
|
973
|
+
keyType,
|
|
974
|
+
valueType,
|
|
975
|
+
...util.normalizeParams(params)
|
|
976
|
+
});
|
|
977
|
+
}
|
|
978
|
+
function partialRecord(keyType, valueType, params) {
|
|
979
|
+
const k = core.clone(keyType);
|
|
980
|
+
k._zod.values = void 0;
|
|
981
|
+
return new ZodRecord({
|
|
982
|
+
type: "record",
|
|
983
|
+
keyType: k,
|
|
984
|
+
valueType,
|
|
985
|
+
...util.normalizeParams(params)
|
|
986
|
+
});
|
|
987
|
+
}
|
|
988
|
+
const ZodMap = /* @__PURE__ */ core.$constructor("ZodMap", (inst, def) => {
|
|
989
|
+
const coreInit = core.$ZodMap.init;
|
|
990
|
+
coreInit(inst, def);
|
|
991
|
+
KrustyType.init(inst, def);
|
|
992
|
+
inst.keyType = def.keyType;
|
|
993
|
+
inst.valueType = def.valueType;
|
|
994
|
+
});
|
|
995
|
+
function map(keyType, valueType, params) {
|
|
996
|
+
return new ZodMap({
|
|
997
|
+
type: "map",
|
|
998
|
+
keyType,
|
|
999
|
+
valueType,
|
|
1000
|
+
...util.normalizeParams(params)
|
|
1001
|
+
});
|
|
1002
|
+
}
|
|
1003
|
+
const ZodSet = /* @__PURE__ */ core.$constructor("ZodSet", (inst, def) => {
|
|
1004
|
+
const coreInit = core.$ZodSet.init;
|
|
1005
|
+
coreInit(inst, def);
|
|
1006
|
+
KrustyType.init(inst, def);
|
|
1007
|
+
inst.min = (...args) => inst.check(core._minSize(...args));
|
|
1008
|
+
inst.nonempty = (params) => inst.check(core._minSize(1, params));
|
|
1009
|
+
inst.max = (...args) => inst.check(core._maxSize(...args));
|
|
1010
|
+
inst.size = (...args) => inst.check(core._size(...args));
|
|
1011
|
+
});
|
|
1012
|
+
function set(valueType, params) {
|
|
1013
|
+
return new ZodSet({
|
|
1014
|
+
type: "set",
|
|
1015
|
+
valueType,
|
|
1016
|
+
...util.normalizeParams(params)
|
|
1017
|
+
});
|
|
1018
|
+
}
|
|
1019
|
+
const ZodEnum = /* @__PURE__ */ core.$constructor("ZodEnum", (inst, def) => {
|
|
1020
|
+
const coreInit = core.$ZodEnum.init;
|
|
1021
|
+
coreInit(inst, def);
|
|
1022
|
+
KrustyType.init(inst, def);
|
|
1023
|
+
inst.enum = def.entries;
|
|
1024
|
+
inst.options = Object.values(def.entries);
|
|
1025
|
+
const keys = new Set(Object.keys(def.entries));
|
|
1026
|
+
inst.extract = (values, params) => {
|
|
1027
|
+
const newEntries = {};
|
|
1028
|
+
for (const value of values) {
|
|
1029
|
+
if (keys.has(value)) {
|
|
1030
|
+
newEntries[value] = def.entries[value];
|
|
1031
|
+
} else throw new Error(`Key ${value} not found in enum`);
|
|
181
1032
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
1033
|
+
return new ZodEnum({
|
|
1034
|
+
...def,
|
|
1035
|
+
checks: [],
|
|
1036
|
+
...util.normalizeParams(params),
|
|
1037
|
+
entries: newEntries
|
|
1038
|
+
});
|
|
1039
|
+
};
|
|
1040
|
+
inst.exclude = (values, params) => {
|
|
1041
|
+
const newEntries = { ...def.entries };
|
|
1042
|
+
for (const value of values) {
|
|
1043
|
+
if (keys.has(value)) {
|
|
1044
|
+
delete newEntries[value];
|
|
1045
|
+
} else throw new Error(`Key ${value} not found in enum`);
|
|
195
1046
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
1047
|
+
return new ZodEnum({
|
|
1048
|
+
...def,
|
|
1049
|
+
checks: [],
|
|
1050
|
+
...util.normalizeParams(params),
|
|
1051
|
+
entries: newEntries
|
|
1052
|
+
});
|
|
1053
|
+
};
|
|
1054
|
+
});
|
|
1055
|
+
function _enum(values, params) {
|
|
1056
|
+
const entries = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
|
|
1057
|
+
return new ZodEnum({
|
|
1058
|
+
type: "enum",
|
|
1059
|
+
entries,
|
|
1060
|
+
...util.normalizeParams(params)
|
|
1061
|
+
});
|
|
1062
|
+
}
|
|
1063
|
+
function nativeEnum(entries, params) {
|
|
1064
|
+
return new ZodEnum({
|
|
1065
|
+
type: "enum",
|
|
1066
|
+
entries,
|
|
1067
|
+
...util.normalizeParams(params)
|
|
1068
|
+
});
|
|
1069
|
+
}
|
|
1070
|
+
const ZodLiteral = /* @__PURE__ */ core.$constructor(
|
|
1071
|
+
"ZodLiteral",
|
|
1072
|
+
(inst, def) => {
|
|
1073
|
+
const coreInit = core.$ZodLiteral.init;
|
|
1074
|
+
coreInit(inst, def);
|
|
1075
|
+
KrustyType.init(inst, def);
|
|
1076
|
+
inst.values = new Set(def.values);
|
|
1077
|
+
Object.defineProperty(inst, "value", {
|
|
1078
|
+
get() {
|
|
1079
|
+
if (def.values.length > 1) {
|
|
1080
|
+
throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");
|
|
206
1081
|
}
|
|
1082
|
+
return def.values[0];
|
|
207
1083
|
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
1084
|
+
});
|
|
1085
|
+
}
|
|
1086
|
+
);
|
|
1087
|
+
function literal(value, params) {
|
|
1088
|
+
return new ZodLiteral({
|
|
1089
|
+
type: "literal",
|
|
1090
|
+
values: Array.isArray(value) ? value : [value],
|
|
1091
|
+
...util.normalizeParams(params)
|
|
1092
|
+
});
|
|
1093
|
+
}
|
|
1094
|
+
const ZodFile = /* @__PURE__ */ core.$constructor("ZodFile", (inst, def) => {
|
|
1095
|
+
const coreInit = core.$ZodFile.init;
|
|
1096
|
+
coreInit(inst, def);
|
|
1097
|
+
KrustyType.init(inst, def);
|
|
1098
|
+
inst.min = (size, params) => inst.check(core._minSize(size, params));
|
|
1099
|
+
inst.max = (size, params) => inst.check(core._maxSize(size, params));
|
|
1100
|
+
inst.mime = (types, params) => inst.check(core._mime(Array.isArray(types) ? types : [types], params));
|
|
1101
|
+
});
|
|
1102
|
+
function file(params) {
|
|
1103
|
+
return core._file(ZodFile, params);
|
|
1104
|
+
}
|
|
1105
|
+
const ZodTransform = /* @__PURE__ */ core.$constructor(
|
|
1106
|
+
"ZodTransform",
|
|
1107
|
+
(inst, def) => {
|
|
1108
|
+
const coreInit = core.$ZodTransform.init;
|
|
1109
|
+
coreInit(inst, def);
|
|
1110
|
+
KrustyType.init(inst, def);
|
|
1111
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
1112
|
+
if (_ctx.direction === "backward") {
|
|
1113
|
+
throw new core.$ZodEncodeError(inst.constructor.name);
|
|
219
1114
|
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
1115
|
+
payload.addIssue = (issue) => {
|
|
1116
|
+
if (typeof issue === "string") {
|
|
1117
|
+
payload.issues.push(util.issue(issue, payload.value, def));
|
|
1118
|
+
} else {
|
|
1119
|
+
const _issue = issue;
|
|
1120
|
+
if (_issue.fatal) _issue.continue = false;
|
|
1121
|
+
_issue.code ??= "custom";
|
|
1122
|
+
_issue.input ??= payload.value;
|
|
1123
|
+
_issue.inst ??= inst;
|
|
1124
|
+
payload.issues.push(util.issue(_issue));
|
|
230
1125
|
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
if (Array.isArray(value)) {
|
|
238
|
-
return value.map((v) => zodCoerceInternal(schema_._def.type, v));
|
|
239
|
-
}
|
|
240
|
-
return value;
|
|
241
|
-
}
|
|
242
|
-
case ZodFirstPartyTypeKind.ZodTuple: {
|
|
243
|
-
const schema_ = schema;
|
|
244
|
-
if (Array.isArray(value)) {
|
|
245
|
-
return value.map((v, i) => {
|
|
246
|
-
const s = schema_._def.items[i] ?? schema_._def.rest;
|
|
247
|
-
return s ? zodCoerceInternal(s, v) : v;
|
|
1126
|
+
};
|
|
1127
|
+
const output = def.transform(payload.value, payload);
|
|
1128
|
+
if (output instanceof Promise) {
|
|
1129
|
+
return output.then((output2) => {
|
|
1130
|
+
payload.value = output2;
|
|
1131
|
+
return payload;
|
|
248
1132
|
});
|
|
249
1133
|
}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
return
|
|
310
|
-
}
|
|
311
|
-
case ZodFirstPartyTypeKind.ZodCatch: {
|
|
312
|
-
const schema_ = schema;
|
|
313
|
-
return zodCoerceInternal(schema_._def.innerType, value);
|
|
314
|
-
}
|
|
315
|
-
case ZodFirstPartyTypeKind.ZodDefault: {
|
|
316
|
-
const schema_ = schema;
|
|
317
|
-
return zodCoerceInternal(schema_._def.innerType, value);
|
|
318
|
-
}
|
|
319
|
-
case ZodFirstPartyTypeKind.ZodNullable: {
|
|
320
|
-
if (value === null) {
|
|
321
|
-
return null;
|
|
322
|
-
}
|
|
323
|
-
const schema_ = schema;
|
|
324
|
-
return zodCoerceInternal(schema_._def.innerType, value);
|
|
325
|
-
}
|
|
326
|
-
case ZodFirstPartyTypeKind.ZodOptional: {
|
|
327
|
-
if (value === void 0) {
|
|
328
|
-
return void 0;
|
|
329
|
-
}
|
|
330
|
-
const schema_ = schema;
|
|
331
|
-
return zodCoerceInternal(schema_._def.innerType, value);
|
|
1134
|
+
payload.value = output;
|
|
1135
|
+
return payload;
|
|
1136
|
+
};
|
|
1137
|
+
}
|
|
1138
|
+
);
|
|
1139
|
+
function transform(fn) {
|
|
1140
|
+
return new ZodTransform({
|
|
1141
|
+
type: "transform",
|
|
1142
|
+
transform: fn
|
|
1143
|
+
});
|
|
1144
|
+
}
|
|
1145
|
+
const ZodOptional = /* @__PURE__ */ core.$constructor(
|
|
1146
|
+
"ZodOptional",
|
|
1147
|
+
(inst, def) => {
|
|
1148
|
+
const coreInit = core.$ZodOptional.init;
|
|
1149
|
+
coreInit(inst, def);
|
|
1150
|
+
KrustyType.init(inst, def);
|
|
1151
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
1152
|
+
}
|
|
1153
|
+
);
|
|
1154
|
+
function optional(innerType) {
|
|
1155
|
+
return new ZodOptional({
|
|
1156
|
+
type: "optional",
|
|
1157
|
+
innerType
|
|
1158
|
+
});
|
|
1159
|
+
}
|
|
1160
|
+
const ZodNullable = /* @__PURE__ */ core.$constructor(
|
|
1161
|
+
"ZodNullable",
|
|
1162
|
+
(inst, def) => {
|
|
1163
|
+
const coreInit = core.$ZodNullable.init;
|
|
1164
|
+
coreInit(inst, def);
|
|
1165
|
+
KrustyType.init(inst, def);
|
|
1166
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
1167
|
+
}
|
|
1168
|
+
);
|
|
1169
|
+
function nullable(innerType) {
|
|
1170
|
+
return new ZodNullable({
|
|
1171
|
+
type: "nullable",
|
|
1172
|
+
innerType
|
|
1173
|
+
});
|
|
1174
|
+
}
|
|
1175
|
+
function nullish(innerType) {
|
|
1176
|
+
return optional(nullable(innerType));
|
|
1177
|
+
}
|
|
1178
|
+
const ZodDefault = /* @__PURE__ */ core.$constructor(
|
|
1179
|
+
"ZodDefault",
|
|
1180
|
+
(inst, def) => {
|
|
1181
|
+
const coreInit = core.$ZodDefault.init;
|
|
1182
|
+
coreInit(inst, def);
|
|
1183
|
+
KrustyType.init(inst, def);
|
|
1184
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
1185
|
+
inst.removeDefault = inst.unwrap;
|
|
1186
|
+
}
|
|
1187
|
+
);
|
|
1188
|
+
function _default(innerType, defaultValue) {
|
|
1189
|
+
return new ZodDefault({
|
|
1190
|
+
type: "default",
|
|
1191
|
+
innerType,
|
|
1192
|
+
get defaultValue() {
|
|
1193
|
+
return typeof defaultValue === "function" ? defaultValue() : util.shallowClone(defaultValue);
|
|
332
1194
|
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
1195
|
+
});
|
|
1196
|
+
}
|
|
1197
|
+
const ZodPrefault = /* @__PURE__ */ core.$constructor(
|
|
1198
|
+
"ZodPrefault",
|
|
1199
|
+
(inst, def) => {
|
|
1200
|
+
const coreInit = core.$ZodPrefault.init;
|
|
1201
|
+
coreInit(inst, def);
|
|
1202
|
+
KrustyType.init(inst, def);
|
|
1203
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
1204
|
+
}
|
|
1205
|
+
);
|
|
1206
|
+
function prefault(innerType, defaultValue) {
|
|
1207
|
+
return new ZodPrefault({
|
|
1208
|
+
type: "prefault",
|
|
1209
|
+
innerType,
|
|
1210
|
+
get defaultValue() {
|
|
1211
|
+
return typeof defaultValue === "function" ? defaultValue() : util.shallowClone(defaultValue);
|
|
339
1212
|
}
|
|
1213
|
+
});
|
|
1214
|
+
}
|
|
1215
|
+
const ZodNonOptional = /* @__PURE__ */ core.$constructor(
|
|
1216
|
+
"ZodNonOptional",
|
|
1217
|
+
(inst, def) => {
|
|
1218
|
+
const coreInit = core.$ZodNonOptional.init;
|
|
1219
|
+
coreInit(inst, def);
|
|
1220
|
+
KrustyType.init(inst, def);
|
|
1221
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
340
1222
|
}
|
|
341
|
-
|
|
1223
|
+
);
|
|
1224
|
+
function nonoptional(innerType, params) {
|
|
1225
|
+
return new ZodNonOptional({
|
|
1226
|
+
type: "nonoptional",
|
|
1227
|
+
innerType,
|
|
1228
|
+
...util.normalizeParams(params)
|
|
1229
|
+
});
|
|
342
1230
|
}
|
|
343
|
-
|
|
344
|
-
|
|
1231
|
+
const ZodSuccess = /* @__PURE__ */ core.$constructor(
|
|
1232
|
+
"ZodSuccess",
|
|
1233
|
+
(inst, def) => {
|
|
1234
|
+
const coreInit = core.$ZodSuccess.init;
|
|
1235
|
+
coreInit(inst, def);
|
|
1236
|
+
KrustyType.init(inst, def);
|
|
1237
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
1238
|
+
}
|
|
1239
|
+
);
|
|
1240
|
+
function success(innerType) {
|
|
1241
|
+
return new ZodSuccess({
|
|
1242
|
+
type: "success",
|
|
1243
|
+
innerType
|
|
1244
|
+
});
|
|
345
1245
|
}
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
1246
|
+
const ZodCatch = /* @__PURE__ */ core.$constructor(
|
|
1247
|
+
"ZodCatch",
|
|
1248
|
+
(inst, def) => {
|
|
1249
|
+
const coreInit = core.$ZodCatch.init;
|
|
1250
|
+
coreInit(inst, def);
|
|
1251
|
+
KrustyType.init(inst, def);
|
|
1252
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
1253
|
+
inst.removeCatch = inst.unwrap;
|
|
1254
|
+
}
|
|
1255
|
+
);
|
|
1256
|
+
function _catch(innerType, catchValue) {
|
|
1257
|
+
return new ZodCatch({
|
|
1258
|
+
type: "catch",
|
|
1259
|
+
innerType,
|
|
1260
|
+
catchValue: typeof catchValue === "function" ? catchValue : () => catchValue
|
|
1261
|
+
});
|
|
1262
|
+
}
|
|
1263
|
+
const ZodNaN = /* @__PURE__ */ core.$constructor("ZodNaN", (inst, def) => {
|
|
1264
|
+
const coreInit = core.$ZodNaN.init;
|
|
1265
|
+
coreInit(inst, def);
|
|
1266
|
+
KrustyType.init(inst, def);
|
|
1267
|
+
});
|
|
1268
|
+
function nan(params) {
|
|
1269
|
+
return core._nan(ZodNaN, params);
|
|
349
1270
|
}
|
|
350
|
-
|
|
351
|
-
const
|
|
352
|
-
|
|
353
|
-
|
|
1271
|
+
const ZodPipe = /* @__PURE__ */ core.$constructor("ZodPipe", (inst, def) => {
|
|
1272
|
+
const coreInit = core.$ZodPipe.init;
|
|
1273
|
+
coreInit(inst, def);
|
|
1274
|
+
KrustyType.init(inst, def);
|
|
1275
|
+
inst.in = def.in;
|
|
1276
|
+
inst.out = def.out;
|
|
1277
|
+
});
|
|
1278
|
+
function pipe(in_, out) {
|
|
1279
|
+
return new ZodPipe({
|
|
1280
|
+
type: "pipe",
|
|
1281
|
+
in: in_,
|
|
1282
|
+
out
|
|
1283
|
+
// ...util.normalizeParams(params),
|
|
1284
|
+
});
|
|
1285
|
+
}
|
|
1286
|
+
const ZodCodec = /* @__PURE__ */ core.$constructor(
|
|
1287
|
+
"ZodCodec",
|
|
1288
|
+
(inst, def) => {
|
|
1289
|
+
ZodPipe.init(inst, def);
|
|
1290
|
+
const coreInit = core.$ZodCodec.init;
|
|
1291
|
+
coreInit(inst, def);
|
|
354
1292
|
}
|
|
355
|
-
|
|
356
|
-
|
|
1293
|
+
);
|
|
1294
|
+
function codec(in_, out, params) {
|
|
1295
|
+
return new ZodCodec({
|
|
1296
|
+
type: "pipe",
|
|
1297
|
+
in: in_,
|
|
1298
|
+
out,
|
|
1299
|
+
transform: params.decode,
|
|
1300
|
+
reverseTransform: params.encode
|
|
1301
|
+
});
|
|
1302
|
+
}
|
|
1303
|
+
const ZodReadonly = /* @__PURE__ */ core.$constructor(
|
|
1304
|
+
"ZodReadonly",
|
|
1305
|
+
(inst, def) => {
|
|
1306
|
+
const coreInit = core.$ZodReadonly.init;
|
|
1307
|
+
coreInit(inst, def);
|
|
1308
|
+
KrustyType.init(inst, def);
|
|
1309
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
357
1310
|
}
|
|
358
|
-
|
|
1311
|
+
);
|
|
1312
|
+
function readonly(innerType) {
|
|
1313
|
+
return new ZodReadonly({
|
|
1314
|
+
type: "readonly",
|
|
1315
|
+
innerType
|
|
1316
|
+
});
|
|
359
1317
|
}
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
1318
|
+
const ZodTemplateLiteral = /* @__PURE__ */ core.$constructor(
|
|
1319
|
+
"ZodTemplateLiteral",
|
|
1320
|
+
(inst, def) => {
|
|
1321
|
+
const coreInit = core.$ZodTemplateLiteral.init;
|
|
1322
|
+
coreInit(inst, def);
|
|
1323
|
+
KrustyType.init(inst, def);
|
|
1324
|
+
}
|
|
1325
|
+
);
|
|
1326
|
+
function templateLiteral(parts, params) {
|
|
1327
|
+
return new ZodTemplateLiteral({
|
|
1328
|
+
type: "template_literal",
|
|
1329
|
+
parts,
|
|
1330
|
+
...util.normalizeParams(params)
|
|
1331
|
+
});
|
|
1332
|
+
}
|
|
1333
|
+
const ZodLazy = /* @__PURE__ */ core.$constructor("ZodLazy", (inst, def) => {
|
|
1334
|
+
const coreInit = core.$ZodLazy.init;
|
|
1335
|
+
coreInit(inst, def);
|
|
1336
|
+
KrustyType.init(inst, def);
|
|
1337
|
+
inst.unwrap = () => inst._zod.def.getter();
|
|
1338
|
+
});
|
|
1339
|
+
function lazy(getter) {
|
|
1340
|
+
return new ZodLazy({
|
|
1341
|
+
type: "lazy",
|
|
1342
|
+
getter
|
|
1343
|
+
});
|
|
1344
|
+
}
|
|
1345
|
+
const ZodPromise = /* @__PURE__ */ core.$constructor(
|
|
1346
|
+
"ZodPromise",
|
|
1347
|
+
(inst, def) => {
|
|
1348
|
+
const coreInit = core.$ZodPromise.init;
|
|
1349
|
+
coreInit(inst, def);
|
|
1350
|
+
KrustyType.init(inst, def);
|
|
1351
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
367
1352
|
}
|
|
368
|
-
|
|
1353
|
+
);
|
|
1354
|
+
function promise(innerType) {
|
|
1355
|
+
return new ZodPromise({
|
|
1356
|
+
type: "promise",
|
|
1357
|
+
innerType
|
|
1358
|
+
});
|
|
369
1359
|
}
|
|
370
|
-
|
|
371
|
-
|
|
1360
|
+
const ZodFunction = /* @__PURE__ */ core.$constructor(
|
|
1361
|
+
"ZodFunction",
|
|
1362
|
+
(inst, def) => {
|
|
1363
|
+
const coreInit = core.$ZodFunction.init;
|
|
1364
|
+
coreInit(inst, def);
|
|
1365
|
+
KrustyType.init(inst, def);
|
|
1366
|
+
}
|
|
1367
|
+
);
|
|
1368
|
+
function _function(params) {
|
|
1369
|
+
return new ZodFunction({
|
|
1370
|
+
type: "function",
|
|
1371
|
+
input: Array.isArray(params?.input) ? tuple(params?.input) : params?.input ?? array(unknown()),
|
|
1372
|
+
output: params?.output ?? unknown()
|
|
1373
|
+
});
|
|
372
1374
|
}
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
1375
|
+
const ZodCustom = /* @__PURE__ */ core.$constructor(
|
|
1376
|
+
"ZodCustom",
|
|
1377
|
+
(inst, def) => {
|
|
1378
|
+
const coreInit = core.$ZodCustom.init;
|
|
1379
|
+
coreInit(inst, def);
|
|
1380
|
+
KrustyType.init(inst, def);
|
|
377
1381
|
}
|
|
378
|
-
|
|
1382
|
+
);
|
|
1383
|
+
function check(fn) {
|
|
1384
|
+
const ch = new core.$ZodCheck({
|
|
1385
|
+
check: "custom"
|
|
1386
|
+
// ...util.normalizeParams(params),
|
|
1387
|
+
});
|
|
1388
|
+
ch._zod.check = fn;
|
|
1389
|
+
return ch;
|
|
1390
|
+
}
|
|
1391
|
+
function custom(fn, _params) {
|
|
1392
|
+
return core._custom(ZodCustom, fn ?? (() => true), _params);
|
|
1393
|
+
}
|
|
1394
|
+
function refine(fn, _params = {}) {
|
|
1395
|
+
return core._refine(ZodCustom, fn, _params);
|
|
1396
|
+
}
|
|
1397
|
+
function superRefine(fn) {
|
|
1398
|
+
return core._superRefine(fn);
|
|
1399
|
+
}
|
|
1400
|
+
function _instanceof(cls, params = {
|
|
1401
|
+
error: `Input not instance of ${cls.name}`
|
|
1402
|
+
}) {
|
|
1403
|
+
const inst = new ZodCustom({
|
|
1404
|
+
type: "custom",
|
|
1405
|
+
check: "custom",
|
|
1406
|
+
fn: (data) => data instanceof cls,
|
|
1407
|
+
abort: true,
|
|
1408
|
+
...util.normalizeParams(params)
|
|
1409
|
+
});
|
|
1410
|
+
inst._zod.bag.Class = cls;
|
|
1411
|
+
return inst;
|
|
1412
|
+
}
|
|
1413
|
+
const stringbool = (...args) => core._stringbool(
|
|
1414
|
+
{
|
|
1415
|
+
Codec: ZodCodec,
|
|
1416
|
+
Boolean: ZodBoolean,
|
|
1417
|
+
String: ZodString
|
|
1418
|
+
},
|
|
1419
|
+
...args
|
|
1420
|
+
);
|
|
1421
|
+
function json(params) {
|
|
1422
|
+
const jsonSchema = lazy(() => {
|
|
1423
|
+
return union([
|
|
1424
|
+
string(params),
|
|
1425
|
+
number(),
|
|
1426
|
+
boolean(),
|
|
1427
|
+
_null(),
|
|
1428
|
+
array(jsonSchema),
|
|
1429
|
+
record(string(), jsonSchema)
|
|
1430
|
+
]);
|
|
1431
|
+
});
|
|
1432
|
+
return jsonSchema;
|
|
1433
|
+
}
|
|
1434
|
+
function preprocess(fn, schema) {
|
|
1435
|
+
return pipe(transform(fn), schema);
|
|
379
1436
|
}
|
|
380
1437
|
|
|
381
|
-
class
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
unsupportedJsonSchema;
|
|
385
|
-
anyJsonSchema;
|
|
386
|
-
constructor(options = {}) {
|
|
387
|
-
this.maxLazyDepth = options.maxLazyDepth ?? 3;
|
|
388
|
-
this.maxStructureDepth = options.maxStructureDepth ?? 10;
|
|
389
|
-
this.unsupportedJsonSchema = options.unsupportedJsonSchema ?? { not: {} };
|
|
390
|
-
this.anyJsonSchema = options.anyJsonSchema ?? {};
|
|
391
|
-
}
|
|
392
|
-
condition(schema) {
|
|
393
|
-
return schema !== void 0 && schema["~standard"].vendor === "zod" && !("_zod" in schema);
|
|
394
|
-
}
|
|
395
|
-
convert(schema, options, lazyDepth = 0, isHandledCustomJSONSchema = false, isHandledZodDescription = false, structureDepth = 0) {
|
|
396
|
-
const def = schema._def;
|
|
397
|
-
if (structureDepth > this.maxStructureDepth) {
|
|
398
|
-
return [false, this.anyJsonSchema];
|
|
399
|
-
}
|
|
400
|
-
if (!options.minStructureDepthForRef || options.minStructureDepthForRef <= structureDepth) {
|
|
401
|
-
const components = toArray(options.components);
|
|
402
|
-
for (const component of components) {
|
|
403
|
-
if (component.schema === schema && component.allowedStrategies.includes(options.strategy)) {
|
|
404
|
-
return [component.required, { $ref: component.ref }];
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
if (!isHandledZodDescription && "description" in def && typeof def.description === "string") {
|
|
409
|
-
const [required, json] = this.convert(
|
|
410
|
-
schema,
|
|
411
|
-
options,
|
|
412
|
-
lazyDepth,
|
|
413
|
-
isHandledCustomJSONSchema,
|
|
414
|
-
true,
|
|
415
|
-
structureDepth
|
|
416
|
-
);
|
|
417
|
-
return [required, { ...json, description: def.description }];
|
|
418
|
-
}
|
|
419
|
-
if (!isHandledCustomJSONSchema) {
|
|
420
|
-
const customJSONSchema = getCustomJsonSchema(def, options);
|
|
421
|
-
if (customJSONSchema) {
|
|
422
|
-
const [required, json] = this.convert(
|
|
423
|
-
schema,
|
|
424
|
-
options,
|
|
425
|
-
lazyDepth,
|
|
426
|
-
true,
|
|
427
|
-
isHandledZodDescription,
|
|
428
|
-
structureDepth
|
|
429
|
-
);
|
|
430
|
-
return [required, { ...json, ...customJSONSchema }];
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
const customSchema = this.#handleCustomZodDef(def);
|
|
434
|
-
if (customSchema) {
|
|
435
|
-
return [true, customSchema];
|
|
436
|
-
}
|
|
437
|
-
const typeName = this.#getZodTypeName(def);
|
|
438
|
-
switch (typeName) {
|
|
439
|
-
case ZodFirstPartyTypeKind.ZodString: {
|
|
440
|
-
const schema_ = schema;
|
|
441
|
-
const json = { type: "string" };
|
|
442
|
-
for (const check of schema_._def.checks) {
|
|
443
|
-
switch (check.kind) {
|
|
444
|
-
case "base64":
|
|
445
|
-
json.contentEncoding = "base64";
|
|
446
|
-
break;
|
|
447
|
-
case "cuid":
|
|
448
|
-
json.pattern = "^[0-9A-HJKMNP-TV-Z]{26}$";
|
|
449
|
-
break;
|
|
450
|
-
case "email":
|
|
451
|
-
json.format = JSONSchemaFormat.Email;
|
|
452
|
-
break;
|
|
453
|
-
case "url":
|
|
454
|
-
json.format = JSONSchemaFormat.URI;
|
|
455
|
-
break;
|
|
456
|
-
case "uuid":
|
|
457
|
-
json.format = JSONSchemaFormat.UUID;
|
|
458
|
-
break;
|
|
459
|
-
case "regex":
|
|
460
|
-
json.pattern = check.regex.source;
|
|
461
|
-
break;
|
|
462
|
-
case "min":
|
|
463
|
-
json.minLength = check.value;
|
|
464
|
-
break;
|
|
465
|
-
case "max":
|
|
466
|
-
json.maxLength = check.value;
|
|
467
|
-
break;
|
|
468
|
-
case "length":
|
|
469
|
-
json.minLength = check.value;
|
|
470
|
-
json.maxLength = check.value;
|
|
471
|
-
break;
|
|
472
|
-
case "includes":
|
|
473
|
-
json.pattern = escapeStringRegexp(check.value);
|
|
474
|
-
break;
|
|
475
|
-
case "startsWith":
|
|
476
|
-
json.pattern = `^${escapeStringRegexp(check.value)}`;
|
|
477
|
-
break;
|
|
478
|
-
case "endsWith":
|
|
479
|
-
json.pattern = `${escapeStringRegexp(check.value)}$`;
|
|
480
|
-
break;
|
|
481
|
-
case "emoji":
|
|
482
|
-
json.pattern = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
|
|
483
|
-
break;
|
|
484
|
-
case "nanoid":
|
|
485
|
-
json.pattern = "^[a-zA-Z0-9_-]{21}$";
|
|
486
|
-
break;
|
|
487
|
-
case "cuid2":
|
|
488
|
-
json.pattern = "^[0-9a-z]+$";
|
|
489
|
-
break;
|
|
490
|
-
case "ulid":
|
|
491
|
-
json.pattern = "^[0-9A-HJKMNP-TV-Z]{26}$";
|
|
492
|
-
break;
|
|
493
|
-
case "datetime":
|
|
494
|
-
json.format = JSONSchemaFormat.DateTime;
|
|
495
|
-
break;
|
|
496
|
-
case "date":
|
|
497
|
-
json.format = JSONSchemaFormat.Date;
|
|
498
|
-
break;
|
|
499
|
-
case "time":
|
|
500
|
-
json.format = JSONSchemaFormat.Time;
|
|
501
|
-
break;
|
|
502
|
-
case "duration":
|
|
503
|
-
json.format = JSONSchemaFormat.Duration;
|
|
504
|
-
break;
|
|
505
|
-
case "ip": {
|
|
506
|
-
if (check.version === "v4") {
|
|
507
|
-
json.format = JSONSchemaFormat.IPv4;
|
|
508
|
-
} else if (check.version === "v6") {
|
|
509
|
-
json.format = JSONSchemaFormat.IPv6;
|
|
510
|
-
} else {
|
|
511
|
-
json.anyOf = [{ format: JSONSchemaFormat.IPv4 }, { format: JSONSchemaFormat.IPv6 }];
|
|
512
|
-
}
|
|
513
|
-
break;
|
|
514
|
-
}
|
|
515
|
-
case "jwt":
|
|
516
|
-
json.pattern = "^[A-Za-z0-9-_]+\\.[A-Za-z0-9-_]+\\.[A-Za-z0-9-_]*$";
|
|
517
|
-
break;
|
|
518
|
-
case "base64url":
|
|
519
|
-
json.pattern = "^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$";
|
|
520
|
-
break;
|
|
521
|
-
default: {
|
|
522
|
-
check.kind;
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
return [true, json];
|
|
527
|
-
}
|
|
528
|
-
case ZodFirstPartyTypeKind.ZodNumber: {
|
|
529
|
-
const schema_ = schema;
|
|
530
|
-
const json = { type: "number" };
|
|
531
|
-
for (const check of schema_._def.checks) {
|
|
532
|
-
switch (check.kind) {
|
|
533
|
-
case "int":
|
|
534
|
-
json.type = "integer";
|
|
535
|
-
break;
|
|
536
|
-
case "min":
|
|
537
|
-
json.minimum = check.value;
|
|
538
|
-
break;
|
|
539
|
-
case "max":
|
|
540
|
-
json.maximum = check.value;
|
|
541
|
-
break;
|
|
542
|
-
case "multipleOf":
|
|
543
|
-
json.multipleOf = check.value;
|
|
544
|
-
break;
|
|
545
|
-
default: {
|
|
546
|
-
check.kind;
|
|
547
|
-
}
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
return [true, json];
|
|
551
|
-
}
|
|
552
|
-
case ZodFirstPartyTypeKind.ZodBigInt: {
|
|
553
|
-
const json = {
|
|
554
|
-
type: "string",
|
|
555
|
-
pattern: "^-?[0-9]+$",
|
|
556
|
-
"x-native-type": JsonSchemaXNativeType.BigInt
|
|
557
|
-
};
|
|
558
|
-
return [true, json];
|
|
559
|
-
}
|
|
560
|
-
case ZodFirstPartyTypeKind.ZodNaN: {
|
|
561
|
-
return options.strategy === "input" ? [true, this.unsupportedJsonSchema] : [true, { type: "null" }];
|
|
562
|
-
}
|
|
563
|
-
case ZodFirstPartyTypeKind.ZodBoolean: {
|
|
564
|
-
return [true, { type: "boolean" }];
|
|
565
|
-
}
|
|
566
|
-
case ZodFirstPartyTypeKind.ZodDate: {
|
|
567
|
-
const schema2 = {
|
|
568
|
-
type: "string",
|
|
569
|
-
format: JSONSchemaFormat.DateTime,
|
|
570
|
-
"x-native-type": JsonSchemaXNativeType.Date
|
|
571
|
-
};
|
|
572
|
-
return [true, schema2];
|
|
573
|
-
}
|
|
574
|
-
case ZodFirstPartyTypeKind.ZodNull: {
|
|
575
|
-
return [true, { type: "null" }];
|
|
576
|
-
}
|
|
577
|
-
case ZodFirstPartyTypeKind.ZodLiteral: {
|
|
578
|
-
const schema_ = schema;
|
|
579
|
-
if (schema_._def.value === void 0) {
|
|
580
|
-
return [false, this.unsupportedJsonSchema];
|
|
581
|
-
}
|
|
582
|
-
return [true, { const: schema_._def.value }];
|
|
583
|
-
}
|
|
584
|
-
case ZodFirstPartyTypeKind.ZodVoid:
|
|
585
|
-
case ZodFirstPartyTypeKind.ZodUndefined: {
|
|
586
|
-
return [false, this.unsupportedJsonSchema];
|
|
587
|
-
}
|
|
588
|
-
case ZodFirstPartyTypeKind.ZodUnknown:
|
|
589
|
-
case ZodFirstPartyTypeKind.ZodAny: {
|
|
590
|
-
return [false, this.anyJsonSchema];
|
|
591
|
-
}
|
|
592
|
-
case ZodFirstPartyTypeKind.ZodEnum: {
|
|
593
|
-
const schema_ = schema;
|
|
594
|
-
return [true, { enum: schema_._def.values }];
|
|
595
|
-
}
|
|
596
|
-
case ZodFirstPartyTypeKind.ZodNativeEnum: {
|
|
597
|
-
const schema_ = schema;
|
|
598
|
-
return [true, { enum: Object.values(schema_._def.values) }];
|
|
599
|
-
}
|
|
600
|
-
case ZodFirstPartyTypeKind.ZodArray: {
|
|
601
|
-
const schema_ = schema;
|
|
602
|
-
const def2 = schema_._def;
|
|
603
|
-
const json = { type: "array" };
|
|
604
|
-
const [itemRequired, itemJson] = this.convert(
|
|
605
|
-
def2.type,
|
|
606
|
-
options,
|
|
607
|
-
lazyDepth,
|
|
608
|
-
false,
|
|
609
|
-
false,
|
|
610
|
-
structureDepth + 1
|
|
611
|
-
);
|
|
612
|
-
json.items = this.#toArrayItemJsonSchema(itemRequired, itemJson, options.strategy);
|
|
613
|
-
if (def2.exactLength) {
|
|
614
|
-
json.maxItems = def2.exactLength.value;
|
|
615
|
-
json.minItems = def2.exactLength.value;
|
|
616
|
-
}
|
|
617
|
-
if (def2.minLength) {
|
|
618
|
-
json.minItems = def2.minLength.value;
|
|
619
|
-
}
|
|
620
|
-
if (def2.maxLength) {
|
|
621
|
-
json.maxItems = def2.maxLength.value;
|
|
622
|
-
}
|
|
623
|
-
return [true, json];
|
|
624
|
-
}
|
|
625
|
-
case ZodFirstPartyTypeKind.ZodTuple: {
|
|
626
|
-
const schema_ = schema;
|
|
627
|
-
const prefixItems = [];
|
|
628
|
-
const json = { type: "array" };
|
|
629
|
-
for (const item of schema_._def.items) {
|
|
630
|
-
const [itemRequired, itemJson] = this.convert(
|
|
631
|
-
item,
|
|
632
|
-
options,
|
|
633
|
-
lazyDepth,
|
|
634
|
-
false,
|
|
635
|
-
false,
|
|
636
|
-
structureDepth + 1
|
|
637
|
-
);
|
|
638
|
-
prefixItems.push(this.#toArrayItemJsonSchema(itemRequired, itemJson, options.strategy));
|
|
639
|
-
}
|
|
640
|
-
if (prefixItems?.length) {
|
|
641
|
-
json.prefixItems = prefixItems;
|
|
642
|
-
}
|
|
643
|
-
if (schema_._def.rest) {
|
|
644
|
-
const [itemRequired, itemJson] = this.convert(
|
|
645
|
-
schema_._def.rest,
|
|
646
|
-
options,
|
|
647
|
-
lazyDepth,
|
|
648
|
-
false,
|
|
649
|
-
false,
|
|
650
|
-
structureDepth + 1
|
|
651
|
-
);
|
|
652
|
-
json.items = this.#toArrayItemJsonSchema(itemRequired, itemJson, options.strategy);
|
|
653
|
-
}
|
|
654
|
-
return [true, json];
|
|
655
|
-
}
|
|
656
|
-
case ZodFirstPartyTypeKind.ZodObject: {
|
|
657
|
-
const schema_ = schema;
|
|
658
|
-
const json = { type: "object" };
|
|
659
|
-
const properties = {};
|
|
660
|
-
const required = [];
|
|
661
|
-
for (const [key, value] of Object.entries(schema_.shape)) {
|
|
662
|
-
const [itemRequired, itemJson] = this.convert(
|
|
663
|
-
value,
|
|
664
|
-
options,
|
|
665
|
-
lazyDepth,
|
|
666
|
-
false,
|
|
667
|
-
false,
|
|
668
|
-
structureDepth + 1
|
|
669
|
-
);
|
|
670
|
-
properties[key] = itemJson;
|
|
671
|
-
if (itemRequired) {
|
|
672
|
-
required.push(key);
|
|
673
|
-
}
|
|
674
|
-
}
|
|
675
|
-
if (Object.keys(properties).length) {
|
|
676
|
-
json.properties = properties;
|
|
677
|
-
}
|
|
678
|
-
if (required.length) {
|
|
679
|
-
json.required = required;
|
|
680
|
-
}
|
|
681
|
-
const catchAllTypeName = this.#getZodTypeName(schema_._def.catchall._def);
|
|
682
|
-
if (catchAllTypeName === ZodFirstPartyTypeKind.ZodNever) {
|
|
683
|
-
if (schema_._def.unknownKeys === "strict") {
|
|
684
|
-
json.additionalProperties = false;
|
|
685
|
-
}
|
|
686
|
-
} else {
|
|
687
|
-
const [_, addJson] = this.convert(
|
|
688
|
-
schema_._def.catchall,
|
|
689
|
-
options,
|
|
690
|
-
lazyDepth,
|
|
691
|
-
false,
|
|
692
|
-
false,
|
|
693
|
-
structureDepth + 1
|
|
694
|
-
);
|
|
695
|
-
json.additionalProperties = addJson;
|
|
696
|
-
}
|
|
697
|
-
return [true, json];
|
|
698
|
-
}
|
|
699
|
-
case ZodFirstPartyTypeKind.ZodRecord: {
|
|
700
|
-
const schema_ = schema;
|
|
701
|
-
const json = { type: "object" };
|
|
702
|
-
const [__, keyJson] = this.convert(
|
|
703
|
-
schema_._def.keyType,
|
|
704
|
-
options,
|
|
705
|
-
lazyDepth,
|
|
706
|
-
false,
|
|
707
|
-
false,
|
|
708
|
-
structureDepth + 1
|
|
709
|
-
);
|
|
710
|
-
if (Object.entries(keyJson).some(([k, v]) => k !== "type" || v !== "string")) {
|
|
711
|
-
json.propertyNames = keyJson;
|
|
712
|
-
}
|
|
713
|
-
const [_, itemJson] = this.convert(
|
|
714
|
-
schema_._def.valueType,
|
|
715
|
-
options,
|
|
716
|
-
lazyDepth,
|
|
717
|
-
false,
|
|
718
|
-
false,
|
|
719
|
-
structureDepth + 1
|
|
720
|
-
);
|
|
721
|
-
json.additionalProperties = itemJson;
|
|
722
|
-
return [true, json];
|
|
723
|
-
}
|
|
724
|
-
case ZodFirstPartyTypeKind.ZodSet: {
|
|
725
|
-
const schema_ = schema;
|
|
726
|
-
const json = {
|
|
727
|
-
type: "array",
|
|
728
|
-
uniqueItems: true,
|
|
729
|
-
"x-native-type": JsonSchemaXNativeType.Set
|
|
730
|
-
};
|
|
731
|
-
const [itemRequired, itemJson] = this.convert(
|
|
732
|
-
schema_._def.valueType,
|
|
733
|
-
options,
|
|
734
|
-
lazyDepth,
|
|
735
|
-
false,
|
|
736
|
-
false,
|
|
737
|
-
structureDepth + 1
|
|
738
|
-
);
|
|
739
|
-
json.items = this.#toArrayItemJsonSchema(itemRequired, itemJson, options.strategy);
|
|
740
|
-
return [true, json];
|
|
741
|
-
}
|
|
742
|
-
case ZodFirstPartyTypeKind.ZodMap: {
|
|
743
|
-
const schema_ = schema;
|
|
744
|
-
const [keyRequired, keyJson] = this.convert(
|
|
745
|
-
schema_._def.keyType,
|
|
746
|
-
options,
|
|
747
|
-
lazyDepth,
|
|
748
|
-
false,
|
|
749
|
-
false,
|
|
750
|
-
structureDepth + 1
|
|
751
|
-
);
|
|
752
|
-
const [valueRequired, valueJson] = this.convert(
|
|
753
|
-
schema_._def.valueType,
|
|
754
|
-
options,
|
|
755
|
-
lazyDepth,
|
|
756
|
-
false,
|
|
757
|
-
false,
|
|
758
|
-
structureDepth + 1
|
|
759
|
-
);
|
|
760
|
-
const json = {
|
|
761
|
-
type: "array",
|
|
762
|
-
items: {
|
|
763
|
-
type: "array",
|
|
764
|
-
prefixItems: [
|
|
765
|
-
this.#toArrayItemJsonSchema(keyRequired, keyJson, options.strategy),
|
|
766
|
-
this.#toArrayItemJsonSchema(valueRequired, valueJson, options.strategy)
|
|
767
|
-
],
|
|
768
|
-
maxItems: 2,
|
|
769
|
-
minItems: 2
|
|
770
|
-
},
|
|
771
|
-
"x-native-type": JsonSchemaXNativeType.Map
|
|
772
|
-
};
|
|
773
|
-
return [true, json];
|
|
774
|
-
}
|
|
775
|
-
case ZodFirstPartyTypeKind.ZodUnion:
|
|
776
|
-
case ZodFirstPartyTypeKind.ZodDiscriminatedUnion: {
|
|
777
|
-
const schema_ = schema;
|
|
778
|
-
const anyOf = [];
|
|
779
|
-
let required = true;
|
|
780
|
-
for (const item of schema_._def.options) {
|
|
781
|
-
const [itemRequired, itemJson] = this.convert(
|
|
782
|
-
item,
|
|
783
|
-
options,
|
|
784
|
-
lazyDepth,
|
|
785
|
-
false,
|
|
786
|
-
false,
|
|
787
|
-
structureDepth
|
|
788
|
-
);
|
|
789
|
-
if (!itemRequired) {
|
|
790
|
-
required = false;
|
|
791
|
-
if (itemJson !== this.unsupportedJsonSchema) {
|
|
792
|
-
anyOf.push(itemJson);
|
|
793
|
-
}
|
|
794
|
-
} else {
|
|
795
|
-
anyOf.push(itemJson);
|
|
796
|
-
}
|
|
797
|
-
}
|
|
798
|
-
if (anyOf.length === 1) {
|
|
799
|
-
return [required, anyOf[0]];
|
|
800
|
-
}
|
|
801
|
-
return [required, { anyOf }];
|
|
802
|
-
}
|
|
803
|
-
case ZodFirstPartyTypeKind.ZodIntersection: {
|
|
804
|
-
const schema_ = schema;
|
|
805
|
-
const allOf = [];
|
|
806
|
-
let required = false;
|
|
807
|
-
for (const item of [schema_._def.left, schema_._def.right]) {
|
|
808
|
-
const [itemRequired, itemJson] = this.convert(
|
|
809
|
-
item,
|
|
810
|
-
options,
|
|
811
|
-
lazyDepth,
|
|
812
|
-
false,
|
|
813
|
-
false,
|
|
814
|
-
structureDepth
|
|
815
|
-
);
|
|
816
|
-
allOf.push(itemJson);
|
|
817
|
-
if (itemRequired) {
|
|
818
|
-
required = true;
|
|
819
|
-
}
|
|
820
|
-
}
|
|
821
|
-
return [required, { allOf }];
|
|
822
|
-
}
|
|
823
|
-
case ZodFirstPartyTypeKind.ZodLazy: {
|
|
824
|
-
const currentLazyDepth = lazyDepth + 1;
|
|
825
|
-
if (currentLazyDepth > this.maxLazyDepth) {
|
|
826
|
-
return [false, this.anyJsonSchema];
|
|
827
|
-
}
|
|
828
|
-
const schema_ = schema;
|
|
829
|
-
return this.convert(schema_._def.getter(), options, currentLazyDepth, false, false, structureDepth);
|
|
830
|
-
}
|
|
831
|
-
case ZodFirstPartyTypeKind.ZodOptional: {
|
|
832
|
-
const schema_ = schema;
|
|
833
|
-
const [_, inner] = this.convert(
|
|
834
|
-
schema_._def.innerType,
|
|
835
|
-
options,
|
|
836
|
-
lazyDepth,
|
|
837
|
-
false,
|
|
838
|
-
false,
|
|
839
|
-
structureDepth
|
|
840
|
-
);
|
|
841
|
-
return [false, inner];
|
|
842
|
-
}
|
|
843
|
-
case ZodFirstPartyTypeKind.ZodReadonly: {
|
|
844
|
-
const schema_ = schema;
|
|
845
|
-
const [required, json] = this.convert(
|
|
846
|
-
schema_._def.innerType,
|
|
847
|
-
options,
|
|
848
|
-
lazyDepth,
|
|
849
|
-
false,
|
|
850
|
-
false,
|
|
851
|
-
structureDepth
|
|
852
|
-
);
|
|
853
|
-
return [required, { ...json, readOnly: true }];
|
|
854
|
-
}
|
|
855
|
-
case ZodFirstPartyTypeKind.ZodDefault: {
|
|
856
|
-
const schema_ = schema;
|
|
857
|
-
const [_, json] = this.convert(
|
|
858
|
-
schema_._def.innerType,
|
|
859
|
-
options,
|
|
860
|
-
lazyDepth,
|
|
861
|
-
false,
|
|
862
|
-
false,
|
|
863
|
-
structureDepth
|
|
864
|
-
);
|
|
865
|
-
return [false, { default: schema_._def.defaultValue(), ...json }];
|
|
866
|
-
}
|
|
867
|
-
case ZodFirstPartyTypeKind.ZodEffects: {
|
|
868
|
-
const schema_ = schema;
|
|
869
|
-
if (schema_._def.effect.type === "transform" && options.strategy === "output") {
|
|
870
|
-
return [false, this.anyJsonSchema];
|
|
871
|
-
}
|
|
872
|
-
return this.convert(schema_._def.schema, options, lazyDepth, false, false, structureDepth);
|
|
873
|
-
}
|
|
874
|
-
case ZodFirstPartyTypeKind.ZodCatch: {
|
|
875
|
-
const schema_ = schema;
|
|
876
|
-
return this.convert(schema_._def.innerType, options, lazyDepth, false, false, structureDepth);
|
|
877
|
-
}
|
|
878
|
-
case ZodFirstPartyTypeKind.ZodBranded: {
|
|
879
|
-
const schema_ = schema;
|
|
880
|
-
return this.convert(schema_._def.type, options, lazyDepth, false, false, structureDepth);
|
|
881
|
-
}
|
|
882
|
-
case ZodFirstPartyTypeKind.ZodPipeline: {
|
|
883
|
-
const schema_ = schema;
|
|
884
|
-
return this.convert(
|
|
885
|
-
options.strategy === "input" ? schema_._def.in : schema_._def.out,
|
|
886
|
-
options,
|
|
887
|
-
lazyDepth,
|
|
888
|
-
false,
|
|
889
|
-
false,
|
|
890
|
-
structureDepth
|
|
891
|
-
);
|
|
892
|
-
}
|
|
893
|
-
case ZodFirstPartyTypeKind.ZodNullable: {
|
|
894
|
-
const schema_ = schema;
|
|
895
|
-
const [required, json] = this.convert(
|
|
896
|
-
schema_._def.innerType,
|
|
897
|
-
options,
|
|
898
|
-
lazyDepth,
|
|
899
|
-
false,
|
|
900
|
-
false,
|
|
901
|
-
structureDepth
|
|
902
|
-
);
|
|
903
|
-
return [required, { anyOf: [json, { type: "null" }] }];
|
|
904
|
-
}
|
|
905
|
-
}
|
|
906
|
-
return [true, this.unsupportedJsonSchema];
|
|
1438
|
+
class SchemaClass {
|
|
1439
|
+
string(params) {
|
|
1440
|
+
return string(params);
|
|
907
1441
|
}
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
if (!customZodDef) {
|
|
911
|
-
return void 0;
|
|
912
|
-
}
|
|
913
|
-
switch (customZodDef.type) {
|
|
914
|
-
case "blob": {
|
|
915
|
-
return { type: "string", contentMediaType: "*/*" };
|
|
916
|
-
}
|
|
917
|
-
case "file": {
|
|
918
|
-
return { type: "string", contentMediaType: customZodDef.mimeType ?? "*/*" };
|
|
919
|
-
}
|
|
920
|
-
case "regexp": {
|
|
921
|
-
return {
|
|
922
|
-
type: "string",
|
|
923
|
-
pattern: "^\\/(.*)\\/([a-z]*)$",
|
|
924
|
-
"x-native-type": JsonSchemaXNativeType.RegExp
|
|
925
|
-
};
|
|
926
|
-
}
|
|
927
|
-
case "url": {
|
|
928
|
-
return {
|
|
929
|
-
type: "string",
|
|
930
|
-
format: JSONSchemaFormat.URI,
|
|
931
|
-
"x-native-type": JsonSchemaXNativeType.Url
|
|
932
|
-
};
|
|
933
|
-
}
|
|
934
|
-
}
|
|
1442
|
+
number(params) {
|
|
1443
|
+
return number(params);
|
|
935
1444
|
}
|
|
936
|
-
|
|
937
|
-
return
|
|
1445
|
+
int(params) {
|
|
1446
|
+
return this.number().int(params);
|
|
938
1447
|
}
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
return
|
|
1448
|
+
boolean(params) {
|
|
1449
|
+
return boolean(params);
|
|
1450
|
+
}
|
|
1451
|
+
null(params) {
|
|
1452
|
+
return _null(params);
|
|
1453
|
+
}
|
|
1454
|
+
array(element, params) {
|
|
1455
|
+
return array(element, params);
|
|
1456
|
+
}
|
|
1457
|
+
record(keyType, valueType, params) {
|
|
1458
|
+
return record(keyType, valueType, params);
|
|
944
1459
|
}
|
|
1460
|
+
union(options, params) {
|
|
1461
|
+
return union(options, params);
|
|
1462
|
+
}
|
|
1463
|
+
discriminatedUnion(discriminator, options, params) {
|
|
1464
|
+
return discriminatedUnion(discriminator, options, params);
|
|
1465
|
+
}
|
|
1466
|
+
object(shape, params) {
|
|
1467
|
+
return object(shape, params);
|
|
1468
|
+
}
|
|
1469
|
+
// TODO: make this a codec?
|
|
1470
|
+
date(params) {
|
|
1471
|
+
return date(params);
|
|
1472
|
+
}
|
|
1473
|
+
any() {
|
|
1474
|
+
return any();
|
|
1475
|
+
}
|
|
1476
|
+
unknown() {
|
|
1477
|
+
return unknown();
|
|
1478
|
+
}
|
|
1479
|
+
never(params) {
|
|
1480
|
+
return never(params);
|
|
1481
|
+
}
|
|
1482
|
+
lazy(getter) {
|
|
1483
|
+
return lazy(getter);
|
|
1484
|
+
}
|
|
1485
|
+
json(params) {
|
|
1486
|
+
return json(params);
|
|
1487
|
+
}
|
|
1488
|
+
/**
|
|
1489
|
+
* TODO: def need to expose
|
|
1490
|
+
* file
|
|
1491
|
+
* literal
|
|
1492
|
+
* nativeEnum
|
|
1493
|
+
*/
|
|
1494
|
+
/**
|
|
1495
|
+
* TODO: decide how to handle non-serializeable values
|
|
1496
|
+
* TODO: decide what types to expose
|
|
1497
|
+
* function
|
|
1498
|
+
* promise
|
|
1499
|
+
* readonly
|
|
1500
|
+
* nan
|
|
1501
|
+
* success
|
|
1502
|
+
* set
|
|
1503
|
+
* map
|
|
1504
|
+
* partialRecord
|
|
1505
|
+
* tuple
|
|
1506
|
+
* intersection
|
|
1507
|
+
* keyof
|
|
1508
|
+
* symbol
|
|
1509
|
+
* bigint
|
|
1510
|
+
* blob
|
|
1511
|
+
*/
|
|
1512
|
+
/**
|
|
1513
|
+
* TODO: decide what non-chained format helpers to expose
|
|
1514
|
+
* -- OBJECT
|
|
1515
|
+
* strictObject
|
|
1516
|
+
* looseObject
|
|
1517
|
+
* -- STRING
|
|
1518
|
+
* url
|
|
1519
|
+
* regexp
|
|
1520
|
+
* email
|
|
1521
|
+
* guid
|
|
1522
|
+
* uuid
|
|
1523
|
+
* uuidv4
|
|
1524
|
+
* uuidv6
|
|
1525
|
+
* uuidv7
|
|
1526
|
+
* url
|
|
1527
|
+
* httpUrl
|
|
1528
|
+
* emoji
|
|
1529
|
+
* nanoid
|
|
1530
|
+
* cuid
|
|
1531
|
+
* cuid2
|
|
1532
|
+
* ulid
|
|
1533
|
+
* xid
|
|
1534
|
+
* ksuid
|
|
1535
|
+
* jwt
|
|
1536
|
+
* hostname
|
|
1537
|
+
* hex
|
|
1538
|
+
* hash
|
|
1539
|
+
* ipv4
|
|
1540
|
+
* ipv6
|
|
1541
|
+
* cidrv4
|
|
1542
|
+
* cidrv6
|
|
1543
|
+
* base64
|
|
1544
|
+
* base64url
|
|
1545
|
+
* e164
|
|
1546
|
+
* -- NUMBER
|
|
1547
|
+
* float32
|
|
1548
|
+
* float64
|
|
1549
|
+
* int32
|
|
1550
|
+
* uint32
|
|
1551
|
+
* int64
|
|
1552
|
+
* uint64
|
|
1553
|
+
*/
|
|
1554
|
+
/**
|
|
1555
|
+
* TODO: decide what other helper methods to expose
|
|
1556
|
+
* preprocess
|
|
1557
|
+
* refine
|
|
1558
|
+
* superRefine
|
|
1559
|
+
* custom
|
|
1560
|
+
* check
|
|
1561
|
+
* codec
|
|
1562
|
+
* pipe
|
|
1563
|
+
* nonoptional
|
|
1564
|
+
* prefault
|
|
1565
|
+
* default
|
|
1566
|
+
* nullish
|
|
1567
|
+
* nullable
|
|
1568
|
+
* optional
|
|
1569
|
+
* transform
|
|
1570
|
+
* stringFormat
|
|
1571
|
+
*/
|
|
945
1572
|
}
|
|
946
1573
|
|
|
947
|
-
|
|
948
|
-
file,
|
|
949
|
-
blob,
|
|
950
|
-
url,
|
|
951
|
-
regexp,
|
|
952
|
-
openapi: customJsonSchema
|
|
953
|
-
};
|
|
954
|
-
|
|
955
|
-
export { ZodSmartCoercionPlugin, ZodToJsonSchemaConverter, blob, composeParams, customJsonSchema, file, getCustomJsonSchema, getCustomZodDef, oz, regexp, setCustomZodDef, url };
|
|
1574
|
+
export { KrustyType, SchemaClass, ZodAny, ZodArray, ZodBase64, ZodBase64URL, ZodBigInt, ZodBigIntFormat, ZodBoolean, ZodCIDRv4, ZodCIDRv6, ZodCUID, ZodCUID2, ZodCatch, ZodCodec, ZodCustom, ZodCustomStringFormat, ZodDate, ZodDefault, ZodDiscriminatedUnion, ZodE164, ZodEmail, ZodEmoji, ZodEnum, ZodError, ZodFile, ZodFunction, ZodGUID, ZodGate, ZodIPv4, ZodIPv6, ZodIntersection, ZodJWT, ZodKSUID, ZodLazy, ZodLiteral, ZodMap, ZodNaN, ZodNanoID, ZodNever, ZodNonOptional, ZodNull, ZodNullable, ZodNumber, ZodNumberFormat, ZodObject, ZodOptional, ZodPipe, ZodPrefault, ZodPromise, ZodReadonly, ZodRealError, ZodRecord, ZodSet, ZodString, ZodStringFormat, ZodSuccess, ZodSymbol, ZodTemplateLiteral, ZodTransform, ZodTuple, ZodULID, ZodURL, ZodUUID, ZodUndefined, ZodUnion, ZodUnknown, ZodVoid, ZodXID, _ZodString, _default, _function, any, array, base64, base64url, bigint, blob, boolean, _catch as catch, check, cidrv4, cidrv6, codec, cuid, cuid2, custom, date, decode, decodeAsync, discriminatedUnion, e164, email, emoji, encode, encodeAsync, _enum as enum, file, float32, float64, _function as function, gate, gatingContext, guid, hash, hex, hostname, httpUrl, _instanceof as instanceof, int, int32, int64, intersection, ipv4, ipv6, isGateIssue, isGateIssueRaw, json, jwt, keyof, ksuid, lazy, literal, looseObject, map, nan, nanoid, nativeEnum, never, nonoptional, _null as null, nullable, nullish, number, object, optional, parse, parseAsync, partialRecord, pipe, prefault, preprocess, promise, readonly, record, refine, regexp, safeDecode, safeDecodeAsync, safeEncode, safeEncodeAsync, safeParse, safeParseAsync, set, strictObject, string, stringFormat, stringbool, success, superRefine, symbol, templateLiteral, transform, tuple, uint32, uint64, ulid, _undefined as undefined, union, unknown, url, uuid, uuidv4, uuidv6, uuidv7, _void as void, xid };
|