@temporary-name/zod 1.9.3-alpha.cf2fe368e72e6a6ab0ce041b812dbf8134f70b0b → 1.9.3-alpha.d0c8ba895f81e5ee5f2f893da0804bd96a5aa41c
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 +339 -362
- package/dist/index.d.ts +339 -362
- package/dist/index.mjs +542 -514
- package/package.json +3 -13
- package/dist/zod4/index.d.mts +0 -12
- package/dist/zod4/index.d.ts +0 -12
- package/dist/zod4/index.mjs +0 -259
package/dist/index.mjs
CHANGED
|
@@ -3,7 +3,6 @@ import { $ZodError, util, _overwrite, _regex, _includes, _startsWith, _endsWith,
|
|
|
3
3
|
export { core };
|
|
4
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
5
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
6
|
-
import { custom as custom$1 } from 'zod/v3';
|
|
7
6
|
|
|
8
7
|
const initializer = (inst, issues) => {
|
|
9
8
|
$ZodError.init(inst, issues);
|
|
@@ -57,83 +56,64 @@ const safeDecode = /* @__PURE__ */ core._safeDecode(ZodRealError);
|
|
|
57
56
|
const safeEncodeAsync = /* @__PURE__ */ core._safeEncodeAsync(ZodRealError);
|
|
58
57
|
const safeDecodeAsync = /* @__PURE__ */ core._safeDecodeAsync(ZodRealError);
|
|
59
58
|
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
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);
|
|
59
|
+
const gatingContext = new AsyncLocalStorage();
|
|
60
|
+
function isGateIssueRaw(issue) {
|
|
61
|
+
return issue.code === "invalid_type" && issue.expected === "never" && issue.inst instanceof KrustyGate;
|
|
70
62
|
}
|
|
71
|
-
|
|
72
|
-
"
|
|
63
|
+
function isGateIssue(issue) {
|
|
64
|
+
return issue.code === "invalid_type" && issue.expected === "never" && issue.path?.length === 0;
|
|
65
|
+
}
|
|
66
|
+
const KrustyGate = /* @__PURE__ */ core.$constructor(
|
|
67
|
+
"KrustyGate",
|
|
73
68
|
(inst, def) => {
|
|
74
|
-
const coreInit = core.$
|
|
69
|
+
const coreInit = core.$ZodOptional.init;
|
|
75
70
|
coreInit(inst, def);
|
|
76
|
-
|
|
71
|
+
KrustyType.init(inst, def);
|
|
72
|
+
inst._zod.parse = (payload, ctx) => {
|
|
73
|
+
const gateEnabled = gatingContext.getStore()?.(def.gateName);
|
|
74
|
+
if (gateEnabled) {
|
|
75
|
+
return def.innerType._zod.run(payload, ctx);
|
|
76
|
+
} else if (payload.value !== void 0) {
|
|
77
|
+
payload.issues.push({
|
|
78
|
+
expected: "never",
|
|
79
|
+
code: "invalid_type",
|
|
80
|
+
input: payload.value,
|
|
81
|
+
inst
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
return payload;
|
|
85
|
+
};
|
|
77
86
|
}
|
|
78
87
|
);
|
|
79
|
-
function
|
|
80
|
-
return
|
|
88
|
+
function gate(innerType, gateName) {
|
|
89
|
+
return new KrustyGate({
|
|
90
|
+
type: "optional",
|
|
91
|
+
innerType,
|
|
92
|
+
gateName
|
|
93
|
+
});
|
|
81
94
|
}
|
|
82
|
-
|
|
83
|
-
|
|
95
|
+
|
|
96
|
+
const KrustyISODateTime = /* @__PURE__ */ core.$constructor(
|
|
97
|
+
"KrustyISODateTime",
|
|
84
98
|
(inst, def) => {
|
|
85
|
-
const coreInit = core.$
|
|
99
|
+
const coreInit = core.$ZodISODateTime.init;
|
|
86
100
|
coreInit(inst, def);
|
|
87
|
-
|
|
101
|
+
KrustyStringFormat.init(inst, def);
|
|
88
102
|
}
|
|
89
103
|
);
|
|
90
|
-
function
|
|
91
|
-
return core.
|
|
104
|
+
function datetime$1(params) {
|
|
105
|
+
return core._isoDateTime(KrustyISODateTime, params);
|
|
92
106
|
}
|
|
93
|
-
const
|
|
94
|
-
"
|
|
107
|
+
const KrustyISODate = /* @__PURE__ */ core.$constructor(
|
|
108
|
+
"KrustyISODate",
|
|
95
109
|
(inst, def) => {
|
|
96
|
-
const coreInit = core.$
|
|
110
|
+
const coreInit = core.$ZodISODate.init;
|
|
97
111
|
coreInit(inst, def);
|
|
98
|
-
|
|
112
|
+
KrustyStringFormat.init(inst, def);
|
|
99
113
|
}
|
|
100
114
|
);
|
|
101
|
-
function
|
|
102
|
-
return core.
|
|
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
|
-
});
|
|
115
|
+
function date$1(params) {
|
|
116
|
+
return core._isoDate(KrustyISODate, params);
|
|
137
117
|
}
|
|
138
118
|
|
|
139
119
|
function handleGating(payload) {
|
|
@@ -146,8 +126,8 @@ function handleGating(payload) {
|
|
|
146
126
|
}
|
|
147
127
|
return payload;
|
|
148
128
|
}
|
|
149
|
-
const
|
|
150
|
-
"
|
|
129
|
+
const KrustyUnion = /* @__PURE__ */ core.$constructor(
|
|
130
|
+
"KrustyUnion",
|
|
151
131
|
(inst, def) => {
|
|
152
132
|
const coreInit = core.$ZodUnion.init;
|
|
153
133
|
coreInit(inst, def);
|
|
@@ -165,19 +145,19 @@ const ZodUnion = /* @__PURE__ */ core.$constructor(
|
|
|
165
145
|
}
|
|
166
146
|
);
|
|
167
147
|
function union(options, params) {
|
|
168
|
-
return new
|
|
148
|
+
return new KrustyUnion({
|
|
169
149
|
type: "union",
|
|
170
150
|
options,
|
|
171
151
|
...util.normalizeParams(params)
|
|
172
152
|
});
|
|
173
153
|
}
|
|
174
|
-
const
|
|
175
|
-
|
|
154
|
+
const KrustyDiscriminatedUnion = /* @__PURE__ */ core.$constructor("KrustyDiscriminatedUnion", (inst, def) => {
|
|
155
|
+
KrustyUnion.init(inst, def);
|
|
176
156
|
const coreInit = core.$ZodDiscriminatedUnion.init;
|
|
177
157
|
coreInit(inst, def);
|
|
178
158
|
});
|
|
179
159
|
function discriminatedUnion(discriminator, options, params) {
|
|
180
|
-
return new
|
|
160
|
+
return new KrustyDiscriminatedUnion({
|
|
181
161
|
type: "union",
|
|
182
162
|
options,
|
|
183
163
|
discriminator,
|
|
@@ -197,8 +177,8 @@ function handlePropertyResult(result, final, key, input) {
|
|
|
197
177
|
final.value[key] = result.value;
|
|
198
178
|
}
|
|
199
179
|
}
|
|
200
|
-
const
|
|
201
|
-
"
|
|
180
|
+
const KrustyObject = /* @__PURE__ */ core.$constructor(
|
|
181
|
+
"KrustyObject",
|
|
202
182
|
(inst, def) => {
|
|
203
183
|
const coreInit = core.$ZodObjectJIT.init;
|
|
204
184
|
coreInit(inst, def);
|
|
@@ -221,8 +201,8 @@ const ZodObject = /* @__PURE__ */ core.$constructor(
|
|
|
221
201
|
inst.merge = (other) => util.merge(inst, other);
|
|
222
202
|
inst.pick = (mask) => util.pick(inst, mask);
|
|
223
203
|
inst.omit = (mask) => util.omit(inst, mask);
|
|
224
|
-
inst.partial = (...args) => util.partial(
|
|
225
|
-
inst.required = (...args) => util.required(
|
|
204
|
+
inst.partial = (...args) => util.partial(KrustyOptional, inst, args[0]);
|
|
205
|
+
inst.required = (...args) => util.required(KrustyNonOptional, inst, args[0]);
|
|
226
206
|
function handleGating(input, payload, ctx) {
|
|
227
207
|
const _catchall = def.catchall?._zod;
|
|
228
208
|
const t = _catchall?.def.type;
|
|
@@ -278,6 +258,26 @@ const ZodObject = /* @__PURE__ */ core.$constructor(
|
|
|
278
258
|
inst._zod.parse = (payload, ctx) => {
|
|
279
259
|
const input = payload.value;
|
|
280
260
|
const res = origParse(payload, ctx);
|
|
261
|
+
if (!def.catchall) {
|
|
262
|
+
const { parseType } = ctx;
|
|
263
|
+
if (parseType && parseType !== "output") {
|
|
264
|
+
const unrecognized = [];
|
|
265
|
+
const keySet = new Set(Object.keys(def.shape));
|
|
266
|
+
for (const key in input) {
|
|
267
|
+
if (!keySet.has(key)) {
|
|
268
|
+
unrecognized.push(key);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
if (unrecognized.length) {
|
|
272
|
+
payload.issues.push({
|
|
273
|
+
code: "unrecognized_keys",
|
|
274
|
+
keys: unrecognized,
|
|
275
|
+
input,
|
|
276
|
+
inst
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
281
|
if (res instanceof Promise) {
|
|
282
282
|
return res.then((r) => handleGating(input, r, ctx));
|
|
283
283
|
} else {
|
|
@@ -292,10 +292,10 @@ function object(shape, params) {
|
|
|
292
292
|
shape: shape ?? {},
|
|
293
293
|
...util.normalizeParams(params)
|
|
294
294
|
};
|
|
295
|
-
return new
|
|
295
|
+
return new KrustyObject(def);
|
|
296
296
|
}
|
|
297
297
|
function strictObject(shape, params) {
|
|
298
|
-
return new
|
|
298
|
+
return new KrustyObject({
|
|
299
299
|
type: "object",
|
|
300
300
|
shape,
|
|
301
301
|
catchall: never(),
|
|
@@ -303,7 +303,7 @@ function strictObject(shape, params) {
|
|
|
303
303
|
});
|
|
304
304
|
}
|
|
305
305
|
function looseObject(shape, params) {
|
|
306
|
-
return new
|
|
306
|
+
return new KrustyObject({
|
|
307
307
|
type: "object",
|
|
308
308
|
shape,
|
|
309
309
|
catchall: unknown(),
|
|
@@ -311,60 +311,6 @@ function looseObject(shape, params) {
|
|
|
311
311
|
});
|
|
312
312
|
}
|
|
313
313
|
|
|
314
|
-
const CUSTOM_ZOD_DEF_SYMBOL = Symbol("ORPC_CUSTOM_ZOD_DEF");
|
|
315
|
-
function setCustomZodDef(def, custom) {
|
|
316
|
-
Object.assign(def, { [CUSTOM_ZOD_DEF_SYMBOL]: custom });
|
|
317
|
-
}
|
|
318
|
-
function composeParams(defaultMessage, params) {
|
|
319
|
-
return (val) => {
|
|
320
|
-
const message = defaultMessage(val);
|
|
321
|
-
if (!params) {
|
|
322
|
-
return {
|
|
323
|
-
message
|
|
324
|
-
};
|
|
325
|
-
}
|
|
326
|
-
if (typeof params === "function") {
|
|
327
|
-
return {
|
|
328
|
-
message,
|
|
329
|
-
...params(val)
|
|
330
|
-
};
|
|
331
|
-
}
|
|
332
|
-
if (typeof params === "object") {
|
|
333
|
-
return {
|
|
334
|
-
message,
|
|
335
|
-
...params
|
|
336
|
-
};
|
|
337
|
-
}
|
|
338
|
-
return {
|
|
339
|
-
message: params
|
|
340
|
-
};
|
|
341
|
-
};
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
function blob(params) {
|
|
345
|
-
const schema = custom$1(
|
|
346
|
-
(val) => val instanceof Blob,
|
|
347
|
-
composeParams(
|
|
348
|
-
() => "Input is not a blob",
|
|
349
|
-
params
|
|
350
|
-
)
|
|
351
|
-
);
|
|
352
|
-
setCustomZodDef(schema._def, { type: "blob" });
|
|
353
|
-
return schema;
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
function regexp(params) {
|
|
357
|
-
const schema = custom$1(
|
|
358
|
-
(val) => val instanceof RegExp,
|
|
359
|
-
composeParams(
|
|
360
|
-
() => "Input is not a regexp",
|
|
361
|
-
params
|
|
362
|
-
)
|
|
363
|
-
);
|
|
364
|
-
setCustomZodDef(schema._def, { type: "regexp" });
|
|
365
|
-
return schema;
|
|
366
|
-
}
|
|
367
|
-
|
|
368
314
|
const KrustyType = /* @__PURE__ */ core.$constructor(
|
|
369
315
|
"KrustyType",
|
|
370
316
|
(inst, def) => {
|
|
@@ -391,19 +337,6 @@ const KrustyType = /* @__PURE__ */ core.$constructor(
|
|
|
391
337
|
reg.add(inst, meta);
|
|
392
338
|
return inst;
|
|
393
339
|
});
|
|
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
340
|
inst.refine = (check2, params) => inst.check(refine(check2, params));
|
|
408
341
|
inst.superRefine = (refinement) => inst.check(superRefine(refinement));
|
|
409
342
|
inst.overwrite = (fn) => inst.check(_overwrite(fn));
|
|
@@ -418,9 +351,6 @@ const KrustyType = /* @__PURE__ */ core.$constructor(
|
|
|
418
351
|
inst.transform = (tx) => pipe(inst, transform(tx));
|
|
419
352
|
inst.default = (def2) => _default(inst, def2);
|
|
420
353
|
inst.prefault = (def2) => prefault(inst, def2);
|
|
421
|
-
inst.catch = (params) => _catch(inst, params);
|
|
422
|
-
inst.pipe = (target) => pipe(inst, target);
|
|
423
|
-
inst.readonly = () => readonly(inst);
|
|
424
354
|
inst.describe = (description) => {
|
|
425
355
|
const cl = inst.clone();
|
|
426
356
|
core.globalRegistry.add(cl, { description });
|
|
@@ -443,8 +373,8 @@ const KrustyType = /* @__PURE__ */ core.$constructor(
|
|
|
443
373
|
return inst;
|
|
444
374
|
}
|
|
445
375
|
);
|
|
446
|
-
const
|
|
447
|
-
"
|
|
376
|
+
const _KrustyString = /* @__PURE__ */ core.$constructor(
|
|
377
|
+
"_KrustyString",
|
|
448
378
|
(inst, def) => {
|
|
449
379
|
const coreInit = core.$ZodString.init;
|
|
450
380
|
coreInit(inst, def);
|
|
@@ -469,270 +399,296 @@ const _ZodString = /* @__PURE__ */ core.$constructor(
|
|
|
469
399
|
inst.toUpperCase = () => inst.check(_toUpperCase());
|
|
470
400
|
}
|
|
471
401
|
);
|
|
472
|
-
const
|
|
473
|
-
"
|
|
402
|
+
const KrustyString = /* @__PURE__ */ core.$constructor(
|
|
403
|
+
"KrustyString",
|
|
474
404
|
(inst, def) => {
|
|
475
405
|
const coreInit = core.$ZodString.init;
|
|
476
406
|
coreInit(inst, def);
|
|
477
|
-
|
|
478
|
-
inst.email = (params) => inst.check(core._email(
|
|
479
|
-
inst.url = (params) => inst.check(core._url(
|
|
480
|
-
inst.jwt = (params) => inst.check(core._jwt(
|
|
481
|
-
inst.emoji = (params) => inst.check(core._emoji(
|
|
482
|
-
inst.guid = (params) => inst.check(core._guid(
|
|
483
|
-
inst.uuid = (params) => inst.check(core._uuid(
|
|
484
|
-
inst.uuidv4 = (params) => inst.check(core._uuidv4(
|
|
485
|
-
inst.uuidv6 = (params) => inst.check(core._uuidv6(
|
|
486
|
-
inst.uuidv7 = (params) => inst.check(core._uuidv7(
|
|
487
|
-
inst.nanoid = (params) => inst.check(core._nanoid(
|
|
488
|
-
inst.guid = (params) => inst.check(core._guid(
|
|
489
|
-
inst.cuid = (params) => inst.check(core._cuid(
|
|
490
|
-
inst.cuid2 = (params) => inst.check(core._cuid2(
|
|
491
|
-
inst.ulid = (params) => inst.check(core._ulid(
|
|
492
|
-
inst.base64 = (params) => inst.check(core._base64(
|
|
493
|
-
inst.base64url = (params) => inst.check(core._base64url(
|
|
494
|
-
inst.xid = (params) => inst.check(core._xid(
|
|
495
|
-
inst.ksuid = (params) => inst.check(core._ksuid(
|
|
496
|
-
inst.ipv4 = (params) => inst.check(core._ipv4(
|
|
497
|
-
inst.ipv6 = (params) => inst.check(core._ipv6(
|
|
498
|
-
inst.cidrv4 = (params) => inst.check(core._cidrv4(
|
|
499
|
-
inst.cidrv6 = (params) => inst.check(core._cidrv6(
|
|
500
|
-
inst.e164 = (params) => inst.check(core._e164(
|
|
501
|
-
inst.datetime = (params) => inst.check(datetime(params));
|
|
502
|
-
inst.date = (params) => inst.check(date$1(params));
|
|
503
|
-
inst.time = (params) => inst.check(time(params));
|
|
504
|
-
inst.duration = (params) => inst.check(duration(params));
|
|
407
|
+
_KrustyString.init(inst, def);
|
|
408
|
+
inst.email = (params) => inst.check(core._email(KrustyEmail, params));
|
|
409
|
+
inst.url = (params) => inst.check(core._url(KrustyURL, params));
|
|
410
|
+
inst.jwt = (params) => inst.check(core._jwt(KrustyJWT, params));
|
|
411
|
+
inst.emoji = (params) => inst.check(core._emoji(KrustyEmoji, params));
|
|
412
|
+
inst.guid = (params) => inst.check(core._guid(KrustyGUID, params));
|
|
413
|
+
inst.uuid = (params) => inst.check(core._uuid(KrustyUUID, params));
|
|
414
|
+
inst.uuidv4 = (params) => inst.check(core._uuidv4(KrustyUUID, params));
|
|
415
|
+
inst.uuidv6 = (params) => inst.check(core._uuidv6(KrustyUUID, params));
|
|
416
|
+
inst.uuidv7 = (params) => inst.check(core._uuidv7(KrustyUUID, params));
|
|
417
|
+
inst.nanoid = (params) => inst.check(core._nanoid(KrustyNanoID, params));
|
|
418
|
+
inst.guid = (params) => inst.check(core._guid(KrustyGUID, params));
|
|
419
|
+
inst.cuid = (params) => inst.check(core._cuid(KrustyCUID, params));
|
|
420
|
+
inst.cuid2 = (params) => inst.check(core._cuid2(KrustyCUID2, params));
|
|
421
|
+
inst.ulid = (params) => inst.check(core._ulid(KrustyULID, params));
|
|
422
|
+
inst.base64 = (params) => inst.check(core._base64(KrustyBase64, params));
|
|
423
|
+
inst.base64url = (params) => inst.check(core._base64url(KrustyBase64URL, params));
|
|
424
|
+
inst.xid = (params) => inst.check(core._xid(KrustyXID, params));
|
|
425
|
+
inst.ksuid = (params) => inst.check(core._ksuid(KrustyKSUID, params));
|
|
426
|
+
inst.ipv4 = (params) => inst.check(core._ipv4(KrustyIPv4, params));
|
|
427
|
+
inst.ipv6 = (params) => inst.check(core._ipv6(KrustyIPv6, params));
|
|
428
|
+
inst.cidrv4 = (params) => inst.check(core._cidrv4(KrustyCIDRv4, params));
|
|
429
|
+
inst.cidrv6 = (params) => inst.check(core._cidrv6(KrustyCIDRv6, params));
|
|
430
|
+
inst.e164 = (params) => inst.check(core._e164(KrustyE164, params));
|
|
505
431
|
}
|
|
506
432
|
);
|
|
507
433
|
function string(params) {
|
|
508
|
-
return core._string(
|
|
434
|
+
return core._string(KrustyString, params);
|
|
509
435
|
}
|
|
510
|
-
const
|
|
511
|
-
"
|
|
436
|
+
const KrustyStringFormat = /* @__PURE__ */ core.$constructor(
|
|
437
|
+
"KrustyStringFormat",
|
|
512
438
|
(inst, def) => {
|
|
513
439
|
const coreInit = core.$ZodStringFormat.init;
|
|
514
440
|
coreInit(inst, def);
|
|
515
|
-
|
|
441
|
+
_KrustyString.init(inst, def);
|
|
516
442
|
}
|
|
517
443
|
);
|
|
518
|
-
const
|
|
519
|
-
"
|
|
444
|
+
const KrustyEmail = /* @__PURE__ */ core.$constructor(
|
|
445
|
+
"KrustyEmail",
|
|
520
446
|
(inst, def) => {
|
|
521
447
|
const coreInit = core.$ZodEmail.init;
|
|
522
448
|
coreInit(inst, def);
|
|
523
|
-
|
|
449
|
+
KrustyStringFormat.init(inst, def);
|
|
524
450
|
}
|
|
525
451
|
);
|
|
526
452
|
function email(params) {
|
|
527
|
-
return core._email(
|
|
453
|
+
return core._email(KrustyEmail, params);
|
|
528
454
|
}
|
|
529
|
-
const
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
455
|
+
const KrustyGUID = /* @__PURE__ */ core.$constructor(
|
|
456
|
+
"KrustyGUID",
|
|
457
|
+
(inst, def) => {
|
|
458
|
+
const coreInit = core.$ZodGUID.init;
|
|
459
|
+
coreInit(inst, def);
|
|
460
|
+
KrustyStringFormat.init(inst, def);
|
|
461
|
+
}
|
|
462
|
+
);
|
|
534
463
|
function guid(params) {
|
|
535
|
-
return core._guid(
|
|
464
|
+
return core._guid(KrustyGUID, params);
|
|
536
465
|
}
|
|
537
|
-
const
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
466
|
+
const KrustyUUID = /* @__PURE__ */ core.$constructor(
|
|
467
|
+
"KrustyUUID",
|
|
468
|
+
(inst, def) => {
|
|
469
|
+
const coreInit = core.$ZodUUID.init;
|
|
470
|
+
coreInit(inst, def);
|
|
471
|
+
KrustyStringFormat.init(inst, def);
|
|
472
|
+
}
|
|
473
|
+
);
|
|
542
474
|
function uuid(params) {
|
|
543
|
-
return core._uuid(
|
|
475
|
+
return core._uuid(KrustyUUID, params);
|
|
544
476
|
}
|
|
545
477
|
function uuidv4(params) {
|
|
546
|
-
return core._uuidv4(
|
|
478
|
+
return core._uuidv4(KrustyUUID, params);
|
|
547
479
|
}
|
|
548
480
|
function uuidv6(params) {
|
|
549
|
-
return core._uuidv6(
|
|
481
|
+
return core._uuidv6(KrustyUUID, params);
|
|
550
482
|
}
|
|
551
483
|
function uuidv7(params) {
|
|
552
|
-
return core._uuidv7(
|
|
484
|
+
return core._uuidv7(KrustyUUID, params);
|
|
553
485
|
}
|
|
554
|
-
const
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
486
|
+
const KrustyURL = /* @__PURE__ */ core.$constructor(
|
|
487
|
+
"KrustyURL",
|
|
488
|
+
(inst, def) => {
|
|
489
|
+
const coreInit = core.$ZodURL.init;
|
|
490
|
+
coreInit(inst, def);
|
|
491
|
+
KrustyStringFormat.init(inst, def);
|
|
492
|
+
}
|
|
493
|
+
);
|
|
559
494
|
function url(params) {
|
|
560
|
-
return core._url(
|
|
495
|
+
return core._url(KrustyURL, params);
|
|
561
496
|
}
|
|
562
497
|
function httpUrl(params) {
|
|
563
|
-
return core._url(
|
|
498
|
+
return core._url(KrustyURL, {
|
|
564
499
|
protocol: /^https?$/,
|
|
565
500
|
hostname: core.regexes.domain,
|
|
566
501
|
...util.normalizeParams(params)
|
|
567
502
|
});
|
|
568
503
|
}
|
|
569
|
-
const
|
|
570
|
-
"
|
|
504
|
+
const KrustyEmoji = /* @__PURE__ */ core.$constructor(
|
|
505
|
+
"KrustyEmoji",
|
|
571
506
|
(inst, def) => {
|
|
572
507
|
const coreInit = core.$ZodEmoji.init;
|
|
573
508
|
coreInit(inst, def);
|
|
574
|
-
|
|
509
|
+
KrustyStringFormat.init(inst, def);
|
|
575
510
|
}
|
|
576
511
|
);
|
|
577
512
|
function emoji(params) {
|
|
578
|
-
return core._emoji(
|
|
513
|
+
return core._emoji(KrustyEmoji, params);
|
|
579
514
|
}
|
|
580
|
-
const
|
|
581
|
-
"
|
|
515
|
+
const KrustyNanoID = /* @__PURE__ */ core.$constructor(
|
|
516
|
+
"KrustyNanoID",
|
|
582
517
|
(inst, def) => {
|
|
583
518
|
const coreInit = core.$ZodNanoID.init;
|
|
584
519
|
coreInit(inst, def);
|
|
585
|
-
|
|
520
|
+
KrustyStringFormat.init(inst, def);
|
|
586
521
|
}
|
|
587
522
|
);
|
|
588
523
|
function nanoid(params) {
|
|
589
|
-
return core._nanoid(
|
|
524
|
+
return core._nanoid(KrustyNanoID, params);
|
|
590
525
|
}
|
|
591
|
-
const
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
526
|
+
const KrustyCUID = /* @__PURE__ */ core.$constructor(
|
|
527
|
+
"KrustyCUID",
|
|
528
|
+
(inst, def) => {
|
|
529
|
+
const coreInit = core.$ZodCUID.init;
|
|
530
|
+
coreInit(inst, def);
|
|
531
|
+
KrustyStringFormat.init(inst, def);
|
|
532
|
+
}
|
|
533
|
+
);
|
|
596
534
|
function cuid(params) {
|
|
597
|
-
return core._cuid(
|
|
535
|
+
return core._cuid(KrustyCUID, params);
|
|
598
536
|
}
|
|
599
|
-
const
|
|
600
|
-
"
|
|
537
|
+
const KrustyCUID2 = /* @__PURE__ */ core.$constructor(
|
|
538
|
+
"KrustyCUID2",
|
|
601
539
|
(inst, def) => {
|
|
602
540
|
const coreInit = core.$ZodCUID2.init;
|
|
603
541
|
coreInit(inst, def);
|
|
604
|
-
|
|
542
|
+
KrustyStringFormat.init(inst, def);
|
|
605
543
|
}
|
|
606
544
|
);
|
|
607
545
|
function cuid2(params) {
|
|
608
|
-
return core._cuid2(
|
|
546
|
+
return core._cuid2(KrustyCUID2, params);
|
|
609
547
|
}
|
|
610
|
-
const
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
548
|
+
const KrustyULID = /* @__PURE__ */ core.$constructor(
|
|
549
|
+
"KrustyULID",
|
|
550
|
+
(inst, def) => {
|
|
551
|
+
const coreInit = core.$ZodULID.init;
|
|
552
|
+
coreInit(inst, def);
|
|
553
|
+
KrustyStringFormat.init(inst, def);
|
|
554
|
+
}
|
|
555
|
+
);
|
|
615
556
|
function ulid(params) {
|
|
616
|
-
return core._ulid(
|
|
557
|
+
return core._ulid(KrustyULID, params);
|
|
617
558
|
}
|
|
618
|
-
const
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
559
|
+
const KrustyXID = /* @__PURE__ */ core.$constructor(
|
|
560
|
+
"KrustyXID",
|
|
561
|
+
(inst, def) => {
|
|
562
|
+
const coreInit = core.$ZodXID.init;
|
|
563
|
+
coreInit(inst, def);
|
|
564
|
+
KrustyStringFormat.init(inst, def);
|
|
565
|
+
}
|
|
566
|
+
);
|
|
623
567
|
function xid(params) {
|
|
624
|
-
return core._xid(
|
|
568
|
+
return core._xid(KrustyXID, params);
|
|
625
569
|
}
|
|
626
|
-
const
|
|
627
|
-
"
|
|
570
|
+
const KrustyKSUID = /* @__PURE__ */ core.$constructor(
|
|
571
|
+
"KrustyKSUID",
|
|
628
572
|
(inst, def) => {
|
|
629
573
|
const coreInit = core.$ZodKSUID.init;
|
|
630
574
|
coreInit(inst, def);
|
|
631
|
-
|
|
575
|
+
KrustyStringFormat.init(inst, def);
|
|
632
576
|
}
|
|
633
577
|
);
|
|
634
578
|
function ksuid(params) {
|
|
635
|
-
return core._ksuid(
|
|
579
|
+
return core._ksuid(KrustyKSUID, params);
|
|
636
580
|
}
|
|
637
|
-
const
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
581
|
+
const KrustyIPv4 = /* @__PURE__ */ core.$constructor(
|
|
582
|
+
"KrustyIPv4",
|
|
583
|
+
(inst, def) => {
|
|
584
|
+
const coreInit = core.$ZodIPv4.init;
|
|
585
|
+
coreInit(inst, def);
|
|
586
|
+
KrustyStringFormat.init(inst, def);
|
|
587
|
+
}
|
|
588
|
+
);
|
|
642
589
|
function ipv4(params) {
|
|
643
|
-
return core._ipv4(
|
|
590
|
+
return core._ipv4(KrustyIPv4, params);
|
|
644
591
|
}
|
|
645
|
-
const
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
592
|
+
const KrustyIPv6 = /* @__PURE__ */ core.$constructor(
|
|
593
|
+
"KrustyIPv6",
|
|
594
|
+
(inst, def) => {
|
|
595
|
+
const coreInit = core.$ZodIPv6.init;
|
|
596
|
+
coreInit(inst, def);
|
|
597
|
+
KrustyStringFormat.init(inst, def);
|
|
598
|
+
}
|
|
599
|
+
);
|
|
650
600
|
function ipv6(params) {
|
|
651
|
-
return core._ipv6(
|
|
601
|
+
return core._ipv6(KrustyIPv6, params);
|
|
652
602
|
}
|
|
653
|
-
const
|
|
654
|
-
"
|
|
603
|
+
const KrustyCIDRv4 = /* @__PURE__ */ core.$constructor(
|
|
604
|
+
"KrustyCIDRv4",
|
|
655
605
|
(inst, def) => {
|
|
656
606
|
const coreInit = core.$ZodCIDRv4.init;
|
|
657
607
|
coreInit(inst, def);
|
|
658
|
-
|
|
608
|
+
KrustyStringFormat.init(inst, def);
|
|
659
609
|
}
|
|
660
610
|
);
|
|
661
611
|
function cidrv4(params) {
|
|
662
|
-
return core._cidrv4(
|
|
612
|
+
return core._cidrv4(KrustyCIDRv4, params);
|
|
663
613
|
}
|
|
664
|
-
const
|
|
665
|
-
"
|
|
614
|
+
const KrustyCIDRv6 = /* @__PURE__ */ core.$constructor(
|
|
615
|
+
"KrustyCIDRv6",
|
|
666
616
|
(inst, def) => {
|
|
667
617
|
const coreInit = core.$ZodCIDRv6.init;
|
|
668
618
|
coreInit(inst, def);
|
|
669
|
-
|
|
619
|
+
KrustyStringFormat.init(inst, def);
|
|
670
620
|
}
|
|
671
621
|
);
|
|
672
622
|
function cidrv6(params) {
|
|
673
|
-
return core._cidrv6(
|
|
623
|
+
return core._cidrv6(KrustyCIDRv6, params);
|
|
674
624
|
}
|
|
675
|
-
const
|
|
676
|
-
"
|
|
625
|
+
const KrustyBase64 = /* @__PURE__ */ core.$constructor(
|
|
626
|
+
"KrustyBase64",
|
|
677
627
|
(inst, def) => {
|
|
678
628
|
const coreInit = core.$ZodBase64.init;
|
|
679
629
|
coreInit(inst, def);
|
|
680
|
-
|
|
630
|
+
KrustyStringFormat.init(inst, def);
|
|
681
631
|
}
|
|
682
632
|
);
|
|
683
633
|
function base64(params) {
|
|
684
|
-
return core._base64(
|
|
634
|
+
return core._base64(KrustyBase64, params);
|
|
685
635
|
}
|
|
686
|
-
const
|
|
687
|
-
"
|
|
636
|
+
const KrustyBase64URL = /* @__PURE__ */ core.$constructor(
|
|
637
|
+
"KrustyBase64URL",
|
|
688
638
|
(inst, def) => {
|
|
689
639
|
const coreInit = core.$ZodBase64URL.init;
|
|
690
640
|
coreInit(inst, def);
|
|
691
|
-
|
|
641
|
+
KrustyStringFormat.init(inst, def);
|
|
692
642
|
}
|
|
693
643
|
);
|
|
694
644
|
function base64url(params) {
|
|
695
|
-
return core._base64url(
|
|
645
|
+
return core._base64url(KrustyBase64URL, params);
|
|
696
646
|
}
|
|
697
|
-
const
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
647
|
+
const KrustyE164 = /* @__PURE__ */ core.$constructor(
|
|
648
|
+
"KrustyE164",
|
|
649
|
+
(inst, def) => {
|
|
650
|
+
const coreInit = core.$ZodE164.init;
|
|
651
|
+
coreInit(inst, def);
|
|
652
|
+
KrustyStringFormat.init(inst, def);
|
|
653
|
+
}
|
|
654
|
+
);
|
|
702
655
|
function e164(params) {
|
|
703
|
-
return core._e164(
|
|
656
|
+
return core._e164(KrustyE164, params);
|
|
704
657
|
}
|
|
705
|
-
const
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
658
|
+
const KrustyJWT = /* @__PURE__ */ core.$constructor(
|
|
659
|
+
"KrustyJWT",
|
|
660
|
+
(inst, def) => {
|
|
661
|
+
const coreInit = core.$ZodJWT.init;
|
|
662
|
+
coreInit(inst, def);
|
|
663
|
+
KrustyStringFormat.init(inst, def);
|
|
664
|
+
}
|
|
665
|
+
);
|
|
710
666
|
function jwt(params) {
|
|
711
|
-
return core._jwt(
|
|
667
|
+
return core._jwt(KrustyJWT, params);
|
|
712
668
|
}
|
|
713
|
-
const
|
|
669
|
+
const KrustyCustomStringFormat = /* @__PURE__ */ core.$constructor("KrustyCustomStringFormat", (inst, def) => {
|
|
714
670
|
const coreInit = core.$ZodCustomStringFormat.init;
|
|
715
671
|
coreInit(inst, def);
|
|
716
|
-
|
|
672
|
+
KrustyStringFormat.init(inst, def);
|
|
717
673
|
});
|
|
718
674
|
function stringFormat(format, fnOrRegex, _params = {}) {
|
|
719
|
-
return core._stringFormat(
|
|
675
|
+
return core._stringFormat(KrustyCustomStringFormat, format, fnOrRegex, _params);
|
|
720
676
|
}
|
|
721
677
|
function hostname(_params) {
|
|
722
|
-
return core._stringFormat(
|
|
678
|
+
return core._stringFormat(KrustyCustomStringFormat, "hostname", core.regexes.hostname, _params);
|
|
723
679
|
}
|
|
724
680
|
function hex(_params) {
|
|
725
|
-
return core._stringFormat(
|
|
681
|
+
return core._stringFormat(KrustyCustomStringFormat, "hex", core.regexes.hex, _params);
|
|
726
682
|
}
|
|
727
683
|
function hash(alg, params) {
|
|
728
684
|
const enc = params?.enc ?? "hex";
|
|
729
685
|
const format = `${alg}_${enc}`;
|
|
730
686
|
const regex = core.regexes[format];
|
|
731
687
|
if (!regex) throw new Error(`Unrecognized hash format: ${format}`);
|
|
732
|
-
return core._stringFormat(
|
|
688
|
+
return core._stringFormat(KrustyCustomStringFormat, format, regex, params);
|
|
733
689
|
}
|
|
734
|
-
const
|
|
735
|
-
"
|
|
690
|
+
const KrustyNumber = /* @__PURE__ */ core.$constructor(
|
|
691
|
+
"KrustyNumber",
|
|
736
692
|
(inst, def) => {
|
|
737
693
|
const coreInit = core.$ZodNumber.init;
|
|
738
694
|
coreInit(inst, def);
|
|
@@ -744,7 +700,6 @@ const ZodNumber = /* @__PURE__ */ core.$constructor(
|
|
|
744
700
|
inst.lte = (value, params) => inst.check(_lte(value, params));
|
|
745
701
|
inst.max = (value, params) => inst.check(_lte(value, params));
|
|
746
702
|
inst.int = (params) => inst.check(int(params));
|
|
747
|
-
inst.safe = (params) => inst.check(int(params));
|
|
748
703
|
inst.positive = (params) => inst.check(_gt(0, params));
|
|
749
704
|
inst.nonnegative = (params) => inst.check(_gte(0, params));
|
|
750
705
|
inst.negative = (params) => inst.check(_lt(0, params));
|
|
@@ -758,47 +713,80 @@ const ZodNumber = /* @__PURE__ */ core.$constructor(
|
|
|
758
713
|
inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? 0.5);
|
|
759
714
|
inst.isFinite = true;
|
|
760
715
|
inst.format = bag.format ?? null;
|
|
716
|
+
const origParse = inst._zod.parse;
|
|
717
|
+
inst._zod.parse = (payload, ctx) => {
|
|
718
|
+
const { parseType } = ctx;
|
|
719
|
+
if (parseType === "query" && typeof payload.value === "string") {
|
|
720
|
+
const value = Number(payload.value);
|
|
721
|
+
if (!Number.isNaN(value)) {
|
|
722
|
+
payload.value = value;
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
return origParse(payload, ctx);
|
|
726
|
+
};
|
|
761
727
|
}
|
|
762
728
|
);
|
|
763
729
|
function number(params) {
|
|
764
|
-
return core._number(
|
|
730
|
+
return core._number(KrustyNumber, params);
|
|
765
731
|
}
|
|
766
|
-
const
|
|
767
|
-
"
|
|
732
|
+
const KrustyNumberFormat = /* @__PURE__ */ core.$constructor(
|
|
733
|
+
"KrustyNumberFormat",
|
|
768
734
|
(inst, def) => {
|
|
769
735
|
const coreInit = core.$ZodNumberFormat.init;
|
|
770
736
|
coreInit(inst, def);
|
|
771
|
-
|
|
737
|
+
KrustyNumber.init(inst, def);
|
|
772
738
|
}
|
|
773
739
|
);
|
|
774
740
|
function int(params) {
|
|
775
|
-
return core._int(
|
|
741
|
+
return core._int(KrustyNumberFormat, params);
|
|
776
742
|
}
|
|
777
743
|
function float32(params) {
|
|
778
|
-
return core._float32(
|
|
744
|
+
return core._float32(KrustyNumberFormat, params);
|
|
779
745
|
}
|
|
780
746
|
function float64(params) {
|
|
781
|
-
return core._float64(
|
|
747
|
+
return core._float64(KrustyNumberFormat, params);
|
|
782
748
|
}
|
|
783
749
|
function int32(params) {
|
|
784
|
-
return core._int32(
|
|
750
|
+
return core._int32(KrustyNumberFormat, params);
|
|
785
751
|
}
|
|
786
752
|
function uint32(params) {
|
|
787
|
-
return core._uint32(
|
|
753
|
+
return core._uint32(KrustyNumberFormat, params);
|
|
788
754
|
}
|
|
789
|
-
const
|
|
790
|
-
"
|
|
755
|
+
const KrustyBoolean = /* @__PURE__ */ core.$constructor(
|
|
756
|
+
"KrustyBoolean",
|
|
791
757
|
(inst, def) => {
|
|
792
758
|
const coreInit = core.$ZodBoolean.init;
|
|
793
759
|
coreInit(inst, def);
|
|
794
760
|
KrustyType.init(inst, def);
|
|
761
|
+
const origParse = inst._zod.parse;
|
|
762
|
+
inst._zod.parse = (payload, ctx) => {
|
|
763
|
+
const { parseType } = ctx;
|
|
764
|
+
if (parseType === "query") {
|
|
765
|
+
if (payload.value === "true") {
|
|
766
|
+
payload.value = true;
|
|
767
|
+
} else if (payload.value === "false") {
|
|
768
|
+
payload.value = false;
|
|
769
|
+
} else {
|
|
770
|
+
payload.issues.push({
|
|
771
|
+
code: "invalid_type",
|
|
772
|
+
expected: "boolean",
|
|
773
|
+
values: ["true", "false"],
|
|
774
|
+
input: payload.value,
|
|
775
|
+
inst,
|
|
776
|
+
continue: false
|
|
777
|
+
});
|
|
778
|
+
return payload;
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
return origParse(payload, ctx);
|
|
782
|
+
};
|
|
795
783
|
}
|
|
796
784
|
);
|
|
797
785
|
function boolean(params) {
|
|
798
|
-
return core._boolean(
|
|
786
|
+
return core._boolean(KrustyBoolean, params);
|
|
799
787
|
}
|
|
800
|
-
const
|
|
801
|
-
"
|
|
788
|
+
const KrustyBigInt = /* @__PURE__ */ core.$constructor(
|
|
789
|
+
"KrustyBigInt",
|
|
802
790
|
(inst, def) => {
|
|
803
791
|
const coreInit = core.$ZodBigInt.init;
|
|
804
792
|
coreInit(inst, def);
|
|
@@ -823,24 +811,24 @@ const ZodBigInt = /* @__PURE__ */ core.$constructor(
|
|
|
823
811
|
}
|
|
824
812
|
);
|
|
825
813
|
function bigint(params) {
|
|
826
|
-
return core._bigint(
|
|
814
|
+
return core._bigint(KrustyBigInt, params);
|
|
827
815
|
}
|
|
828
|
-
const
|
|
829
|
-
"
|
|
816
|
+
const KrustyBigIntFormat = /* @__PURE__ */ core.$constructor(
|
|
817
|
+
"KrustyBigIntFormat",
|
|
830
818
|
(inst, def) => {
|
|
831
819
|
const coreInit = core.$ZodBigIntFormat.init;
|
|
832
820
|
coreInit(inst, def);
|
|
833
|
-
|
|
821
|
+
KrustyBigInt.init(inst, def);
|
|
834
822
|
}
|
|
835
823
|
);
|
|
836
824
|
function int64(params) {
|
|
837
|
-
return core._int64(
|
|
825
|
+
return core._int64(KrustyBigIntFormat, params);
|
|
838
826
|
}
|
|
839
827
|
function uint64(params) {
|
|
840
|
-
return core._uint64(
|
|
828
|
+
return core._uint64(KrustyBigIntFormat, params);
|
|
841
829
|
}
|
|
842
|
-
const
|
|
843
|
-
"
|
|
830
|
+
const KrustySymbol = /* @__PURE__ */ core.$constructor(
|
|
831
|
+
"KrustySymbol",
|
|
844
832
|
(inst, def) => {
|
|
845
833
|
const coreInit = core.$ZodSymbol.init;
|
|
846
834
|
coreInit(inst, def);
|
|
@@ -848,10 +836,10 @@ const ZodSymbol = /* @__PURE__ */ core.$constructor(
|
|
|
848
836
|
}
|
|
849
837
|
);
|
|
850
838
|
function symbol(params) {
|
|
851
|
-
return core._symbol(
|
|
839
|
+
return core._symbol(KrustySymbol, params);
|
|
852
840
|
}
|
|
853
|
-
const
|
|
854
|
-
"
|
|
841
|
+
const KrustyUndefined = /* @__PURE__ */ core.$constructor(
|
|
842
|
+
"KrustyUndefined",
|
|
855
843
|
(inst, def) => {
|
|
856
844
|
const coreInit = core.$ZodUndefined.init;
|
|
857
845
|
coreInit(inst, def);
|
|
@@ -859,26 +847,32 @@ const ZodUndefined = /* @__PURE__ */ core.$constructor(
|
|
|
859
847
|
}
|
|
860
848
|
);
|
|
861
849
|
function _undefined(params) {
|
|
862
|
-
return core._undefined(
|
|
850
|
+
return core._undefined(KrustyUndefined, params);
|
|
863
851
|
}
|
|
864
|
-
const
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
852
|
+
const KrustyNull = /* @__PURE__ */ core.$constructor(
|
|
853
|
+
"KrustyNull",
|
|
854
|
+
(inst, def) => {
|
|
855
|
+
const coreInit = core.$ZodNull.init;
|
|
856
|
+
coreInit(inst, def);
|
|
857
|
+
KrustyType.init(inst, def);
|
|
858
|
+
}
|
|
859
|
+
);
|
|
869
860
|
function _null(params) {
|
|
870
|
-
return core._null(
|
|
861
|
+
return core._null(KrustyNull, params);
|
|
871
862
|
}
|
|
872
|
-
const
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
863
|
+
const KrustyAny = /* @__PURE__ */ core.$constructor(
|
|
864
|
+
"KrustyAny",
|
|
865
|
+
(inst, def) => {
|
|
866
|
+
const coreInit = core.$ZodAny.init;
|
|
867
|
+
coreInit(inst, def);
|
|
868
|
+
KrustyType.init(inst, def);
|
|
869
|
+
}
|
|
870
|
+
);
|
|
877
871
|
function any() {
|
|
878
|
-
return core._any(
|
|
872
|
+
return core._any(KrustyAny);
|
|
879
873
|
}
|
|
880
|
-
const
|
|
881
|
-
"
|
|
874
|
+
const KrustyUnknown = /* @__PURE__ */ core.$constructor(
|
|
875
|
+
"KrustyUnknown",
|
|
882
876
|
(inst, def) => {
|
|
883
877
|
const coreInit = core.$ZodUnknown.init;
|
|
884
878
|
coreInit(inst, def);
|
|
@@ -886,10 +880,10 @@ const ZodUnknown = /* @__PURE__ */ core.$constructor(
|
|
|
886
880
|
}
|
|
887
881
|
);
|
|
888
882
|
function unknown() {
|
|
889
|
-
return core._unknown(
|
|
883
|
+
return core._unknown(KrustyUnknown);
|
|
890
884
|
}
|
|
891
|
-
const
|
|
892
|
-
"
|
|
885
|
+
const KrustyNever = /* @__PURE__ */ core.$constructor(
|
|
886
|
+
"KrustyNever",
|
|
893
887
|
(inst, def) => {
|
|
894
888
|
const coreInit = core.$ZodNever.init;
|
|
895
889
|
coreInit(inst, def);
|
|
@@ -897,31 +891,49 @@ const ZodNever = /* @__PURE__ */ core.$constructor(
|
|
|
897
891
|
}
|
|
898
892
|
);
|
|
899
893
|
function never(params) {
|
|
900
|
-
return core._never(
|
|
894
|
+
return core._never(KrustyNever, params);
|
|
901
895
|
}
|
|
902
|
-
const
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
896
|
+
const KrustyVoid = /* @__PURE__ */ core.$constructor(
|
|
897
|
+
"KrustyVoid",
|
|
898
|
+
(inst, def) => {
|
|
899
|
+
const coreInit = core.$ZodVoid.init;
|
|
900
|
+
coreInit(inst, def);
|
|
901
|
+
KrustyType.init(inst, def);
|
|
902
|
+
}
|
|
903
|
+
);
|
|
907
904
|
function _void(params) {
|
|
908
|
-
return core._void(
|
|
905
|
+
return core._void(KrustyVoid, params);
|
|
909
906
|
}
|
|
910
|
-
const
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
907
|
+
const KrustyDate = /* @__PURE__ */ core.$constructor(
|
|
908
|
+
"KrustyDate",
|
|
909
|
+
(inst, def) => {
|
|
910
|
+
const coreInit = core.$ZodDate.init;
|
|
911
|
+
coreInit(inst, def);
|
|
912
|
+
KrustyType.init(inst, def);
|
|
913
|
+
inst.min = (value, params) => inst.check(_gte(value, params));
|
|
914
|
+
inst.max = (value, params) => inst.check(_lte(value, params));
|
|
915
|
+
const c = inst._zod.bag;
|
|
916
|
+
inst.minDate = c.minimum ? new Date(c.minimum) : null;
|
|
917
|
+
inst.maxDate = c.maximum ? new Date(c.maximum) : null;
|
|
918
|
+
}
|
|
919
|
+
);
|
|
920
920
|
function date(params) {
|
|
921
|
-
return core._date(
|
|
921
|
+
return codec(date$1(params), core._date(KrustyDate, params), {
|
|
922
|
+
encode: (date2) => `${date2.getFullYear()}-${String(date2.getMonth() + 1).padStart(2, "0")}-${String(date2.getDate()).padStart(2, "0")}`,
|
|
923
|
+
decode: (isoString2) => {
|
|
924
|
+
const [y, m, d] = isoString2.split("-");
|
|
925
|
+
return new Date(Number(y), Number(m) - 1, Number(d));
|
|
926
|
+
}
|
|
927
|
+
});
|
|
928
|
+
}
|
|
929
|
+
function datetime(params) {
|
|
930
|
+
return codec(datetime$1(params), core._date(KrustyDate, params), {
|
|
931
|
+
encode: (date2) => date2.toISOString(),
|
|
932
|
+
decode: (isoString2) => new Date(isoString2)
|
|
933
|
+
});
|
|
922
934
|
}
|
|
923
|
-
const
|
|
924
|
-
"
|
|
935
|
+
const KrustyArray = /* @__PURE__ */ core.$constructor(
|
|
936
|
+
"KrustyArray",
|
|
925
937
|
(inst, def) => {
|
|
926
938
|
const coreInit = core.$ZodArray.init;
|
|
927
939
|
coreInit(inst, def);
|
|
@@ -935,14 +947,14 @@ const ZodArray = /* @__PURE__ */ core.$constructor(
|
|
|
935
947
|
}
|
|
936
948
|
);
|
|
937
949
|
function array(element, params) {
|
|
938
|
-
return core._array(
|
|
950
|
+
return core._array(KrustyArray, element, params);
|
|
939
951
|
}
|
|
940
952
|
function keyof(schema) {
|
|
941
953
|
const shape = schema._zod.def.shape;
|
|
942
954
|
return _enum(Object.keys(shape));
|
|
943
955
|
}
|
|
944
|
-
const
|
|
945
|
-
"
|
|
956
|
+
const KrustyIntersection = /* @__PURE__ */ core.$constructor(
|
|
957
|
+
"KrustyIntersection",
|
|
946
958
|
(inst, def) => {
|
|
947
959
|
const coreInit = core.$ZodIntersection.init;
|
|
948
960
|
coreInit(inst, def);
|
|
@@ -950,14 +962,14 @@ const ZodIntersection = /* @__PURE__ */ core.$constructor(
|
|
|
950
962
|
}
|
|
951
963
|
);
|
|
952
964
|
function intersection(left, right) {
|
|
953
|
-
return new
|
|
965
|
+
return new KrustyIntersection({
|
|
954
966
|
type: "intersection",
|
|
955
967
|
left,
|
|
956
968
|
right
|
|
957
969
|
});
|
|
958
970
|
}
|
|
959
|
-
const
|
|
960
|
-
"
|
|
971
|
+
const KrustyTuple = /* @__PURE__ */ core.$constructor(
|
|
972
|
+
"KrustyTuple",
|
|
961
973
|
(inst, def) => {
|
|
962
974
|
const coreInit = core.$ZodTuple.init;
|
|
963
975
|
coreInit(inst, def);
|
|
@@ -972,15 +984,15 @@ function tuple(items, _paramsOrRest, _params) {
|
|
|
972
984
|
const hasRest = _paramsOrRest instanceof core.$ZodType;
|
|
973
985
|
const params = hasRest ? _params : _paramsOrRest;
|
|
974
986
|
const rest = hasRest ? _paramsOrRest : null;
|
|
975
|
-
return new
|
|
987
|
+
return new KrustyTuple({
|
|
976
988
|
type: "tuple",
|
|
977
989
|
items,
|
|
978
990
|
rest,
|
|
979
991
|
...util.normalizeParams(params)
|
|
980
992
|
});
|
|
981
993
|
}
|
|
982
|
-
const
|
|
983
|
-
"
|
|
994
|
+
const KrustyRecord = /* @__PURE__ */ core.$constructor(
|
|
995
|
+
"KrustyRecord",
|
|
984
996
|
(inst, def) => {
|
|
985
997
|
const coreInit = core.$ZodRecord.init;
|
|
986
998
|
coreInit(inst, def);
|
|
@@ -990,7 +1002,7 @@ const ZodRecord = /* @__PURE__ */ core.$constructor(
|
|
|
990
1002
|
}
|
|
991
1003
|
);
|
|
992
1004
|
function record(keyType, valueType, params) {
|
|
993
|
-
return new
|
|
1005
|
+
return new KrustyRecord({
|
|
994
1006
|
type: "record",
|
|
995
1007
|
keyType,
|
|
996
1008
|
valueType,
|
|
@@ -1000,97 +1012,106 @@ function record(keyType, valueType, params) {
|
|
|
1000
1012
|
function partialRecord(keyType, valueType, params) {
|
|
1001
1013
|
const k = core.clone(keyType);
|
|
1002
1014
|
k._zod.values = void 0;
|
|
1003
|
-
return new
|
|
1015
|
+
return new KrustyRecord({
|
|
1004
1016
|
type: "record",
|
|
1005
1017
|
keyType: k,
|
|
1006
1018
|
valueType,
|
|
1007
1019
|
...util.normalizeParams(params)
|
|
1008
1020
|
});
|
|
1009
1021
|
}
|
|
1010
|
-
const
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1022
|
+
const KrustyMap = /* @__PURE__ */ core.$constructor(
|
|
1023
|
+
"KrustyMap",
|
|
1024
|
+
(inst, def) => {
|
|
1025
|
+
const coreInit = core.$ZodMap.init;
|
|
1026
|
+
coreInit(inst, def);
|
|
1027
|
+
KrustyType.init(inst, def);
|
|
1028
|
+
inst.keyType = def.keyType;
|
|
1029
|
+
inst.valueType = def.valueType;
|
|
1030
|
+
}
|
|
1031
|
+
);
|
|
1017
1032
|
function map(keyType, valueType, params) {
|
|
1018
|
-
return new
|
|
1033
|
+
return new KrustyMap({
|
|
1019
1034
|
type: "map",
|
|
1020
1035
|
keyType,
|
|
1021
1036
|
valueType,
|
|
1022
1037
|
...util.normalizeParams(params)
|
|
1023
1038
|
});
|
|
1024
1039
|
}
|
|
1025
|
-
const
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1040
|
+
const KrustySet = /* @__PURE__ */ core.$constructor(
|
|
1041
|
+
"KrustySet",
|
|
1042
|
+
(inst, def) => {
|
|
1043
|
+
const coreInit = core.$ZodSet.init;
|
|
1044
|
+
coreInit(inst, def);
|
|
1045
|
+
KrustyType.init(inst, def);
|
|
1046
|
+
inst.min = (...args) => inst.check(core._minSize(...args));
|
|
1047
|
+
inst.nonempty = (params) => inst.check(core._minSize(1, params));
|
|
1048
|
+
inst.max = (...args) => inst.check(core._maxSize(...args));
|
|
1049
|
+
inst.size = (...args) => inst.check(core._size(...args));
|
|
1050
|
+
}
|
|
1051
|
+
);
|
|
1034
1052
|
function set(valueType, params) {
|
|
1035
|
-
return new
|
|
1053
|
+
return new KrustySet({
|
|
1036
1054
|
type: "set",
|
|
1037
1055
|
valueType,
|
|
1038
1056
|
...util.normalizeParams(params)
|
|
1039
1057
|
});
|
|
1040
1058
|
}
|
|
1041
|
-
const
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
const
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
});
|
|
1059
|
+
const KrustyEnum = /* @__PURE__ */ core.$constructor(
|
|
1060
|
+
"KrustyEnum",
|
|
1061
|
+
(inst, def) => {
|
|
1062
|
+
const coreInit = core.$ZodEnum.init;
|
|
1063
|
+
coreInit(inst, def);
|
|
1064
|
+
KrustyType.init(inst, def);
|
|
1065
|
+
inst.enum = def.entries;
|
|
1066
|
+
inst.options = Object.values(def.entries);
|
|
1067
|
+
const keys = new Set(Object.keys(def.entries));
|
|
1068
|
+
inst.extract = (values, params) => {
|
|
1069
|
+
const newEntries = {};
|
|
1070
|
+
for (const value of values) {
|
|
1071
|
+
if (keys.has(value)) {
|
|
1072
|
+
newEntries[value] = def.entries[value];
|
|
1073
|
+
} else throw new Error(`Key ${value} not found in enum`);
|
|
1074
|
+
}
|
|
1075
|
+
return new KrustyEnum({
|
|
1076
|
+
...def,
|
|
1077
|
+
checks: [],
|
|
1078
|
+
...util.normalizeParams(params),
|
|
1079
|
+
entries: newEntries
|
|
1080
|
+
});
|
|
1081
|
+
};
|
|
1082
|
+
inst.exclude = (values, params) => {
|
|
1083
|
+
const newEntries = { ...def.entries };
|
|
1084
|
+
for (const value of values) {
|
|
1085
|
+
if (keys.has(value)) {
|
|
1086
|
+
delete newEntries[value];
|
|
1087
|
+
} else throw new Error(`Key ${value} not found in enum`);
|
|
1088
|
+
}
|
|
1089
|
+
return new KrustyEnum({
|
|
1090
|
+
...def,
|
|
1091
|
+
checks: [],
|
|
1092
|
+
...util.normalizeParams(params),
|
|
1093
|
+
entries: newEntries
|
|
1094
|
+
});
|
|
1095
|
+
};
|
|
1096
|
+
}
|
|
1097
|
+
);
|
|
1077
1098
|
function _enum(values, params) {
|
|
1078
1099
|
const entries = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
|
|
1079
|
-
return new
|
|
1100
|
+
return new KrustyEnum({
|
|
1080
1101
|
type: "enum",
|
|
1081
1102
|
entries,
|
|
1082
1103
|
...util.normalizeParams(params)
|
|
1083
1104
|
});
|
|
1084
1105
|
}
|
|
1085
1106
|
function nativeEnum(entries, params) {
|
|
1086
|
-
return new
|
|
1107
|
+
return new KrustyEnum({
|
|
1087
1108
|
type: "enum",
|
|
1088
1109
|
entries,
|
|
1089
1110
|
...util.normalizeParams(params)
|
|
1090
1111
|
});
|
|
1091
1112
|
}
|
|
1092
|
-
const
|
|
1093
|
-
"
|
|
1113
|
+
const KrustyLiteral = /* @__PURE__ */ core.$constructor(
|
|
1114
|
+
"KrustyLiteral",
|
|
1094
1115
|
(inst, def) => {
|
|
1095
1116
|
const coreInit = core.$ZodLiteral.init;
|
|
1096
1117
|
coreInit(inst, def);
|
|
@@ -1107,25 +1128,28 @@ const ZodLiteral = /* @__PURE__ */ core.$constructor(
|
|
|
1107
1128
|
}
|
|
1108
1129
|
);
|
|
1109
1130
|
function literal(value, params) {
|
|
1110
|
-
return new
|
|
1131
|
+
return new KrustyLiteral({
|
|
1111
1132
|
type: "literal",
|
|
1112
1133
|
values: Array.isArray(value) ? value : [value],
|
|
1113
1134
|
...util.normalizeParams(params)
|
|
1114
1135
|
});
|
|
1115
1136
|
}
|
|
1116
|
-
const
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1137
|
+
const KrustyFile = /* @__PURE__ */ core.$constructor(
|
|
1138
|
+
"KrustyFile",
|
|
1139
|
+
(inst, def) => {
|
|
1140
|
+
const coreInit = core.$ZodFile.init;
|
|
1141
|
+
coreInit(inst, def);
|
|
1142
|
+
KrustyType.init(inst, def);
|
|
1143
|
+
inst.min = (size, params) => inst.check(core._minSize(size, params));
|
|
1144
|
+
inst.max = (size, params) => inst.check(core._maxSize(size, params));
|
|
1145
|
+
inst.mime = (types, params) => inst.check(core._mime(Array.isArray(types) ? types : [types], params));
|
|
1146
|
+
}
|
|
1147
|
+
);
|
|
1124
1148
|
function file(params) {
|
|
1125
|
-
return core._file(
|
|
1149
|
+
return core._file(KrustyFile, params);
|
|
1126
1150
|
}
|
|
1127
|
-
const
|
|
1128
|
-
"
|
|
1151
|
+
const KrustyTransform = /* @__PURE__ */ core.$constructor(
|
|
1152
|
+
"KrustyTransform",
|
|
1129
1153
|
(inst, def) => {
|
|
1130
1154
|
const coreInit = core.$ZodTransform.init;
|
|
1131
1155
|
coreInit(inst, def);
|
|
@@ -1159,13 +1183,13 @@ const ZodTransform = /* @__PURE__ */ core.$constructor(
|
|
|
1159
1183
|
}
|
|
1160
1184
|
);
|
|
1161
1185
|
function transform(fn) {
|
|
1162
|
-
return new
|
|
1186
|
+
return new KrustyTransform({
|
|
1163
1187
|
type: "transform",
|
|
1164
1188
|
transform: fn
|
|
1165
1189
|
});
|
|
1166
1190
|
}
|
|
1167
|
-
const
|
|
1168
|
-
"
|
|
1191
|
+
const KrustyOptional = /* @__PURE__ */ core.$constructor(
|
|
1192
|
+
"KrustyOptional",
|
|
1169
1193
|
(inst, def) => {
|
|
1170
1194
|
const coreInit = core.$ZodOptional.init;
|
|
1171
1195
|
coreInit(inst, def);
|
|
@@ -1174,13 +1198,13 @@ const ZodOptional = /* @__PURE__ */ core.$constructor(
|
|
|
1174
1198
|
}
|
|
1175
1199
|
);
|
|
1176
1200
|
function optional(innerType) {
|
|
1177
|
-
return new
|
|
1201
|
+
return new KrustyOptional({
|
|
1178
1202
|
type: "optional",
|
|
1179
1203
|
innerType
|
|
1180
1204
|
});
|
|
1181
1205
|
}
|
|
1182
|
-
const
|
|
1183
|
-
"
|
|
1206
|
+
const KrustyNullable = /* @__PURE__ */ core.$constructor(
|
|
1207
|
+
"KrustyNullable",
|
|
1184
1208
|
(inst, def) => {
|
|
1185
1209
|
const coreInit = core.$ZodNullable.init;
|
|
1186
1210
|
coreInit(inst, def);
|
|
@@ -1189,7 +1213,7 @@ const ZodNullable = /* @__PURE__ */ core.$constructor(
|
|
|
1189
1213
|
}
|
|
1190
1214
|
);
|
|
1191
1215
|
function nullable(innerType) {
|
|
1192
|
-
return new
|
|
1216
|
+
return new KrustyNullable({
|
|
1193
1217
|
type: "nullable",
|
|
1194
1218
|
innerType
|
|
1195
1219
|
});
|
|
@@ -1197,8 +1221,8 @@ function nullable(innerType) {
|
|
|
1197
1221
|
function nullish(innerType) {
|
|
1198
1222
|
return optional(nullable(innerType));
|
|
1199
1223
|
}
|
|
1200
|
-
const
|
|
1201
|
-
"
|
|
1224
|
+
const KrustyDefault = /* @__PURE__ */ core.$constructor(
|
|
1225
|
+
"KrustyDefault",
|
|
1202
1226
|
(inst, def) => {
|
|
1203
1227
|
const coreInit = core.$ZodDefault.init;
|
|
1204
1228
|
coreInit(inst, def);
|
|
@@ -1208,7 +1232,7 @@ const ZodDefault = /* @__PURE__ */ core.$constructor(
|
|
|
1208
1232
|
}
|
|
1209
1233
|
);
|
|
1210
1234
|
function _default(innerType, defaultValue) {
|
|
1211
|
-
return new
|
|
1235
|
+
return new KrustyDefault({
|
|
1212
1236
|
type: "default",
|
|
1213
1237
|
innerType,
|
|
1214
1238
|
get defaultValue() {
|
|
@@ -1216,8 +1240,8 @@ function _default(innerType, defaultValue) {
|
|
|
1216
1240
|
}
|
|
1217
1241
|
});
|
|
1218
1242
|
}
|
|
1219
|
-
const
|
|
1220
|
-
"
|
|
1243
|
+
const KrustyPrefault = /* @__PURE__ */ core.$constructor(
|
|
1244
|
+
"KrustyPrefault",
|
|
1221
1245
|
(inst, def) => {
|
|
1222
1246
|
const coreInit = core.$ZodPrefault.init;
|
|
1223
1247
|
coreInit(inst, def);
|
|
@@ -1226,7 +1250,7 @@ const ZodPrefault = /* @__PURE__ */ core.$constructor(
|
|
|
1226
1250
|
}
|
|
1227
1251
|
);
|
|
1228
1252
|
function prefault(innerType, defaultValue) {
|
|
1229
|
-
return new
|
|
1253
|
+
return new KrustyPrefault({
|
|
1230
1254
|
type: "prefault",
|
|
1231
1255
|
innerType,
|
|
1232
1256
|
get defaultValue() {
|
|
@@ -1234,8 +1258,8 @@ function prefault(innerType, defaultValue) {
|
|
|
1234
1258
|
}
|
|
1235
1259
|
});
|
|
1236
1260
|
}
|
|
1237
|
-
const
|
|
1238
|
-
"
|
|
1261
|
+
const KrustyNonOptional = /* @__PURE__ */ core.$constructor(
|
|
1262
|
+
"KrustyNonOptional",
|
|
1239
1263
|
(inst, def) => {
|
|
1240
1264
|
const coreInit = core.$ZodNonOptional.init;
|
|
1241
1265
|
coreInit(inst, def);
|
|
@@ -1244,14 +1268,14 @@ const ZodNonOptional = /* @__PURE__ */ core.$constructor(
|
|
|
1244
1268
|
}
|
|
1245
1269
|
);
|
|
1246
1270
|
function nonoptional(innerType, params) {
|
|
1247
|
-
return new
|
|
1271
|
+
return new KrustyNonOptional({
|
|
1248
1272
|
type: "nonoptional",
|
|
1249
1273
|
innerType,
|
|
1250
1274
|
...util.normalizeParams(params)
|
|
1251
1275
|
});
|
|
1252
1276
|
}
|
|
1253
|
-
const
|
|
1254
|
-
"
|
|
1277
|
+
const KrustySuccess = /* @__PURE__ */ core.$constructor(
|
|
1278
|
+
"KrustySuccess",
|
|
1255
1279
|
(inst, def) => {
|
|
1256
1280
|
const coreInit = core.$ZodSuccess.init;
|
|
1257
1281
|
coreInit(inst, def);
|
|
@@ -1260,13 +1284,13 @@ const ZodSuccess = /* @__PURE__ */ core.$constructor(
|
|
|
1260
1284
|
}
|
|
1261
1285
|
);
|
|
1262
1286
|
function success(innerType) {
|
|
1263
|
-
return new
|
|
1287
|
+
return new KrustySuccess({
|
|
1264
1288
|
type: "success",
|
|
1265
1289
|
innerType
|
|
1266
1290
|
});
|
|
1267
1291
|
}
|
|
1268
|
-
const
|
|
1269
|
-
"
|
|
1292
|
+
const KrustyCatch = /* @__PURE__ */ core.$constructor(
|
|
1293
|
+
"KrustyCatch",
|
|
1270
1294
|
(inst, def) => {
|
|
1271
1295
|
const coreInit = core.$ZodCatch.init;
|
|
1272
1296
|
coreInit(inst, def);
|
|
@@ -1276,45 +1300,51 @@ const ZodCatch = /* @__PURE__ */ core.$constructor(
|
|
|
1276
1300
|
}
|
|
1277
1301
|
);
|
|
1278
1302
|
function _catch(innerType, catchValue) {
|
|
1279
|
-
return new
|
|
1303
|
+
return new KrustyCatch({
|
|
1280
1304
|
type: "catch",
|
|
1281
1305
|
innerType,
|
|
1282
1306
|
catchValue: typeof catchValue === "function" ? catchValue : () => catchValue
|
|
1283
1307
|
});
|
|
1284
1308
|
}
|
|
1285
|
-
const
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1309
|
+
const KrustyNaN = /* @__PURE__ */ core.$constructor(
|
|
1310
|
+
"KrustyNaN",
|
|
1311
|
+
(inst, def) => {
|
|
1312
|
+
const coreInit = core.$ZodNaN.init;
|
|
1313
|
+
coreInit(inst, def);
|
|
1314
|
+
KrustyType.init(inst, def);
|
|
1315
|
+
}
|
|
1316
|
+
);
|
|
1290
1317
|
function nan(params) {
|
|
1291
|
-
return core._nan(
|
|
1318
|
+
return core._nan(KrustyNaN, params);
|
|
1292
1319
|
}
|
|
1293
|
-
const
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1320
|
+
const KrustyPipe = /* @__PURE__ */ core.$constructor(
|
|
1321
|
+
"KrustyPipe",
|
|
1322
|
+
(inst, def) => {
|
|
1323
|
+
const coreInit = core.$ZodPipe.init;
|
|
1324
|
+
coreInit(inst, def);
|
|
1325
|
+
KrustyType.init(inst, def);
|
|
1326
|
+
inst.in = def.in;
|
|
1327
|
+
inst.out = def.out;
|
|
1328
|
+
}
|
|
1329
|
+
);
|
|
1300
1330
|
function pipe(in_, out) {
|
|
1301
|
-
return new
|
|
1331
|
+
return new KrustyPipe({
|
|
1302
1332
|
type: "pipe",
|
|
1303
1333
|
in: in_,
|
|
1304
1334
|
out
|
|
1305
1335
|
// ...util.normalizeParams(params),
|
|
1306
1336
|
});
|
|
1307
1337
|
}
|
|
1308
|
-
const
|
|
1309
|
-
"
|
|
1338
|
+
const KrustyCodec = /* @__PURE__ */ core.$constructor(
|
|
1339
|
+
"KrustyCodec",
|
|
1310
1340
|
(inst, def) => {
|
|
1311
|
-
|
|
1341
|
+
KrustyPipe.init(inst, def);
|
|
1312
1342
|
const coreInit = core.$ZodCodec.init;
|
|
1313
1343
|
coreInit(inst, def);
|
|
1314
1344
|
}
|
|
1315
1345
|
);
|
|
1316
1346
|
function codec(in_, out, params) {
|
|
1317
|
-
return new
|
|
1347
|
+
return new KrustyCodec({
|
|
1318
1348
|
type: "pipe",
|
|
1319
1349
|
in: in_,
|
|
1320
1350
|
out,
|
|
@@ -1322,8 +1352,8 @@ function codec(in_, out, params) {
|
|
|
1322
1352
|
reverseTransform: params.encode
|
|
1323
1353
|
});
|
|
1324
1354
|
}
|
|
1325
|
-
const
|
|
1326
|
-
"
|
|
1355
|
+
const KrustyReadonly = /* @__PURE__ */ core.$constructor(
|
|
1356
|
+
"KrustyReadonly",
|
|
1327
1357
|
(inst, def) => {
|
|
1328
1358
|
const coreInit = core.$ZodReadonly.init;
|
|
1329
1359
|
coreInit(inst, def);
|
|
@@ -1332,40 +1362,40 @@ const ZodReadonly = /* @__PURE__ */ core.$constructor(
|
|
|
1332
1362
|
}
|
|
1333
1363
|
);
|
|
1334
1364
|
function readonly(innerType) {
|
|
1335
|
-
return new
|
|
1365
|
+
return new KrustyReadonly({
|
|
1336
1366
|
type: "readonly",
|
|
1337
1367
|
innerType
|
|
1338
1368
|
});
|
|
1339
1369
|
}
|
|
1340
|
-
const
|
|
1341
|
-
|
|
1342
|
-
(inst, def)
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
KrustyType.init(inst, def);
|
|
1346
|
-
}
|
|
1347
|
-
);
|
|
1370
|
+
const KrustyTemplateLiteral = /* @__PURE__ */ core.$constructor("KrustyTemplateLiteral", (inst, def) => {
|
|
1371
|
+
const coreInit = core.$ZodTemplateLiteral.init;
|
|
1372
|
+
coreInit(inst, def);
|
|
1373
|
+
KrustyType.init(inst, def);
|
|
1374
|
+
});
|
|
1348
1375
|
function templateLiteral(parts, params) {
|
|
1349
|
-
return new
|
|
1376
|
+
return new KrustyTemplateLiteral({
|
|
1350
1377
|
type: "template_literal",
|
|
1351
1378
|
parts,
|
|
1352
1379
|
...util.normalizeParams(params)
|
|
1353
1380
|
});
|
|
1354
1381
|
}
|
|
1355
|
-
const
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1382
|
+
const KrustyLazy = /* @__PURE__ */ core.$constructor(
|
|
1383
|
+
"KrustyLazy",
|
|
1384
|
+
(inst, def) => {
|
|
1385
|
+
const coreInit = core.$ZodLazy.init;
|
|
1386
|
+
coreInit(inst, def);
|
|
1387
|
+
KrustyType.init(inst, def);
|
|
1388
|
+
inst.unwrap = () => inst._zod.def.getter();
|
|
1389
|
+
}
|
|
1390
|
+
);
|
|
1361
1391
|
function lazy(getter) {
|
|
1362
|
-
return new
|
|
1392
|
+
return new KrustyLazy({
|
|
1363
1393
|
type: "lazy",
|
|
1364
1394
|
getter
|
|
1365
1395
|
});
|
|
1366
1396
|
}
|
|
1367
|
-
const
|
|
1368
|
-
"
|
|
1397
|
+
const KrustyPromise = /* @__PURE__ */ core.$constructor(
|
|
1398
|
+
"KrustyPromise",
|
|
1369
1399
|
(inst, def) => {
|
|
1370
1400
|
const coreInit = core.$ZodPromise.init;
|
|
1371
1401
|
coreInit(inst, def);
|
|
@@ -1374,13 +1404,13 @@ const ZodPromise = /* @__PURE__ */ core.$constructor(
|
|
|
1374
1404
|
}
|
|
1375
1405
|
);
|
|
1376
1406
|
function promise(innerType) {
|
|
1377
|
-
return new
|
|
1407
|
+
return new KrustyPromise({
|
|
1378
1408
|
type: "promise",
|
|
1379
1409
|
innerType
|
|
1380
1410
|
});
|
|
1381
1411
|
}
|
|
1382
|
-
const
|
|
1383
|
-
"
|
|
1412
|
+
const KrustyFunction = /* @__PURE__ */ core.$constructor(
|
|
1413
|
+
"KrustyFunction",
|
|
1384
1414
|
(inst, def) => {
|
|
1385
1415
|
const coreInit = core.$ZodFunction.init;
|
|
1386
1416
|
coreInit(inst, def);
|
|
@@ -1388,14 +1418,14 @@ const ZodFunction = /* @__PURE__ */ core.$constructor(
|
|
|
1388
1418
|
}
|
|
1389
1419
|
);
|
|
1390
1420
|
function _function(params) {
|
|
1391
|
-
return new
|
|
1421
|
+
return new KrustyFunction({
|
|
1392
1422
|
type: "function",
|
|
1393
1423
|
input: Array.isArray(params?.input) ? tuple(params?.input) : params?.input ?? array(unknown()),
|
|
1394
1424
|
output: params?.output ?? unknown()
|
|
1395
1425
|
});
|
|
1396
1426
|
}
|
|
1397
|
-
const
|
|
1398
|
-
"
|
|
1427
|
+
const KrustyCustom = /* @__PURE__ */ core.$constructor(
|
|
1428
|
+
"KrustyCustom",
|
|
1399
1429
|
(inst, def) => {
|
|
1400
1430
|
const coreInit = core.$ZodCustom.init;
|
|
1401
1431
|
coreInit(inst, def);
|
|
@@ -1411,10 +1441,10 @@ function check(fn) {
|
|
|
1411
1441
|
return ch;
|
|
1412
1442
|
}
|
|
1413
1443
|
function custom(fn, _params) {
|
|
1414
|
-
return core._custom(
|
|
1444
|
+
return core._custom(KrustyCustom, fn ?? (() => true), _params);
|
|
1415
1445
|
}
|
|
1416
1446
|
function refine(fn, _params = {}) {
|
|
1417
|
-
return core._refine(
|
|
1447
|
+
return core._refine(KrustyCustom, fn, _params);
|
|
1418
1448
|
}
|
|
1419
1449
|
function superRefine(fn) {
|
|
1420
1450
|
return core._superRefine(fn);
|
|
@@ -1422,7 +1452,7 @@ function superRefine(fn) {
|
|
|
1422
1452
|
function _instanceof(cls, params = {
|
|
1423
1453
|
error: `Input not instance of ${cls.name}`
|
|
1424
1454
|
}) {
|
|
1425
|
-
const inst = new
|
|
1455
|
+
const inst = new KrustyCustom({
|
|
1426
1456
|
type: "custom",
|
|
1427
1457
|
check: "custom",
|
|
1428
1458
|
fn: (data) => data instanceof cls,
|
|
@@ -1434,9 +1464,9 @@ function _instanceof(cls, params = {
|
|
|
1434
1464
|
}
|
|
1435
1465
|
const stringbool = (...args) => core._stringbool(
|
|
1436
1466
|
{
|
|
1437
|
-
Codec:
|
|
1438
|
-
Boolean:
|
|
1439
|
-
String:
|
|
1467
|
+
Codec: KrustyCodec,
|
|
1468
|
+
Boolean: KrustyBoolean,
|
|
1469
|
+
String: KrustyString
|
|
1440
1470
|
},
|
|
1441
1471
|
...args
|
|
1442
1472
|
);
|
|
@@ -1453,9 +1483,6 @@ function json(params) {
|
|
|
1453
1483
|
});
|
|
1454
1484
|
return jsonSchema;
|
|
1455
1485
|
}
|
|
1456
|
-
function preprocess(fn, schema) {
|
|
1457
|
-
return pipe(transform(fn), schema);
|
|
1458
|
-
}
|
|
1459
1486
|
|
|
1460
1487
|
class SchemaClass {
|
|
1461
1488
|
string(params) {
|
|
@@ -1488,10 +1515,12 @@ class SchemaClass {
|
|
|
1488
1515
|
object(shape, params) {
|
|
1489
1516
|
return object(shape, params);
|
|
1490
1517
|
}
|
|
1491
|
-
// TODO: make this a codec?
|
|
1492
1518
|
date(params) {
|
|
1493
1519
|
return date(params);
|
|
1494
1520
|
}
|
|
1521
|
+
datetime(params) {
|
|
1522
|
+
return datetime(params);
|
|
1523
|
+
}
|
|
1495
1524
|
any() {
|
|
1496
1525
|
return any();
|
|
1497
1526
|
}
|
|
@@ -1575,7 +1604,6 @@ class SchemaClass {
|
|
|
1575
1604
|
*/
|
|
1576
1605
|
/**
|
|
1577
1606
|
* TODO: decide what other helper methods to expose
|
|
1578
|
-
* preprocess
|
|
1579
1607
|
* refine
|
|
1580
1608
|
* superRefine
|
|
1581
1609
|
* custom
|
|
@@ -1593,4 +1621,4 @@ class SchemaClass {
|
|
|
1593
1621
|
*/
|
|
1594
1622
|
}
|
|
1595
1623
|
|
|
1596
|
-
export {
|
|
1624
|
+
export { KrustyAny, KrustyArray, KrustyBase64, KrustyBase64URL, KrustyBigInt, KrustyBigIntFormat, KrustyBoolean, KrustyCIDRv4, KrustyCIDRv6, KrustyCUID, KrustyCUID2, KrustyCatch, KrustyCodec, KrustyCustom, KrustyCustomStringFormat, KrustyDate, KrustyDefault, KrustyDiscriminatedUnion, KrustyE164, KrustyEmail, KrustyEmoji, KrustyEnum, KrustyFile, KrustyFunction, KrustyGUID, KrustyGate, KrustyIPv4, KrustyIPv6, KrustyIntersection, KrustyJWT, KrustyKSUID, KrustyLazy, KrustyLiteral, KrustyMap, KrustyNaN, KrustyNanoID, KrustyNever, KrustyNonOptional, KrustyNull, KrustyNullable, KrustyNumber, KrustyNumberFormat, KrustyObject, KrustyOptional, KrustyPipe, KrustyPrefault, KrustyPromise, KrustyReadonly, KrustyRecord, KrustySet, KrustyString, KrustyStringFormat, KrustySuccess, KrustySymbol, KrustyTemplateLiteral, KrustyTransform, KrustyTuple, KrustyType, KrustyULID, KrustyURL, KrustyUUID, KrustyUndefined, KrustyUnion, KrustyUnknown, KrustyVoid, KrustyXID, SchemaClass, ZodError, ZodRealError, _KrustyString, _default, _function, any, array, base64, base64url, bigint, boolean, _catch as catch, check, cidrv4, cidrv6, codec, cuid, cuid2, custom, date, datetime, 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, promise, readonly, record, refine, 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 };
|