@temporary-name/zod 1.9.3-alpha.03f5d40e5b399f85012c2fb4e98167e26d551d36 → 1.9.3-alpha.0f2e1f4d66464608b85c66977bff51174cbb238f
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 +347 -359
- package/dist/index.d.ts +347 -359
- package/dist/index.mjs +561 -511
- package/package.json +4 -11
- 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,11 +351,30 @@ 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);
|
|
354
|
+
inst.describe = (description) => {
|
|
355
|
+
const cl = inst.clone();
|
|
356
|
+
core.globalRegistry.add(cl, { description });
|
|
357
|
+
return cl;
|
|
358
|
+
};
|
|
359
|
+
Object.defineProperty(inst, "description", {
|
|
360
|
+
get() {
|
|
361
|
+
return core.globalRegistry.get(inst)?.description;
|
|
362
|
+
},
|
|
363
|
+
configurable: true
|
|
364
|
+
});
|
|
365
|
+
inst.meta = (...args) => {
|
|
366
|
+
if (args.length === 0) {
|
|
367
|
+
return core.globalRegistry.get(inst);
|
|
368
|
+
}
|
|
369
|
+
const cl = inst.clone();
|
|
370
|
+
core.globalRegistry.add(cl, args[0]);
|
|
371
|
+
return cl;
|
|
372
|
+
};
|
|
421
373
|
return inst;
|
|
422
374
|
}
|
|
423
375
|
);
|
|
424
|
-
const
|
|
425
|
-
"
|
|
376
|
+
const _KrustyString = /* @__PURE__ */ core.$constructor(
|
|
377
|
+
"_KrustyString",
|
|
426
378
|
(inst, def) => {
|
|
427
379
|
const coreInit = core.$ZodString.init;
|
|
428
380
|
coreInit(inst, def);
|
|
@@ -447,270 +399,296 @@ const _ZodString = /* @__PURE__ */ core.$constructor(
|
|
|
447
399
|
inst.toUpperCase = () => inst.check(_toUpperCase());
|
|
448
400
|
}
|
|
449
401
|
);
|
|
450
|
-
const
|
|
451
|
-
"
|
|
402
|
+
const KrustyString = /* @__PURE__ */ core.$constructor(
|
|
403
|
+
"KrustyString",
|
|
452
404
|
(inst, def) => {
|
|
453
405
|
const coreInit = core.$ZodString.init;
|
|
454
406
|
coreInit(inst, def);
|
|
455
|
-
|
|
456
|
-
inst.email = (params) => inst.check(core._email(
|
|
457
|
-
inst.url = (params) => inst.check(core._url(
|
|
458
|
-
inst.jwt = (params) => inst.check(core._jwt(
|
|
459
|
-
inst.emoji = (params) => inst.check(core._emoji(
|
|
460
|
-
inst.guid = (params) => inst.check(core._guid(
|
|
461
|
-
inst.uuid = (params) => inst.check(core._uuid(
|
|
462
|
-
inst.uuidv4 = (params) => inst.check(core._uuidv4(
|
|
463
|
-
inst.uuidv6 = (params) => inst.check(core._uuidv6(
|
|
464
|
-
inst.uuidv7 = (params) => inst.check(core._uuidv7(
|
|
465
|
-
inst.nanoid = (params) => inst.check(core._nanoid(
|
|
466
|
-
inst.guid = (params) => inst.check(core._guid(
|
|
467
|
-
inst.cuid = (params) => inst.check(core._cuid(
|
|
468
|
-
inst.cuid2 = (params) => inst.check(core._cuid2(
|
|
469
|
-
inst.ulid = (params) => inst.check(core._ulid(
|
|
470
|
-
inst.base64 = (params) => inst.check(core._base64(
|
|
471
|
-
inst.base64url = (params) => inst.check(core._base64url(
|
|
472
|
-
inst.xid = (params) => inst.check(core._xid(
|
|
473
|
-
inst.ksuid = (params) => inst.check(core._ksuid(
|
|
474
|
-
inst.ipv4 = (params) => inst.check(core._ipv4(
|
|
475
|
-
inst.ipv6 = (params) => inst.check(core._ipv6(
|
|
476
|
-
inst.cidrv4 = (params) => inst.check(core._cidrv4(
|
|
477
|
-
inst.cidrv6 = (params) => inst.check(core._cidrv6(
|
|
478
|
-
inst.e164 = (params) => inst.check(core._e164(
|
|
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));
|
|
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));
|
|
483
431
|
}
|
|
484
432
|
);
|
|
485
433
|
function string(params) {
|
|
486
|
-
return core._string(
|
|
434
|
+
return core._string(KrustyString, params);
|
|
487
435
|
}
|
|
488
|
-
const
|
|
489
|
-
"
|
|
436
|
+
const KrustyStringFormat = /* @__PURE__ */ core.$constructor(
|
|
437
|
+
"KrustyStringFormat",
|
|
490
438
|
(inst, def) => {
|
|
491
439
|
const coreInit = core.$ZodStringFormat.init;
|
|
492
440
|
coreInit(inst, def);
|
|
493
|
-
|
|
441
|
+
_KrustyString.init(inst, def);
|
|
494
442
|
}
|
|
495
443
|
);
|
|
496
|
-
const
|
|
497
|
-
"
|
|
444
|
+
const KrustyEmail = /* @__PURE__ */ core.$constructor(
|
|
445
|
+
"KrustyEmail",
|
|
498
446
|
(inst, def) => {
|
|
499
447
|
const coreInit = core.$ZodEmail.init;
|
|
500
448
|
coreInit(inst, def);
|
|
501
|
-
|
|
449
|
+
KrustyStringFormat.init(inst, def);
|
|
502
450
|
}
|
|
503
451
|
);
|
|
504
452
|
function email(params) {
|
|
505
|
-
return core._email(
|
|
453
|
+
return core._email(KrustyEmail, params);
|
|
506
454
|
}
|
|
507
|
-
const
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
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
|
+
);
|
|
512
463
|
function guid(params) {
|
|
513
|
-
return core._guid(
|
|
464
|
+
return core._guid(KrustyGUID, params);
|
|
514
465
|
}
|
|
515
|
-
const
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
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
|
+
);
|
|
520
474
|
function uuid(params) {
|
|
521
|
-
return core._uuid(
|
|
475
|
+
return core._uuid(KrustyUUID, params);
|
|
522
476
|
}
|
|
523
477
|
function uuidv4(params) {
|
|
524
|
-
return core._uuidv4(
|
|
478
|
+
return core._uuidv4(KrustyUUID, params);
|
|
525
479
|
}
|
|
526
480
|
function uuidv6(params) {
|
|
527
|
-
return core._uuidv6(
|
|
481
|
+
return core._uuidv6(KrustyUUID, params);
|
|
528
482
|
}
|
|
529
483
|
function uuidv7(params) {
|
|
530
|
-
return core._uuidv7(
|
|
484
|
+
return core._uuidv7(KrustyUUID, params);
|
|
531
485
|
}
|
|
532
|
-
const
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
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
|
+
);
|
|
537
494
|
function url(params) {
|
|
538
|
-
return core._url(
|
|
495
|
+
return core._url(KrustyURL, params);
|
|
539
496
|
}
|
|
540
497
|
function httpUrl(params) {
|
|
541
|
-
return core._url(
|
|
498
|
+
return core._url(KrustyURL, {
|
|
542
499
|
protocol: /^https?$/,
|
|
543
500
|
hostname: core.regexes.domain,
|
|
544
501
|
...util.normalizeParams(params)
|
|
545
502
|
});
|
|
546
503
|
}
|
|
547
|
-
const
|
|
548
|
-
"
|
|
504
|
+
const KrustyEmoji = /* @__PURE__ */ core.$constructor(
|
|
505
|
+
"KrustyEmoji",
|
|
549
506
|
(inst, def) => {
|
|
550
507
|
const coreInit = core.$ZodEmoji.init;
|
|
551
508
|
coreInit(inst, def);
|
|
552
|
-
|
|
509
|
+
KrustyStringFormat.init(inst, def);
|
|
553
510
|
}
|
|
554
511
|
);
|
|
555
512
|
function emoji(params) {
|
|
556
|
-
return core._emoji(
|
|
513
|
+
return core._emoji(KrustyEmoji, params);
|
|
557
514
|
}
|
|
558
|
-
const
|
|
559
|
-
"
|
|
515
|
+
const KrustyNanoID = /* @__PURE__ */ core.$constructor(
|
|
516
|
+
"KrustyNanoID",
|
|
560
517
|
(inst, def) => {
|
|
561
518
|
const coreInit = core.$ZodNanoID.init;
|
|
562
519
|
coreInit(inst, def);
|
|
563
|
-
|
|
520
|
+
KrustyStringFormat.init(inst, def);
|
|
564
521
|
}
|
|
565
522
|
);
|
|
566
523
|
function nanoid(params) {
|
|
567
|
-
return core._nanoid(
|
|
524
|
+
return core._nanoid(KrustyNanoID, params);
|
|
568
525
|
}
|
|
569
|
-
const
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
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
|
+
);
|
|
574
534
|
function cuid(params) {
|
|
575
|
-
return core._cuid(
|
|
535
|
+
return core._cuid(KrustyCUID, params);
|
|
576
536
|
}
|
|
577
|
-
const
|
|
578
|
-
"
|
|
537
|
+
const KrustyCUID2 = /* @__PURE__ */ core.$constructor(
|
|
538
|
+
"KrustyCUID2",
|
|
579
539
|
(inst, def) => {
|
|
580
540
|
const coreInit = core.$ZodCUID2.init;
|
|
581
541
|
coreInit(inst, def);
|
|
582
|
-
|
|
542
|
+
KrustyStringFormat.init(inst, def);
|
|
583
543
|
}
|
|
584
544
|
);
|
|
585
545
|
function cuid2(params) {
|
|
586
|
-
return core._cuid2(
|
|
546
|
+
return core._cuid2(KrustyCUID2, params);
|
|
587
547
|
}
|
|
588
|
-
const
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
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
|
+
);
|
|
593
556
|
function ulid(params) {
|
|
594
|
-
return core._ulid(
|
|
557
|
+
return core._ulid(KrustyULID, params);
|
|
595
558
|
}
|
|
596
|
-
const
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
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
|
+
);
|
|
601
567
|
function xid(params) {
|
|
602
|
-
return core._xid(
|
|
568
|
+
return core._xid(KrustyXID, params);
|
|
603
569
|
}
|
|
604
|
-
const
|
|
605
|
-
"
|
|
570
|
+
const KrustyKSUID = /* @__PURE__ */ core.$constructor(
|
|
571
|
+
"KrustyKSUID",
|
|
606
572
|
(inst, def) => {
|
|
607
573
|
const coreInit = core.$ZodKSUID.init;
|
|
608
574
|
coreInit(inst, def);
|
|
609
|
-
|
|
575
|
+
KrustyStringFormat.init(inst, def);
|
|
610
576
|
}
|
|
611
577
|
);
|
|
612
578
|
function ksuid(params) {
|
|
613
|
-
return core._ksuid(
|
|
579
|
+
return core._ksuid(KrustyKSUID, params);
|
|
614
580
|
}
|
|
615
|
-
const
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
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
|
+
);
|
|
620
589
|
function ipv4(params) {
|
|
621
|
-
return core._ipv4(
|
|
590
|
+
return core._ipv4(KrustyIPv4, params);
|
|
622
591
|
}
|
|
623
|
-
const
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
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
|
+
);
|
|
628
600
|
function ipv6(params) {
|
|
629
|
-
return core._ipv6(
|
|
601
|
+
return core._ipv6(KrustyIPv6, params);
|
|
630
602
|
}
|
|
631
|
-
const
|
|
632
|
-
"
|
|
603
|
+
const KrustyCIDRv4 = /* @__PURE__ */ core.$constructor(
|
|
604
|
+
"KrustyCIDRv4",
|
|
633
605
|
(inst, def) => {
|
|
634
606
|
const coreInit = core.$ZodCIDRv4.init;
|
|
635
607
|
coreInit(inst, def);
|
|
636
|
-
|
|
608
|
+
KrustyStringFormat.init(inst, def);
|
|
637
609
|
}
|
|
638
610
|
);
|
|
639
611
|
function cidrv4(params) {
|
|
640
|
-
return core._cidrv4(
|
|
612
|
+
return core._cidrv4(KrustyCIDRv4, params);
|
|
641
613
|
}
|
|
642
|
-
const
|
|
643
|
-
"
|
|
614
|
+
const KrustyCIDRv6 = /* @__PURE__ */ core.$constructor(
|
|
615
|
+
"KrustyCIDRv6",
|
|
644
616
|
(inst, def) => {
|
|
645
617
|
const coreInit = core.$ZodCIDRv6.init;
|
|
646
618
|
coreInit(inst, def);
|
|
647
|
-
|
|
619
|
+
KrustyStringFormat.init(inst, def);
|
|
648
620
|
}
|
|
649
621
|
);
|
|
650
622
|
function cidrv6(params) {
|
|
651
|
-
return core._cidrv6(
|
|
623
|
+
return core._cidrv6(KrustyCIDRv6, params);
|
|
652
624
|
}
|
|
653
|
-
const
|
|
654
|
-
"
|
|
625
|
+
const KrustyBase64 = /* @__PURE__ */ core.$constructor(
|
|
626
|
+
"KrustyBase64",
|
|
655
627
|
(inst, def) => {
|
|
656
628
|
const coreInit = core.$ZodBase64.init;
|
|
657
629
|
coreInit(inst, def);
|
|
658
|
-
|
|
630
|
+
KrustyStringFormat.init(inst, def);
|
|
659
631
|
}
|
|
660
632
|
);
|
|
661
633
|
function base64(params) {
|
|
662
|
-
return core._base64(
|
|
634
|
+
return core._base64(KrustyBase64, params);
|
|
663
635
|
}
|
|
664
|
-
const
|
|
665
|
-
"
|
|
636
|
+
const KrustyBase64URL = /* @__PURE__ */ core.$constructor(
|
|
637
|
+
"KrustyBase64URL",
|
|
666
638
|
(inst, def) => {
|
|
667
639
|
const coreInit = core.$ZodBase64URL.init;
|
|
668
640
|
coreInit(inst, def);
|
|
669
|
-
|
|
641
|
+
KrustyStringFormat.init(inst, def);
|
|
670
642
|
}
|
|
671
643
|
);
|
|
672
644
|
function base64url(params) {
|
|
673
|
-
return core._base64url(
|
|
645
|
+
return core._base64url(KrustyBase64URL, params);
|
|
674
646
|
}
|
|
675
|
-
const
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
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
|
+
);
|
|
680
655
|
function e164(params) {
|
|
681
|
-
return core._e164(
|
|
656
|
+
return core._e164(KrustyE164, params);
|
|
682
657
|
}
|
|
683
|
-
const
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
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
|
+
);
|
|
688
666
|
function jwt(params) {
|
|
689
|
-
return core._jwt(
|
|
667
|
+
return core._jwt(KrustyJWT, params);
|
|
690
668
|
}
|
|
691
|
-
const
|
|
669
|
+
const KrustyCustomStringFormat = /* @__PURE__ */ core.$constructor("KrustyCustomStringFormat", (inst, def) => {
|
|
692
670
|
const coreInit = core.$ZodCustomStringFormat.init;
|
|
693
671
|
coreInit(inst, def);
|
|
694
|
-
|
|
672
|
+
KrustyStringFormat.init(inst, def);
|
|
695
673
|
});
|
|
696
674
|
function stringFormat(format, fnOrRegex, _params = {}) {
|
|
697
|
-
return core._stringFormat(
|
|
675
|
+
return core._stringFormat(KrustyCustomStringFormat, format, fnOrRegex, _params);
|
|
698
676
|
}
|
|
699
677
|
function hostname(_params) {
|
|
700
|
-
return core._stringFormat(
|
|
678
|
+
return core._stringFormat(KrustyCustomStringFormat, "hostname", core.regexes.hostname, _params);
|
|
701
679
|
}
|
|
702
680
|
function hex(_params) {
|
|
703
|
-
return core._stringFormat(
|
|
681
|
+
return core._stringFormat(KrustyCustomStringFormat, "hex", core.regexes.hex, _params);
|
|
704
682
|
}
|
|
705
683
|
function hash(alg, params) {
|
|
706
684
|
const enc = params?.enc ?? "hex";
|
|
707
685
|
const format = `${alg}_${enc}`;
|
|
708
686
|
const regex = core.regexes[format];
|
|
709
687
|
if (!regex) throw new Error(`Unrecognized hash format: ${format}`);
|
|
710
|
-
return core._stringFormat(
|
|
688
|
+
return core._stringFormat(KrustyCustomStringFormat, format, regex, params);
|
|
711
689
|
}
|
|
712
|
-
const
|
|
713
|
-
"
|
|
690
|
+
const KrustyNumber = /* @__PURE__ */ core.$constructor(
|
|
691
|
+
"KrustyNumber",
|
|
714
692
|
(inst, def) => {
|
|
715
693
|
const coreInit = core.$ZodNumber.init;
|
|
716
694
|
coreInit(inst, def);
|
|
@@ -722,7 +700,6 @@ const ZodNumber = /* @__PURE__ */ core.$constructor(
|
|
|
722
700
|
inst.lte = (value, params) => inst.check(_lte(value, params));
|
|
723
701
|
inst.max = (value, params) => inst.check(_lte(value, params));
|
|
724
702
|
inst.int = (params) => inst.check(int(params));
|
|
725
|
-
inst.safe = (params) => inst.check(int(params));
|
|
726
703
|
inst.positive = (params) => inst.check(_gt(0, params));
|
|
727
704
|
inst.nonnegative = (params) => inst.check(_gte(0, params));
|
|
728
705
|
inst.negative = (params) => inst.check(_lt(0, params));
|
|
@@ -736,47 +713,80 @@ const ZodNumber = /* @__PURE__ */ core.$constructor(
|
|
|
736
713
|
inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? 0.5);
|
|
737
714
|
inst.isFinite = true;
|
|
738
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
|
+
};
|
|
739
727
|
}
|
|
740
728
|
);
|
|
741
729
|
function number(params) {
|
|
742
|
-
return core._number(
|
|
730
|
+
return core._number(KrustyNumber, params);
|
|
743
731
|
}
|
|
744
|
-
const
|
|
745
|
-
"
|
|
732
|
+
const KrustyNumberFormat = /* @__PURE__ */ core.$constructor(
|
|
733
|
+
"KrustyNumberFormat",
|
|
746
734
|
(inst, def) => {
|
|
747
735
|
const coreInit = core.$ZodNumberFormat.init;
|
|
748
736
|
coreInit(inst, def);
|
|
749
|
-
|
|
737
|
+
KrustyNumber.init(inst, def);
|
|
750
738
|
}
|
|
751
739
|
);
|
|
752
740
|
function int(params) {
|
|
753
|
-
return core._int(
|
|
741
|
+
return core._int(KrustyNumberFormat, params);
|
|
754
742
|
}
|
|
755
743
|
function float32(params) {
|
|
756
|
-
return core._float32(
|
|
744
|
+
return core._float32(KrustyNumberFormat, params);
|
|
757
745
|
}
|
|
758
746
|
function float64(params) {
|
|
759
|
-
return core._float64(
|
|
747
|
+
return core._float64(KrustyNumberFormat, params);
|
|
760
748
|
}
|
|
761
749
|
function int32(params) {
|
|
762
|
-
return core._int32(
|
|
750
|
+
return core._int32(KrustyNumberFormat, params);
|
|
763
751
|
}
|
|
764
752
|
function uint32(params) {
|
|
765
|
-
return core._uint32(
|
|
753
|
+
return core._uint32(KrustyNumberFormat, params);
|
|
766
754
|
}
|
|
767
|
-
const
|
|
768
|
-
"
|
|
755
|
+
const KrustyBoolean = /* @__PURE__ */ core.$constructor(
|
|
756
|
+
"KrustyBoolean",
|
|
769
757
|
(inst, def) => {
|
|
770
758
|
const coreInit = core.$ZodBoolean.init;
|
|
771
759
|
coreInit(inst, def);
|
|
772
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
|
+
};
|
|
773
783
|
}
|
|
774
784
|
);
|
|
775
785
|
function boolean(params) {
|
|
776
|
-
return core._boolean(
|
|
786
|
+
return core._boolean(KrustyBoolean, params);
|
|
777
787
|
}
|
|
778
|
-
const
|
|
779
|
-
"
|
|
788
|
+
const KrustyBigInt = /* @__PURE__ */ core.$constructor(
|
|
789
|
+
"KrustyBigInt",
|
|
780
790
|
(inst, def) => {
|
|
781
791
|
const coreInit = core.$ZodBigInt.init;
|
|
782
792
|
coreInit(inst, def);
|
|
@@ -801,24 +811,24 @@ const ZodBigInt = /* @__PURE__ */ core.$constructor(
|
|
|
801
811
|
}
|
|
802
812
|
);
|
|
803
813
|
function bigint(params) {
|
|
804
|
-
return core._bigint(
|
|
814
|
+
return core._bigint(KrustyBigInt, params);
|
|
805
815
|
}
|
|
806
|
-
const
|
|
807
|
-
"
|
|
816
|
+
const KrustyBigIntFormat = /* @__PURE__ */ core.$constructor(
|
|
817
|
+
"KrustyBigIntFormat",
|
|
808
818
|
(inst, def) => {
|
|
809
819
|
const coreInit = core.$ZodBigIntFormat.init;
|
|
810
820
|
coreInit(inst, def);
|
|
811
|
-
|
|
821
|
+
KrustyBigInt.init(inst, def);
|
|
812
822
|
}
|
|
813
823
|
);
|
|
814
824
|
function int64(params) {
|
|
815
|
-
return core._int64(
|
|
825
|
+
return core._int64(KrustyBigIntFormat, params);
|
|
816
826
|
}
|
|
817
827
|
function uint64(params) {
|
|
818
|
-
return core._uint64(
|
|
828
|
+
return core._uint64(KrustyBigIntFormat, params);
|
|
819
829
|
}
|
|
820
|
-
const
|
|
821
|
-
"
|
|
830
|
+
const KrustySymbol = /* @__PURE__ */ core.$constructor(
|
|
831
|
+
"KrustySymbol",
|
|
822
832
|
(inst, def) => {
|
|
823
833
|
const coreInit = core.$ZodSymbol.init;
|
|
824
834
|
coreInit(inst, def);
|
|
@@ -826,10 +836,10 @@ const ZodSymbol = /* @__PURE__ */ core.$constructor(
|
|
|
826
836
|
}
|
|
827
837
|
);
|
|
828
838
|
function symbol(params) {
|
|
829
|
-
return core._symbol(
|
|
839
|
+
return core._symbol(KrustySymbol, params);
|
|
830
840
|
}
|
|
831
|
-
const
|
|
832
|
-
"
|
|
841
|
+
const KrustyUndefined = /* @__PURE__ */ core.$constructor(
|
|
842
|
+
"KrustyUndefined",
|
|
833
843
|
(inst, def) => {
|
|
834
844
|
const coreInit = core.$ZodUndefined.init;
|
|
835
845
|
coreInit(inst, def);
|
|
@@ -837,26 +847,32 @@ const ZodUndefined = /* @__PURE__ */ core.$constructor(
|
|
|
837
847
|
}
|
|
838
848
|
);
|
|
839
849
|
function _undefined(params) {
|
|
840
|
-
return core._undefined(
|
|
850
|
+
return core._undefined(KrustyUndefined, params);
|
|
841
851
|
}
|
|
842
|
-
const
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
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
|
+
);
|
|
847
860
|
function _null(params) {
|
|
848
|
-
return core._null(
|
|
861
|
+
return core._null(KrustyNull, params);
|
|
849
862
|
}
|
|
850
|
-
const
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
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
|
+
);
|
|
855
871
|
function any() {
|
|
856
|
-
return core._any(
|
|
872
|
+
return core._any(KrustyAny);
|
|
857
873
|
}
|
|
858
|
-
const
|
|
859
|
-
"
|
|
874
|
+
const KrustyUnknown = /* @__PURE__ */ core.$constructor(
|
|
875
|
+
"KrustyUnknown",
|
|
860
876
|
(inst, def) => {
|
|
861
877
|
const coreInit = core.$ZodUnknown.init;
|
|
862
878
|
coreInit(inst, def);
|
|
@@ -864,10 +880,10 @@ const ZodUnknown = /* @__PURE__ */ core.$constructor(
|
|
|
864
880
|
}
|
|
865
881
|
);
|
|
866
882
|
function unknown() {
|
|
867
|
-
return core._unknown(
|
|
883
|
+
return core._unknown(KrustyUnknown);
|
|
868
884
|
}
|
|
869
|
-
const
|
|
870
|
-
"
|
|
885
|
+
const KrustyNever = /* @__PURE__ */ core.$constructor(
|
|
886
|
+
"KrustyNever",
|
|
871
887
|
(inst, def) => {
|
|
872
888
|
const coreInit = core.$ZodNever.init;
|
|
873
889
|
coreInit(inst, def);
|
|
@@ -875,31 +891,49 @@ const ZodNever = /* @__PURE__ */ core.$constructor(
|
|
|
875
891
|
}
|
|
876
892
|
);
|
|
877
893
|
function never(params) {
|
|
878
|
-
return core._never(
|
|
894
|
+
return core._never(KrustyNever, params);
|
|
879
895
|
}
|
|
880
|
-
const
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
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
|
+
);
|
|
885
904
|
function _void(params) {
|
|
886
|
-
return core._void(
|
|
905
|
+
return core._void(KrustyVoid, params);
|
|
887
906
|
}
|
|
888
|
-
const
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
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
|
+
);
|
|
898
920
|
function date(params) {
|
|
899
|
-
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
|
+
});
|
|
900
928
|
}
|
|
901
|
-
|
|
902
|
-
|
|
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
|
+
});
|
|
934
|
+
}
|
|
935
|
+
const KrustyArray = /* @__PURE__ */ core.$constructor(
|
|
936
|
+
"KrustyArray",
|
|
903
937
|
(inst, def) => {
|
|
904
938
|
const coreInit = core.$ZodArray.init;
|
|
905
939
|
coreInit(inst, def);
|
|
@@ -913,14 +947,14 @@ const ZodArray = /* @__PURE__ */ core.$constructor(
|
|
|
913
947
|
}
|
|
914
948
|
);
|
|
915
949
|
function array(element, params) {
|
|
916
|
-
return core._array(
|
|
950
|
+
return core._array(KrustyArray, element, params);
|
|
917
951
|
}
|
|
918
952
|
function keyof(schema) {
|
|
919
953
|
const shape = schema._zod.def.shape;
|
|
920
954
|
return _enum(Object.keys(shape));
|
|
921
955
|
}
|
|
922
|
-
const
|
|
923
|
-
"
|
|
956
|
+
const KrustyIntersection = /* @__PURE__ */ core.$constructor(
|
|
957
|
+
"KrustyIntersection",
|
|
924
958
|
(inst, def) => {
|
|
925
959
|
const coreInit = core.$ZodIntersection.init;
|
|
926
960
|
coreInit(inst, def);
|
|
@@ -928,14 +962,14 @@ const ZodIntersection = /* @__PURE__ */ core.$constructor(
|
|
|
928
962
|
}
|
|
929
963
|
);
|
|
930
964
|
function intersection(left, right) {
|
|
931
|
-
return new
|
|
965
|
+
return new KrustyIntersection({
|
|
932
966
|
type: "intersection",
|
|
933
967
|
left,
|
|
934
968
|
right
|
|
935
969
|
});
|
|
936
970
|
}
|
|
937
|
-
const
|
|
938
|
-
"
|
|
971
|
+
const KrustyTuple = /* @__PURE__ */ core.$constructor(
|
|
972
|
+
"KrustyTuple",
|
|
939
973
|
(inst, def) => {
|
|
940
974
|
const coreInit = core.$ZodTuple.init;
|
|
941
975
|
coreInit(inst, def);
|
|
@@ -950,15 +984,15 @@ function tuple(items, _paramsOrRest, _params) {
|
|
|
950
984
|
const hasRest = _paramsOrRest instanceof core.$ZodType;
|
|
951
985
|
const params = hasRest ? _params : _paramsOrRest;
|
|
952
986
|
const rest = hasRest ? _paramsOrRest : null;
|
|
953
|
-
return new
|
|
987
|
+
return new KrustyTuple({
|
|
954
988
|
type: "tuple",
|
|
955
989
|
items,
|
|
956
990
|
rest,
|
|
957
991
|
...util.normalizeParams(params)
|
|
958
992
|
});
|
|
959
993
|
}
|
|
960
|
-
const
|
|
961
|
-
"
|
|
994
|
+
const KrustyRecord = /* @__PURE__ */ core.$constructor(
|
|
995
|
+
"KrustyRecord",
|
|
962
996
|
(inst, def) => {
|
|
963
997
|
const coreInit = core.$ZodRecord.init;
|
|
964
998
|
coreInit(inst, def);
|
|
@@ -968,7 +1002,7 @@ const ZodRecord = /* @__PURE__ */ core.$constructor(
|
|
|
968
1002
|
}
|
|
969
1003
|
);
|
|
970
1004
|
function record(keyType, valueType, params) {
|
|
971
|
-
return new
|
|
1005
|
+
return new KrustyRecord({
|
|
972
1006
|
type: "record",
|
|
973
1007
|
keyType,
|
|
974
1008
|
valueType,
|
|
@@ -978,97 +1012,106 @@ function record(keyType, valueType, params) {
|
|
|
978
1012
|
function partialRecord(keyType, valueType, params) {
|
|
979
1013
|
const k = core.clone(keyType);
|
|
980
1014
|
k._zod.values = void 0;
|
|
981
|
-
return new
|
|
1015
|
+
return new KrustyRecord({
|
|
982
1016
|
type: "record",
|
|
983
1017
|
keyType: k,
|
|
984
1018
|
valueType,
|
|
985
1019
|
...util.normalizeParams(params)
|
|
986
1020
|
});
|
|
987
1021
|
}
|
|
988
|
-
const
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
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
|
+
);
|
|
995
1032
|
function map(keyType, valueType, params) {
|
|
996
|
-
return new
|
|
1033
|
+
return new KrustyMap({
|
|
997
1034
|
type: "map",
|
|
998
1035
|
keyType,
|
|
999
1036
|
valueType,
|
|
1000
1037
|
...util.normalizeParams(params)
|
|
1001
1038
|
});
|
|
1002
1039
|
}
|
|
1003
|
-
const
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
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
|
+
);
|
|
1012
1052
|
function set(valueType, params) {
|
|
1013
|
-
return new
|
|
1053
|
+
return new KrustySet({
|
|
1014
1054
|
type: "set",
|
|
1015
1055
|
valueType,
|
|
1016
1056
|
...util.normalizeParams(params)
|
|
1017
1057
|
});
|
|
1018
1058
|
}
|
|
1019
|
-
const
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
const
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
});
|
|
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
|
+
);
|
|
1055
1098
|
function _enum(values, params) {
|
|
1056
1099
|
const entries = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
|
|
1057
|
-
return new
|
|
1100
|
+
return new KrustyEnum({
|
|
1058
1101
|
type: "enum",
|
|
1059
1102
|
entries,
|
|
1060
1103
|
...util.normalizeParams(params)
|
|
1061
1104
|
});
|
|
1062
1105
|
}
|
|
1063
1106
|
function nativeEnum(entries, params) {
|
|
1064
|
-
return new
|
|
1107
|
+
return new KrustyEnum({
|
|
1065
1108
|
type: "enum",
|
|
1066
1109
|
entries,
|
|
1067
1110
|
...util.normalizeParams(params)
|
|
1068
1111
|
});
|
|
1069
1112
|
}
|
|
1070
|
-
const
|
|
1071
|
-
"
|
|
1113
|
+
const KrustyLiteral = /* @__PURE__ */ core.$constructor(
|
|
1114
|
+
"KrustyLiteral",
|
|
1072
1115
|
(inst, def) => {
|
|
1073
1116
|
const coreInit = core.$ZodLiteral.init;
|
|
1074
1117
|
coreInit(inst, def);
|
|
@@ -1085,25 +1128,28 @@ const ZodLiteral = /* @__PURE__ */ core.$constructor(
|
|
|
1085
1128
|
}
|
|
1086
1129
|
);
|
|
1087
1130
|
function literal(value, params) {
|
|
1088
|
-
return new
|
|
1131
|
+
return new KrustyLiteral({
|
|
1089
1132
|
type: "literal",
|
|
1090
1133
|
values: Array.isArray(value) ? value : [value],
|
|
1091
1134
|
...util.normalizeParams(params)
|
|
1092
1135
|
});
|
|
1093
1136
|
}
|
|
1094
|
-
const
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
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
|
+
);
|
|
1102
1148
|
function file(params) {
|
|
1103
|
-
return core._file(
|
|
1149
|
+
return core._file(KrustyFile, params);
|
|
1104
1150
|
}
|
|
1105
|
-
const
|
|
1106
|
-
"
|
|
1151
|
+
const KrustyTransform = /* @__PURE__ */ core.$constructor(
|
|
1152
|
+
"KrustyTransform",
|
|
1107
1153
|
(inst, def) => {
|
|
1108
1154
|
const coreInit = core.$ZodTransform.init;
|
|
1109
1155
|
coreInit(inst, def);
|
|
@@ -1137,13 +1183,13 @@ const ZodTransform = /* @__PURE__ */ core.$constructor(
|
|
|
1137
1183
|
}
|
|
1138
1184
|
);
|
|
1139
1185
|
function transform(fn) {
|
|
1140
|
-
return new
|
|
1186
|
+
return new KrustyTransform({
|
|
1141
1187
|
type: "transform",
|
|
1142
1188
|
transform: fn
|
|
1143
1189
|
});
|
|
1144
1190
|
}
|
|
1145
|
-
const
|
|
1146
|
-
"
|
|
1191
|
+
const KrustyOptional = /* @__PURE__ */ core.$constructor(
|
|
1192
|
+
"KrustyOptional",
|
|
1147
1193
|
(inst, def) => {
|
|
1148
1194
|
const coreInit = core.$ZodOptional.init;
|
|
1149
1195
|
coreInit(inst, def);
|
|
@@ -1152,13 +1198,13 @@ const ZodOptional = /* @__PURE__ */ core.$constructor(
|
|
|
1152
1198
|
}
|
|
1153
1199
|
);
|
|
1154
1200
|
function optional(innerType) {
|
|
1155
|
-
return new
|
|
1201
|
+
return new KrustyOptional({
|
|
1156
1202
|
type: "optional",
|
|
1157
1203
|
innerType
|
|
1158
1204
|
});
|
|
1159
1205
|
}
|
|
1160
|
-
const
|
|
1161
|
-
"
|
|
1206
|
+
const KrustyNullable = /* @__PURE__ */ core.$constructor(
|
|
1207
|
+
"KrustyNullable",
|
|
1162
1208
|
(inst, def) => {
|
|
1163
1209
|
const coreInit = core.$ZodNullable.init;
|
|
1164
1210
|
coreInit(inst, def);
|
|
@@ -1167,7 +1213,7 @@ const ZodNullable = /* @__PURE__ */ core.$constructor(
|
|
|
1167
1213
|
}
|
|
1168
1214
|
);
|
|
1169
1215
|
function nullable(innerType) {
|
|
1170
|
-
return new
|
|
1216
|
+
return new KrustyNullable({
|
|
1171
1217
|
type: "nullable",
|
|
1172
1218
|
innerType
|
|
1173
1219
|
});
|
|
@@ -1175,8 +1221,8 @@ function nullable(innerType) {
|
|
|
1175
1221
|
function nullish(innerType) {
|
|
1176
1222
|
return optional(nullable(innerType));
|
|
1177
1223
|
}
|
|
1178
|
-
const
|
|
1179
|
-
"
|
|
1224
|
+
const KrustyDefault = /* @__PURE__ */ core.$constructor(
|
|
1225
|
+
"KrustyDefault",
|
|
1180
1226
|
(inst, def) => {
|
|
1181
1227
|
const coreInit = core.$ZodDefault.init;
|
|
1182
1228
|
coreInit(inst, def);
|
|
@@ -1186,7 +1232,7 @@ const ZodDefault = /* @__PURE__ */ core.$constructor(
|
|
|
1186
1232
|
}
|
|
1187
1233
|
);
|
|
1188
1234
|
function _default(innerType, defaultValue) {
|
|
1189
|
-
return new
|
|
1235
|
+
return new KrustyDefault({
|
|
1190
1236
|
type: "default",
|
|
1191
1237
|
innerType,
|
|
1192
1238
|
get defaultValue() {
|
|
@@ -1194,8 +1240,8 @@ function _default(innerType, defaultValue) {
|
|
|
1194
1240
|
}
|
|
1195
1241
|
});
|
|
1196
1242
|
}
|
|
1197
|
-
const
|
|
1198
|
-
"
|
|
1243
|
+
const KrustyPrefault = /* @__PURE__ */ core.$constructor(
|
|
1244
|
+
"KrustyPrefault",
|
|
1199
1245
|
(inst, def) => {
|
|
1200
1246
|
const coreInit = core.$ZodPrefault.init;
|
|
1201
1247
|
coreInit(inst, def);
|
|
@@ -1204,7 +1250,7 @@ const ZodPrefault = /* @__PURE__ */ core.$constructor(
|
|
|
1204
1250
|
}
|
|
1205
1251
|
);
|
|
1206
1252
|
function prefault(innerType, defaultValue) {
|
|
1207
|
-
return new
|
|
1253
|
+
return new KrustyPrefault({
|
|
1208
1254
|
type: "prefault",
|
|
1209
1255
|
innerType,
|
|
1210
1256
|
get defaultValue() {
|
|
@@ -1212,8 +1258,8 @@ function prefault(innerType, defaultValue) {
|
|
|
1212
1258
|
}
|
|
1213
1259
|
});
|
|
1214
1260
|
}
|
|
1215
|
-
const
|
|
1216
|
-
"
|
|
1261
|
+
const KrustyNonOptional = /* @__PURE__ */ core.$constructor(
|
|
1262
|
+
"KrustyNonOptional",
|
|
1217
1263
|
(inst, def) => {
|
|
1218
1264
|
const coreInit = core.$ZodNonOptional.init;
|
|
1219
1265
|
coreInit(inst, def);
|
|
@@ -1222,14 +1268,14 @@ const ZodNonOptional = /* @__PURE__ */ core.$constructor(
|
|
|
1222
1268
|
}
|
|
1223
1269
|
);
|
|
1224
1270
|
function nonoptional(innerType, params) {
|
|
1225
|
-
return new
|
|
1271
|
+
return new KrustyNonOptional({
|
|
1226
1272
|
type: "nonoptional",
|
|
1227
1273
|
innerType,
|
|
1228
1274
|
...util.normalizeParams(params)
|
|
1229
1275
|
});
|
|
1230
1276
|
}
|
|
1231
|
-
const
|
|
1232
|
-
"
|
|
1277
|
+
const KrustySuccess = /* @__PURE__ */ core.$constructor(
|
|
1278
|
+
"KrustySuccess",
|
|
1233
1279
|
(inst, def) => {
|
|
1234
1280
|
const coreInit = core.$ZodSuccess.init;
|
|
1235
1281
|
coreInit(inst, def);
|
|
@@ -1238,13 +1284,13 @@ const ZodSuccess = /* @__PURE__ */ core.$constructor(
|
|
|
1238
1284
|
}
|
|
1239
1285
|
);
|
|
1240
1286
|
function success(innerType) {
|
|
1241
|
-
return new
|
|
1287
|
+
return new KrustySuccess({
|
|
1242
1288
|
type: "success",
|
|
1243
1289
|
innerType
|
|
1244
1290
|
});
|
|
1245
1291
|
}
|
|
1246
|
-
const
|
|
1247
|
-
"
|
|
1292
|
+
const KrustyCatch = /* @__PURE__ */ core.$constructor(
|
|
1293
|
+
"KrustyCatch",
|
|
1248
1294
|
(inst, def) => {
|
|
1249
1295
|
const coreInit = core.$ZodCatch.init;
|
|
1250
1296
|
coreInit(inst, def);
|
|
@@ -1254,45 +1300,51 @@ const ZodCatch = /* @__PURE__ */ core.$constructor(
|
|
|
1254
1300
|
}
|
|
1255
1301
|
);
|
|
1256
1302
|
function _catch(innerType, catchValue) {
|
|
1257
|
-
return new
|
|
1303
|
+
return new KrustyCatch({
|
|
1258
1304
|
type: "catch",
|
|
1259
1305
|
innerType,
|
|
1260
1306
|
catchValue: typeof catchValue === "function" ? catchValue : () => catchValue
|
|
1261
1307
|
});
|
|
1262
1308
|
}
|
|
1263
|
-
const
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
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
|
+
);
|
|
1268
1317
|
function nan(params) {
|
|
1269
|
-
return core._nan(
|
|
1318
|
+
return core._nan(KrustyNaN, params);
|
|
1270
1319
|
}
|
|
1271
|
-
const
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
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
|
+
);
|
|
1278
1330
|
function pipe(in_, out) {
|
|
1279
|
-
return new
|
|
1331
|
+
return new KrustyPipe({
|
|
1280
1332
|
type: "pipe",
|
|
1281
1333
|
in: in_,
|
|
1282
1334
|
out
|
|
1283
1335
|
// ...util.normalizeParams(params),
|
|
1284
1336
|
});
|
|
1285
1337
|
}
|
|
1286
|
-
const
|
|
1287
|
-
"
|
|
1338
|
+
const KrustyCodec = /* @__PURE__ */ core.$constructor(
|
|
1339
|
+
"KrustyCodec",
|
|
1288
1340
|
(inst, def) => {
|
|
1289
|
-
|
|
1341
|
+
KrustyPipe.init(inst, def);
|
|
1290
1342
|
const coreInit = core.$ZodCodec.init;
|
|
1291
1343
|
coreInit(inst, def);
|
|
1292
1344
|
}
|
|
1293
1345
|
);
|
|
1294
1346
|
function codec(in_, out, params) {
|
|
1295
|
-
return new
|
|
1347
|
+
return new KrustyCodec({
|
|
1296
1348
|
type: "pipe",
|
|
1297
1349
|
in: in_,
|
|
1298
1350
|
out,
|
|
@@ -1300,8 +1352,8 @@ function codec(in_, out, params) {
|
|
|
1300
1352
|
reverseTransform: params.encode
|
|
1301
1353
|
});
|
|
1302
1354
|
}
|
|
1303
|
-
const
|
|
1304
|
-
"
|
|
1355
|
+
const KrustyReadonly = /* @__PURE__ */ core.$constructor(
|
|
1356
|
+
"KrustyReadonly",
|
|
1305
1357
|
(inst, def) => {
|
|
1306
1358
|
const coreInit = core.$ZodReadonly.init;
|
|
1307
1359
|
coreInit(inst, def);
|
|
@@ -1310,40 +1362,40 @@ const ZodReadonly = /* @__PURE__ */ core.$constructor(
|
|
|
1310
1362
|
}
|
|
1311
1363
|
);
|
|
1312
1364
|
function readonly(innerType) {
|
|
1313
|
-
return new
|
|
1365
|
+
return new KrustyReadonly({
|
|
1314
1366
|
type: "readonly",
|
|
1315
1367
|
innerType
|
|
1316
1368
|
});
|
|
1317
1369
|
}
|
|
1318
|
-
const
|
|
1319
|
-
|
|
1320
|
-
(inst, def)
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
KrustyType.init(inst, def);
|
|
1324
|
-
}
|
|
1325
|
-
);
|
|
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
|
+
});
|
|
1326
1375
|
function templateLiteral(parts, params) {
|
|
1327
|
-
return new
|
|
1376
|
+
return new KrustyTemplateLiteral({
|
|
1328
1377
|
type: "template_literal",
|
|
1329
1378
|
parts,
|
|
1330
1379
|
...util.normalizeParams(params)
|
|
1331
1380
|
});
|
|
1332
1381
|
}
|
|
1333
|
-
const
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
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
|
+
);
|
|
1339
1391
|
function lazy(getter) {
|
|
1340
|
-
return new
|
|
1392
|
+
return new KrustyLazy({
|
|
1341
1393
|
type: "lazy",
|
|
1342
1394
|
getter
|
|
1343
1395
|
});
|
|
1344
1396
|
}
|
|
1345
|
-
const
|
|
1346
|
-
"
|
|
1397
|
+
const KrustyPromise = /* @__PURE__ */ core.$constructor(
|
|
1398
|
+
"KrustyPromise",
|
|
1347
1399
|
(inst, def) => {
|
|
1348
1400
|
const coreInit = core.$ZodPromise.init;
|
|
1349
1401
|
coreInit(inst, def);
|
|
@@ -1352,13 +1404,13 @@ const ZodPromise = /* @__PURE__ */ core.$constructor(
|
|
|
1352
1404
|
}
|
|
1353
1405
|
);
|
|
1354
1406
|
function promise(innerType) {
|
|
1355
|
-
return new
|
|
1407
|
+
return new KrustyPromise({
|
|
1356
1408
|
type: "promise",
|
|
1357
1409
|
innerType
|
|
1358
1410
|
});
|
|
1359
1411
|
}
|
|
1360
|
-
const
|
|
1361
|
-
"
|
|
1412
|
+
const KrustyFunction = /* @__PURE__ */ core.$constructor(
|
|
1413
|
+
"KrustyFunction",
|
|
1362
1414
|
(inst, def) => {
|
|
1363
1415
|
const coreInit = core.$ZodFunction.init;
|
|
1364
1416
|
coreInit(inst, def);
|
|
@@ -1366,14 +1418,14 @@ const ZodFunction = /* @__PURE__ */ core.$constructor(
|
|
|
1366
1418
|
}
|
|
1367
1419
|
);
|
|
1368
1420
|
function _function(params) {
|
|
1369
|
-
return new
|
|
1421
|
+
return new KrustyFunction({
|
|
1370
1422
|
type: "function",
|
|
1371
1423
|
input: Array.isArray(params?.input) ? tuple(params?.input) : params?.input ?? array(unknown()),
|
|
1372
1424
|
output: params?.output ?? unknown()
|
|
1373
1425
|
});
|
|
1374
1426
|
}
|
|
1375
|
-
const
|
|
1376
|
-
"
|
|
1427
|
+
const KrustyCustom = /* @__PURE__ */ core.$constructor(
|
|
1428
|
+
"KrustyCustom",
|
|
1377
1429
|
(inst, def) => {
|
|
1378
1430
|
const coreInit = core.$ZodCustom.init;
|
|
1379
1431
|
coreInit(inst, def);
|
|
@@ -1389,10 +1441,10 @@ function check(fn) {
|
|
|
1389
1441
|
return ch;
|
|
1390
1442
|
}
|
|
1391
1443
|
function custom(fn, _params) {
|
|
1392
|
-
return core._custom(
|
|
1444
|
+
return core._custom(KrustyCustom, fn ?? (() => true), _params);
|
|
1393
1445
|
}
|
|
1394
1446
|
function refine(fn, _params = {}) {
|
|
1395
|
-
return core._refine(
|
|
1447
|
+
return core._refine(KrustyCustom, fn, _params);
|
|
1396
1448
|
}
|
|
1397
1449
|
function superRefine(fn) {
|
|
1398
1450
|
return core._superRefine(fn);
|
|
@@ -1400,7 +1452,7 @@ function superRefine(fn) {
|
|
|
1400
1452
|
function _instanceof(cls, params = {
|
|
1401
1453
|
error: `Input not instance of ${cls.name}`
|
|
1402
1454
|
}) {
|
|
1403
|
-
const inst = new
|
|
1455
|
+
const inst = new KrustyCustom({
|
|
1404
1456
|
type: "custom",
|
|
1405
1457
|
check: "custom",
|
|
1406
1458
|
fn: (data) => data instanceof cls,
|
|
@@ -1412,9 +1464,9 @@ function _instanceof(cls, params = {
|
|
|
1412
1464
|
}
|
|
1413
1465
|
const stringbool = (...args) => core._stringbool(
|
|
1414
1466
|
{
|
|
1415
|
-
Codec:
|
|
1416
|
-
Boolean:
|
|
1417
|
-
String:
|
|
1467
|
+
Codec: KrustyCodec,
|
|
1468
|
+
Boolean: KrustyBoolean,
|
|
1469
|
+
String: KrustyString
|
|
1418
1470
|
},
|
|
1419
1471
|
...args
|
|
1420
1472
|
);
|
|
@@ -1431,9 +1483,6 @@ function json(params) {
|
|
|
1431
1483
|
});
|
|
1432
1484
|
return jsonSchema;
|
|
1433
1485
|
}
|
|
1434
|
-
function preprocess(fn, schema) {
|
|
1435
|
-
return pipe(transform(fn), schema);
|
|
1436
|
-
}
|
|
1437
1486
|
|
|
1438
1487
|
class SchemaClass {
|
|
1439
1488
|
string(params) {
|
|
@@ -1466,10 +1515,12 @@ class SchemaClass {
|
|
|
1466
1515
|
object(shape, params) {
|
|
1467
1516
|
return object(shape, params);
|
|
1468
1517
|
}
|
|
1469
|
-
// TODO: make this a codec?
|
|
1470
1518
|
date(params) {
|
|
1471
1519
|
return date(params);
|
|
1472
1520
|
}
|
|
1521
|
+
datetime(params) {
|
|
1522
|
+
return datetime(params);
|
|
1523
|
+
}
|
|
1473
1524
|
any() {
|
|
1474
1525
|
return any();
|
|
1475
1526
|
}
|
|
@@ -1553,7 +1604,6 @@ class SchemaClass {
|
|
|
1553
1604
|
*/
|
|
1554
1605
|
/**
|
|
1555
1606
|
* TODO: decide what other helper methods to expose
|
|
1556
|
-
* preprocess
|
|
1557
1607
|
* refine
|
|
1558
1608
|
* superRefine
|
|
1559
1609
|
* custom
|
|
@@ -1571,4 +1621,4 @@ class SchemaClass {
|
|
|
1571
1621
|
*/
|
|
1572
1622
|
}
|
|
1573
1623
|
|
|
1574
|
-
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 };
|