@temporary-name/zod 1.9.3-alpha.76a5d8c6a7525b4b17df3f9565304645f0922ab3 → 1.9.3-alpha.76b43312556f455ccc88aeb67b7c37a426f74d5f
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 -357
- package/dist/index.d.ts +347 -357
- package/dist/index.mjs +561 -510
- 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);
|
|
@@ -736,47 +714,80 @@ const ZodNumber = /* @__PURE__ */ core.$constructor(
|
|
|
736
714
|
inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? 0.5);
|
|
737
715
|
inst.isFinite = true;
|
|
738
716
|
inst.format = bag.format ?? null;
|
|
717
|
+
const origParse = inst._zod.parse;
|
|
718
|
+
inst._zod.parse = (payload, ctx) => {
|
|
719
|
+
const { parseType } = ctx;
|
|
720
|
+
if (parseType === "query" && typeof payload.value === "string") {
|
|
721
|
+
const value = Number(payload.value);
|
|
722
|
+
if (!Number.isNaN(value)) {
|
|
723
|
+
payload.value = value;
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
return origParse(payload, ctx);
|
|
727
|
+
};
|
|
739
728
|
}
|
|
740
729
|
);
|
|
741
730
|
function number(params) {
|
|
742
|
-
return core._number(
|
|
731
|
+
return core._number(KrustyNumber, params);
|
|
743
732
|
}
|
|
744
|
-
const
|
|
745
|
-
"
|
|
733
|
+
const KrustyNumberFormat = /* @__PURE__ */ core.$constructor(
|
|
734
|
+
"KrustyNumberFormat",
|
|
746
735
|
(inst, def) => {
|
|
747
736
|
const coreInit = core.$ZodNumberFormat.init;
|
|
748
737
|
coreInit(inst, def);
|
|
749
|
-
|
|
738
|
+
KrustyNumber.init(inst, def);
|
|
750
739
|
}
|
|
751
740
|
);
|
|
752
741
|
function int(params) {
|
|
753
|
-
return core._int(
|
|
742
|
+
return core._int(KrustyNumberFormat, params);
|
|
754
743
|
}
|
|
755
744
|
function float32(params) {
|
|
756
|
-
return core._float32(
|
|
745
|
+
return core._float32(KrustyNumberFormat, params);
|
|
757
746
|
}
|
|
758
747
|
function float64(params) {
|
|
759
|
-
return core._float64(
|
|
748
|
+
return core._float64(KrustyNumberFormat, params);
|
|
760
749
|
}
|
|
761
750
|
function int32(params) {
|
|
762
|
-
return core._int32(
|
|
751
|
+
return core._int32(KrustyNumberFormat, params);
|
|
763
752
|
}
|
|
764
753
|
function uint32(params) {
|
|
765
|
-
return core._uint32(
|
|
754
|
+
return core._uint32(KrustyNumberFormat, params);
|
|
766
755
|
}
|
|
767
|
-
const
|
|
768
|
-
"
|
|
756
|
+
const KrustyBoolean = /* @__PURE__ */ core.$constructor(
|
|
757
|
+
"KrustyBoolean",
|
|
769
758
|
(inst, def) => {
|
|
770
759
|
const coreInit = core.$ZodBoolean.init;
|
|
771
760
|
coreInit(inst, def);
|
|
772
761
|
KrustyType.init(inst, def);
|
|
762
|
+
const origParse = inst._zod.parse;
|
|
763
|
+
inst._zod.parse = (payload, ctx) => {
|
|
764
|
+
const { parseType } = ctx;
|
|
765
|
+
if (parseType === "query") {
|
|
766
|
+
if (payload.value === "true") {
|
|
767
|
+
payload.value = true;
|
|
768
|
+
} else if (payload.value === "false") {
|
|
769
|
+
payload.value = false;
|
|
770
|
+
} else {
|
|
771
|
+
payload.issues.push({
|
|
772
|
+
code: "invalid_type",
|
|
773
|
+
expected: "boolean",
|
|
774
|
+
values: ["true", "false"],
|
|
775
|
+
input: payload.value,
|
|
776
|
+
inst,
|
|
777
|
+
continue: false
|
|
778
|
+
});
|
|
779
|
+
return payload;
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
return origParse(payload, ctx);
|
|
783
|
+
};
|
|
773
784
|
}
|
|
774
785
|
);
|
|
775
786
|
function boolean(params) {
|
|
776
|
-
return core._boolean(
|
|
787
|
+
return core._boolean(KrustyBoolean, params);
|
|
777
788
|
}
|
|
778
|
-
const
|
|
779
|
-
"
|
|
789
|
+
const KrustyBigInt = /* @__PURE__ */ core.$constructor(
|
|
790
|
+
"KrustyBigInt",
|
|
780
791
|
(inst, def) => {
|
|
781
792
|
const coreInit = core.$ZodBigInt.init;
|
|
782
793
|
coreInit(inst, def);
|
|
@@ -801,24 +812,24 @@ const ZodBigInt = /* @__PURE__ */ core.$constructor(
|
|
|
801
812
|
}
|
|
802
813
|
);
|
|
803
814
|
function bigint(params) {
|
|
804
|
-
return core._bigint(
|
|
815
|
+
return core._bigint(KrustyBigInt, params);
|
|
805
816
|
}
|
|
806
|
-
const
|
|
807
|
-
"
|
|
817
|
+
const KrustyBigIntFormat = /* @__PURE__ */ core.$constructor(
|
|
818
|
+
"KrustyBigIntFormat",
|
|
808
819
|
(inst, def) => {
|
|
809
820
|
const coreInit = core.$ZodBigIntFormat.init;
|
|
810
821
|
coreInit(inst, def);
|
|
811
|
-
|
|
822
|
+
KrustyBigInt.init(inst, def);
|
|
812
823
|
}
|
|
813
824
|
);
|
|
814
825
|
function int64(params) {
|
|
815
|
-
return core._int64(
|
|
826
|
+
return core._int64(KrustyBigIntFormat, params);
|
|
816
827
|
}
|
|
817
828
|
function uint64(params) {
|
|
818
|
-
return core._uint64(
|
|
829
|
+
return core._uint64(KrustyBigIntFormat, params);
|
|
819
830
|
}
|
|
820
|
-
const
|
|
821
|
-
"
|
|
831
|
+
const KrustySymbol = /* @__PURE__ */ core.$constructor(
|
|
832
|
+
"KrustySymbol",
|
|
822
833
|
(inst, def) => {
|
|
823
834
|
const coreInit = core.$ZodSymbol.init;
|
|
824
835
|
coreInit(inst, def);
|
|
@@ -826,10 +837,10 @@ const ZodSymbol = /* @__PURE__ */ core.$constructor(
|
|
|
826
837
|
}
|
|
827
838
|
);
|
|
828
839
|
function symbol(params) {
|
|
829
|
-
return core._symbol(
|
|
840
|
+
return core._symbol(KrustySymbol, params);
|
|
830
841
|
}
|
|
831
|
-
const
|
|
832
|
-
"
|
|
842
|
+
const KrustyUndefined = /* @__PURE__ */ core.$constructor(
|
|
843
|
+
"KrustyUndefined",
|
|
833
844
|
(inst, def) => {
|
|
834
845
|
const coreInit = core.$ZodUndefined.init;
|
|
835
846
|
coreInit(inst, def);
|
|
@@ -837,26 +848,32 @@ const ZodUndefined = /* @__PURE__ */ core.$constructor(
|
|
|
837
848
|
}
|
|
838
849
|
);
|
|
839
850
|
function _undefined(params) {
|
|
840
|
-
return core._undefined(
|
|
851
|
+
return core._undefined(KrustyUndefined, params);
|
|
841
852
|
}
|
|
842
|
-
const
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
853
|
+
const KrustyNull = /* @__PURE__ */ core.$constructor(
|
|
854
|
+
"KrustyNull",
|
|
855
|
+
(inst, def) => {
|
|
856
|
+
const coreInit = core.$ZodNull.init;
|
|
857
|
+
coreInit(inst, def);
|
|
858
|
+
KrustyType.init(inst, def);
|
|
859
|
+
}
|
|
860
|
+
);
|
|
847
861
|
function _null(params) {
|
|
848
|
-
return core._null(
|
|
862
|
+
return core._null(KrustyNull, params);
|
|
849
863
|
}
|
|
850
|
-
const
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
864
|
+
const KrustyAny = /* @__PURE__ */ core.$constructor(
|
|
865
|
+
"KrustyAny",
|
|
866
|
+
(inst, def) => {
|
|
867
|
+
const coreInit = core.$ZodAny.init;
|
|
868
|
+
coreInit(inst, def);
|
|
869
|
+
KrustyType.init(inst, def);
|
|
870
|
+
}
|
|
871
|
+
);
|
|
855
872
|
function any() {
|
|
856
|
-
return core._any(
|
|
873
|
+
return core._any(KrustyAny);
|
|
857
874
|
}
|
|
858
|
-
const
|
|
859
|
-
"
|
|
875
|
+
const KrustyUnknown = /* @__PURE__ */ core.$constructor(
|
|
876
|
+
"KrustyUnknown",
|
|
860
877
|
(inst, def) => {
|
|
861
878
|
const coreInit = core.$ZodUnknown.init;
|
|
862
879
|
coreInit(inst, def);
|
|
@@ -864,10 +881,10 @@ const ZodUnknown = /* @__PURE__ */ core.$constructor(
|
|
|
864
881
|
}
|
|
865
882
|
);
|
|
866
883
|
function unknown() {
|
|
867
|
-
return core._unknown(
|
|
884
|
+
return core._unknown(KrustyUnknown);
|
|
868
885
|
}
|
|
869
|
-
const
|
|
870
|
-
"
|
|
886
|
+
const KrustyNever = /* @__PURE__ */ core.$constructor(
|
|
887
|
+
"KrustyNever",
|
|
871
888
|
(inst, def) => {
|
|
872
889
|
const coreInit = core.$ZodNever.init;
|
|
873
890
|
coreInit(inst, def);
|
|
@@ -875,31 +892,49 @@ const ZodNever = /* @__PURE__ */ core.$constructor(
|
|
|
875
892
|
}
|
|
876
893
|
);
|
|
877
894
|
function never(params) {
|
|
878
|
-
return core._never(
|
|
895
|
+
return core._never(KrustyNever, params);
|
|
879
896
|
}
|
|
880
|
-
const
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
897
|
+
const KrustyVoid = /* @__PURE__ */ core.$constructor(
|
|
898
|
+
"KrustyVoid",
|
|
899
|
+
(inst, def) => {
|
|
900
|
+
const coreInit = core.$ZodVoid.init;
|
|
901
|
+
coreInit(inst, def);
|
|
902
|
+
KrustyType.init(inst, def);
|
|
903
|
+
}
|
|
904
|
+
);
|
|
885
905
|
function _void(params) {
|
|
886
|
-
return core._void(
|
|
906
|
+
return core._void(KrustyVoid, params);
|
|
887
907
|
}
|
|
888
|
-
const
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
908
|
+
const KrustyDate = /* @__PURE__ */ core.$constructor(
|
|
909
|
+
"KrustyDate",
|
|
910
|
+
(inst, def) => {
|
|
911
|
+
const coreInit = core.$ZodDate.init;
|
|
912
|
+
coreInit(inst, def);
|
|
913
|
+
KrustyType.init(inst, def);
|
|
914
|
+
inst.min = (value, params) => inst.check(_gte(value, params));
|
|
915
|
+
inst.max = (value, params) => inst.check(_lte(value, params));
|
|
916
|
+
const c = inst._zod.bag;
|
|
917
|
+
inst.minDate = c.minimum ? new Date(c.minimum) : null;
|
|
918
|
+
inst.maxDate = c.maximum ? new Date(c.maximum) : null;
|
|
919
|
+
}
|
|
920
|
+
);
|
|
898
921
|
function date(params) {
|
|
899
|
-
return core._date(
|
|
922
|
+
return codec(date$1(params), core._date(KrustyDate, params), {
|
|
923
|
+
encode: (date2) => `${date2.getFullYear()}-${String(date2.getMonth() + 1).padStart(2, "0")}-${String(date2.getDate()).padStart(2, "0")}`,
|
|
924
|
+
decode: (isoString2) => {
|
|
925
|
+
const [y, m, d] = isoString2.split("-");
|
|
926
|
+
return new Date(Number(y), Number(m) - 1, Number(d));
|
|
927
|
+
}
|
|
928
|
+
});
|
|
900
929
|
}
|
|
901
|
-
|
|
902
|
-
|
|
930
|
+
function datetime(params) {
|
|
931
|
+
return codec(datetime$1(params), core._date(KrustyDate, params), {
|
|
932
|
+
encode: (date2) => date2.toISOString(),
|
|
933
|
+
decode: (isoString2) => new Date(isoString2)
|
|
934
|
+
});
|
|
935
|
+
}
|
|
936
|
+
const KrustyArray = /* @__PURE__ */ core.$constructor(
|
|
937
|
+
"KrustyArray",
|
|
903
938
|
(inst, def) => {
|
|
904
939
|
const coreInit = core.$ZodArray.init;
|
|
905
940
|
coreInit(inst, def);
|
|
@@ -913,14 +948,14 @@ const ZodArray = /* @__PURE__ */ core.$constructor(
|
|
|
913
948
|
}
|
|
914
949
|
);
|
|
915
950
|
function array(element, params) {
|
|
916
|
-
return core._array(
|
|
951
|
+
return core._array(KrustyArray, element, params);
|
|
917
952
|
}
|
|
918
953
|
function keyof(schema) {
|
|
919
954
|
const shape = schema._zod.def.shape;
|
|
920
955
|
return _enum(Object.keys(shape));
|
|
921
956
|
}
|
|
922
|
-
const
|
|
923
|
-
"
|
|
957
|
+
const KrustyIntersection = /* @__PURE__ */ core.$constructor(
|
|
958
|
+
"KrustyIntersection",
|
|
924
959
|
(inst, def) => {
|
|
925
960
|
const coreInit = core.$ZodIntersection.init;
|
|
926
961
|
coreInit(inst, def);
|
|
@@ -928,14 +963,14 @@ const ZodIntersection = /* @__PURE__ */ core.$constructor(
|
|
|
928
963
|
}
|
|
929
964
|
);
|
|
930
965
|
function intersection(left, right) {
|
|
931
|
-
return new
|
|
966
|
+
return new KrustyIntersection({
|
|
932
967
|
type: "intersection",
|
|
933
968
|
left,
|
|
934
969
|
right
|
|
935
970
|
});
|
|
936
971
|
}
|
|
937
|
-
const
|
|
938
|
-
"
|
|
972
|
+
const KrustyTuple = /* @__PURE__ */ core.$constructor(
|
|
973
|
+
"KrustyTuple",
|
|
939
974
|
(inst, def) => {
|
|
940
975
|
const coreInit = core.$ZodTuple.init;
|
|
941
976
|
coreInit(inst, def);
|
|
@@ -950,15 +985,15 @@ function tuple(items, _paramsOrRest, _params) {
|
|
|
950
985
|
const hasRest = _paramsOrRest instanceof core.$ZodType;
|
|
951
986
|
const params = hasRest ? _params : _paramsOrRest;
|
|
952
987
|
const rest = hasRest ? _paramsOrRest : null;
|
|
953
|
-
return new
|
|
988
|
+
return new KrustyTuple({
|
|
954
989
|
type: "tuple",
|
|
955
990
|
items,
|
|
956
991
|
rest,
|
|
957
992
|
...util.normalizeParams(params)
|
|
958
993
|
});
|
|
959
994
|
}
|
|
960
|
-
const
|
|
961
|
-
"
|
|
995
|
+
const KrustyRecord = /* @__PURE__ */ core.$constructor(
|
|
996
|
+
"KrustyRecord",
|
|
962
997
|
(inst, def) => {
|
|
963
998
|
const coreInit = core.$ZodRecord.init;
|
|
964
999
|
coreInit(inst, def);
|
|
@@ -968,7 +1003,7 @@ const ZodRecord = /* @__PURE__ */ core.$constructor(
|
|
|
968
1003
|
}
|
|
969
1004
|
);
|
|
970
1005
|
function record(keyType, valueType, params) {
|
|
971
|
-
return new
|
|
1006
|
+
return new KrustyRecord({
|
|
972
1007
|
type: "record",
|
|
973
1008
|
keyType,
|
|
974
1009
|
valueType,
|
|
@@ -978,97 +1013,106 @@ function record(keyType, valueType, params) {
|
|
|
978
1013
|
function partialRecord(keyType, valueType, params) {
|
|
979
1014
|
const k = core.clone(keyType);
|
|
980
1015
|
k._zod.values = void 0;
|
|
981
|
-
return new
|
|
1016
|
+
return new KrustyRecord({
|
|
982
1017
|
type: "record",
|
|
983
1018
|
keyType: k,
|
|
984
1019
|
valueType,
|
|
985
1020
|
...util.normalizeParams(params)
|
|
986
1021
|
});
|
|
987
1022
|
}
|
|
988
|
-
const
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
1023
|
+
const KrustyMap = /* @__PURE__ */ core.$constructor(
|
|
1024
|
+
"KrustyMap",
|
|
1025
|
+
(inst, def) => {
|
|
1026
|
+
const coreInit = core.$ZodMap.init;
|
|
1027
|
+
coreInit(inst, def);
|
|
1028
|
+
KrustyType.init(inst, def);
|
|
1029
|
+
inst.keyType = def.keyType;
|
|
1030
|
+
inst.valueType = def.valueType;
|
|
1031
|
+
}
|
|
1032
|
+
);
|
|
995
1033
|
function map(keyType, valueType, params) {
|
|
996
|
-
return new
|
|
1034
|
+
return new KrustyMap({
|
|
997
1035
|
type: "map",
|
|
998
1036
|
keyType,
|
|
999
1037
|
valueType,
|
|
1000
1038
|
...util.normalizeParams(params)
|
|
1001
1039
|
});
|
|
1002
1040
|
}
|
|
1003
|
-
const
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1041
|
+
const KrustySet = /* @__PURE__ */ core.$constructor(
|
|
1042
|
+
"KrustySet",
|
|
1043
|
+
(inst, def) => {
|
|
1044
|
+
const coreInit = core.$ZodSet.init;
|
|
1045
|
+
coreInit(inst, def);
|
|
1046
|
+
KrustyType.init(inst, def);
|
|
1047
|
+
inst.min = (...args) => inst.check(core._minSize(...args));
|
|
1048
|
+
inst.nonempty = (params) => inst.check(core._minSize(1, params));
|
|
1049
|
+
inst.max = (...args) => inst.check(core._maxSize(...args));
|
|
1050
|
+
inst.size = (...args) => inst.check(core._size(...args));
|
|
1051
|
+
}
|
|
1052
|
+
);
|
|
1012
1053
|
function set(valueType, params) {
|
|
1013
|
-
return new
|
|
1054
|
+
return new KrustySet({
|
|
1014
1055
|
type: "set",
|
|
1015
1056
|
valueType,
|
|
1016
1057
|
...util.normalizeParams(params)
|
|
1017
1058
|
});
|
|
1018
1059
|
}
|
|
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
|
-
});
|
|
1060
|
+
const KrustyEnum = /* @__PURE__ */ core.$constructor(
|
|
1061
|
+
"KrustyEnum",
|
|
1062
|
+
(inst, def) => {
|
|
1063
|
+
const coreInit = core.$ZodEnum.init;
|
|
1064
|
+
coreInit(inst, def);
|
|
1065
|
+
KrustyType.init(inst, def);
|
|
1066
|
+
inst.enum = def.entries;
|
|
1067
|
+
inst.options = Object.values(def.entries);
|
|
1068
|
+
const keys = new Set(Object.keys(def.entries));
|
|
1069
|
+
inst.extract = (values, params) => {
|
|
1070
|
+
const newEntries = {};
|
|
1071
|
+
for (const value of values) {
|
|
1072
|
+
if (keys.has(value)) {
|
|
1073
|
+
newEntries[value] = def.entries[value];
|
|
1074
|
+
} else throw new Error(`Key ${value} not found in enum`);
|
|
1075
|
+
}
|
|
1076
|
+
return new KrustyEnum({
|
|
1077
|
+
...def,
|
|
1078
|
+
checks: [],
|
|
1079
|
+
...util.normalizeParams(params),
|
|
1080
|
+
entries: newEntries
|
|
1081
|
+
});
|
|
1082
|
+
};
|
|
1083
|
+
inst.exclude = (values, params) => {
|
|
1084
|
+
const newEntries = { ...def.entries };
|
|
1085
|
+
for (const value of values) {
|
|
1086
|
+
if (keys.has(value)) {
|
|
1087
|
+
delete newEntries[value];
|
|
1088
|
+
} else throw new Error(`Key ${value} not found in enum`);
|
|
1089
|
+
}
|
|
1090
|
+
return new KrustyEnum({
|
|
1091
|
+
...def,
|
|
1092
|
+
checks: [],
|
|
1093
|
+
...util.normalizeParams(params),
|
|
1094
|
+
entries: newEntries
|
|
1095
|
+
});
|
|
1096
|
+
};
|
|
1097
|
+
}
|
|
1098
|
+
);
|
|
1055
1099
|
function _enum(values, params) {
|
|
1056
1100
|
const entries = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
|
|
1057
|
-
return new
|
|
1101
|
+
return new KrustyEnum({
|
|
1058
1102
|
type: "enum",
|
|
1059
1103
|
entries,
|
|
1060
1104
|
...util.normalizeParams(params)
|
|
1061
1105
|
});
|
|
1062
1106
|
}
|
|
1063
1107
|
function nativeEnum(entries, params) {
|
|
1064
|
-
return new
|
|
1108
|
+
return new KrustyEnum({
|
|
1065
1109
|
type: "enum",
|
|
1066
1110
|
entries,
|
|
1067
1111
|
...util.normalizeParams(params)
|
|
1068
1112
|
});
|
|
1069
1113
|
}
|
|
1070
|
-
const
|
|
1071
|
-
"
|
|
1114
|
+
const KrustyLiteral = /* @__PURE__ */ core.$constructor(
|
|
1115
|
+
"KrustyLiteral",
|
|
1072
1116
|
(inst, def) => {
|
|
1073
1117
|
const coreInit = core.$ZodLiteral.init;
|
|
1074
1118
|
coreInit(inst, def);
|
|
@@ -1085,25 +1129,28 @@ const ZodLiteral = /* @__PURE__ */ core.$constructor(
|
|
|
1085
1129
|
}
|
|
1086
1130
|
);
|
|
1087
1131
|
function literal(value, params) {
|
|
1088
|
-
return new
|
|
1132
|
+
return new KrustyLiteral({
|
|
1089
1133
|
type: "literal",
|
|
1090
1134
|
values: Array.isArray(value) ? value : [value],
|
|
1091
1135
|
...util.normalizeParams(params)
|
|
1092
1136
|
});
|
|
1093
1137
|
}
|
|
1094
|
-
const
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1138
|
+
const KrustyFile = /* @__PURE__ */ core.$constructor(
|
|
1139
|
+
"KrustyFile",
|
|
1140
|
+
(inst, def) => {
|
|
1141
|
+
const coreInit = core.$ZodFile.init;
|
|
1142
|
+
coreInit(inst, def);
|
|
1143
|
+
KrustyType.init(inst, def);
|
|
1144
|
+
inst.min = (size, params) => inst.check(core._minSize(size, params));
|
|
1145
|
+
inst.max = (size, params) => inst.check(core._maxSize(size, params));
|
|
1146
|
+
inst.mime = (types, params) => inst.check(core._mime(Array.isArray(types) ? types : [types], params));
|
|
1147
|
+
}
|
|
1148
|
+
);
|
|
1102
1149
|
function file(params) {
|
|
1103
|
-
return core._file(
|
|
1150
|
+
return core._file(KrustyFile, params);
|
|
1104
1151
|
}
|
|
1105
|
-
const
|
|
1106
|
-
"
|
|
1152
|
+
const KrustyTransform = /* @__PURE__ */ core.$constructor(
|
|
1153
|
+
"KrustyTransform",
|
|
1107
1154
|
(inst, def) => {
|
|
1108
1155
|
const coreInit = core.$ZodTransform.init;
|
|
1109
1156
|
coreInit(inst, def);
|
|
@@ -1137,13 +1184,13 @@ const ZodTransform = /* @__PURE__ */ core.$constructor(
|
|
|
1137
1184
|
}
|
|
1138
1185
|
);
|
|
1139
1186
|
function transform(fn) {
|
|
1140
|
-
return new
|
|
1187
|
+
return new KrustyTransform({
|
|
1141
1188
|
type: "transform",
|
|
1142
1189
|
transform: fn
|
|
1143
1190
|
});
|
|
1144
1191
|
}
|
|
1145
|
-
const
|
|
1146
|
-
"
|
|
1192
|
+
const KrustyOptional = /* @__PURE__ */ core.$constructor(
|
|
1193
|
+
"KrustyOptional",
|
|
1147
1194
|
(inst, def) => {
|
|
1148
1195
|
const coreInit = core.$ZodOptional.init;
|
|
1149
1196
|
coreInit(inst, def);
|
|
@@ -1152,13 +1199,13 @@ const ZodOptional = /* @__PURE__ */ core.$constructor(
|
|
|
1152
1199
|
}
|
|
1153
1200
|
);
|
|
1154
1201
|
function optional(innerType) {
|
|
1155
|
-
return new
|
|
1202
|
+
return new KrustyOptional({
|
|
1156
1203
|
type: "optional",
|
|
1157
1204
|
innerType
|
|
1158
1205
|
});
|
|
1159
1206
|
}
|
|
1160
|
-
const
|
|
1161
|
-
"
|
|
1207
|
+
const KrustyNullable = /* @__PURE__ */ core.$constructor(
|
|
1208
|
+
"KrustyNullable",
|
|
1162
1209
|
(inst, def) => {
|
|
1163
1210
|
const coreInit = core.$ZodNullable.init;
|
|
1164
1211
|
coreInit(inst, def);
|
|
@@ -1167,7 +1214,7 @@ const ZodNullable = /* @__PURE__ */ core.$constructor(
|
|
|
1167
1214
|
}
|
|
1168
1215
|
);
|
|
1169
1216
|
function nullable(innerType) {
|
|
1170
|
-
return new
|
|
1217
|
+
return new KrustyNullable({
|
|
1171
1218
|
type: "nullable",
|
|
1172
1219
|
innerType
|
|
1173
1220
|
});
|
|
@@ -1175,8 +1222,8 @@ function nullable(innerType) {
|
|
|
1175
1222
|
function nullish(innerType) {
|
|
1176
1223
|
return optional(nullable(innerType));
|
|
1177
1224
|
}
|
|
1178
|
-
const
|
|
1179
|
-
"
|
|
1225
|
+
const KrustyDefault = /* @__PURE__ */ core.$constructor(
|
|
1226
|
+
"KrustyDefault",
|
|
1180
1227
|
(inst, def) => {
|
|
1181
1228
|
const coreInit = core.$ZodDefault.init;
|
|
1182
1229
|
coreInit(inst, def);
|
|
@@ -1186,7 +1233,7 @@ const ZodDefault = /* @__PURE__ */ core.$constructor(
|
|
|
1186
1233
|
}
|
|
1187
1234
|
);
|
|
1188
1235
|
function _default(innerType, defaultValue) {
|
|
1189
|
-
return new
|
|
1236
|
+
return new KrustyDefault({
|
|
1190
1237
|
type: "default",
|
|
1191
1238
|
innerType,
|
|
1192
1239
|
get defaultValue() {
|
|
@@ -1194,8 +1241,8 @@ function _default(innerType, defaultValue) {
|
|
|
1194
1241
|
}
|
|
1195
1242
|
});
|
|
1196
1243
|
}
|
|
1197
|
-
const
|
|
1198
|
-
"
|
|
1244
|
+
const KrustyPrefault = /* @__PURE__ */ core.$constructor(
|
|
1245
|
+
"KrustyPrefault",
|
|
1199
1246
|
(inst, def) => {
|
|
1200
1247
|
const coreInit = core.$ZodPrefault.init;
|
|
1201
1248
|
coreInit(inst, def);
|
|
@@ -1204,7 +1251,7 @@ const ZodPrefault = /* @__PURE__ */ core.$constructor(
|
|
|
1204
1251
|
}
|
|
1205
1252
|
);
|
|
1206
1253
|
function prefault(innerType, defaultValue) {
|
|
1207
|
-
return new
|
|
1254
|
+
return new KrustyPrefault({
|
|
1208
1255
|
type: "prefault",
|
|
1209
1256
|
innerType,
|
|
1210
1257
|
get defaultValue() {
|
|
@@ -1212,8 +1259,8 @@ function prefault(innerType, defaultValue) {
|
|
|
1212
1259
|
}
|
|
1213
1260
|
});
|
|
1214
1261
|
}
|
|
1215
|
-
const
|
|
1216
|
-
"
|
|
1262
|
+
const KrustyNonOptional = /* @__PURE__ */ core.$constructor(
|
|
1263
|
+
"KrustyNonOptional",
|
|
1217
1264
|
(inst, def) => {
|
|
1218
1265
|
const coreInit = core.$ZodNonOptional.init;
|
|
1219
1266
|
coreInit(inst, def);
|
|
@@ -1222,14 +1269,14 @@ const ZodNonOptional = /* @__PURE__ */ core.$constructor(
|
|
|
1222
1269
|
}
|
|
1223
1270
|
);
|
|
1224
1271
|
function nonoptional(innerType, params) {
|
|
1225
|
-
return new
|
|
1272
|
+
return new KrustyNonOptional({
|
|
1226
1273
|
type: "nonoptional",
|
|
1227
1274
|
innerType,
|
|
1228
1275
|
...util.normalizeParams(params)
|
|
1229
1276
|
});
|
|
1230
1277
|
}
|
|
1231
|
-
const
|
|
1232
|
-
"
|
|
1278
|
+
const KrustySuccess = /* @__PURE__ */ core.$constructor(
|
|
1279
|
+
"KrustySuccess",
|
|
1233
1280
|
(inst, def) => {
|
|
1234
1281
|
const coreInit = core.$ZodSuccess.init;
|
|
1235
1282
|
coreInit(inst, def);
|
|
@@ -1238,13 +1285,13 @@ const ZodSuccess = /* @__PURE__ */ core.$constructor(
|
|
|
1238
1285
|
}
|
|
1239
1286
|
);
|
|
1240
1287
|
function success(innerType) {
|
|
1241
|
-
return new
|
|
1288
|
+
return new KrustySuccess({
|
|
1242
1289
|
type: "success",
|
|
1243
1290
|
innerType
|
|
1244
1291
|
});
|
|
1245
1292
|
}
|
|
1246
|
-
const
|
|
1247
|
-
"
|
|
1293
|
+
const KrustyCatch = /* @__PURE__ */ core.$constructor(
|
|
1294
|
+
"KrustyCatch",
|
|
1248
1295
|
(inst, def) => {
|
|
1249
1296
|
const coreInit = core.$ZodCatch.init;
|
|
1250
1297
|
coreInit(inst, def);
|
|
@@ -1254,45 +1301,51 @@ const ZodCatch = /* @__PURE__ */ core.$constructor(
|
|
|
1254
1301
|
}
|
|
1255
1302
|
);
|
|
1256
1303
|
function _catch(innerType, catchValue) {
|
|
1257
|
-
return new
|
|
1304
|
+
return new KrustyCatch({
|
|
1258
1305
|
type: "catch",
|
|
1259
1306
|
innerType,
|
|
1260
1307
|
catchValue: typeof catchValue === "function" ? catchValue : () => catchValue
|
|
1261
1308
|
});
|
|
1262
1309
|
}
|
|
1263
|
-
const
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1310
|
+
const KrustyNaN = /* @__PURE__ */ core.$constructor(
|
|
1311
|
+
"KrustyNaN",
|
|
1312
|
+
(inst, def) => {
|
|
1313
|
+
const coreInit = core.$ZodNaN.init;
|
|
1314
|
+
coreInit(inst, def);
|
|
1315
|
+
KrustyType.init(inst, def);
|
|
1316
|
+
}
|
|
1317
|
+
);
|
|
1268
1318
|
function nan(params) {
|
|
1269
|
-
return core._nan(
|
|
1319
|
+
return core._nan(KrustyNaN, params);
|
|
1270
1320
|
}
|
|
1271
|
-
const
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1321
|
+
const KrustyPipe = /* @__PURE__ */ core.$constructor(
|
|
1322
|
+
"KrustyPipe",
|
|
1323
|
+
(inst, def) => {
|
|
1324
|
+
const coreInit = core.$ZodPipe.init;
|
|
1325
|
+
coreInit(inst, def);
|
|
1326
|
+
KrustyType.init(inst, def);
|
|
1327
|
+
inst.in = def.in;
|
|
1328
|
+
inst.out = def.out;
|
|
1329
|
+
}
|
|
1330
|
+
);
|
|
1278
1331
|
function pipe(in_, out) {
|
|
1279
|
-
return new
|
|
1332
|
+
return new KrustyPipe({
|
|
1280
1333
|
type: "pipe",
|
|
1281
1334
|
in: in_,
|
|
1282
1335
|
out
|
|
1283
1336
|
// ...util.normalizeParams(params),
|
|
1284
1337
|
});
|
|
1285
1338
|
}
|
|
1286
|
-
const
|
|
1287
|
-
"
|
|
1339
|
+
const KrustyCodec = /* @__PURE__ */ core.$constructor(
|
|
1340
|
+
"KrustyCodec",
|
|
1288
1341
|
(inst, def) => {
|
|
1289
|
-
|
|
1342
|
+
KrustyPipe.init(inst, def);
|
|
1290
1343
|
const coreInit = core.$ZodCodec.init;
|
|
1291
1344
|
coreInit(inst, def);
|
|
1292
1345
|
}
|
|
1293
1346
|
);
|
|
1294
1347
|
function codec(in_, out, params) {
|
|
1295
|
-
return new
|
|
1348
|
+
return new KrustyCodec({
|
|
1296
1349
|
type: "pipe",
|
|
1297
1350
|
in: in_,
|
|
1298
1351
|
out,
|
|
@@ -1300,8 +1353,8 @@ function codec(in_, out, params) {
|
|
|
1300
1353
|
reverseTransform: params.encode
|
|
1301
1354
|
});
|
|
1302
1355
|
}
|
|
1303
|
-
const
|
|
1304
|
-
"
|
|
1356
|
+
const KrustyReadonly = /* @__PURE__ */ core.$constructor(
|
|
1357
|
+
"KrustyReadonly",
|
|
1305
1358
|
(inst, def) => {
|
|
1306
1359
|
const coreInit = core.$ZodReadonly.init;
|
|
1307
1360
|
coreInit(inst, def);
|
|
@@ -1310,40 +1363,40 @@ const ZodReadonly = /* @__PURE__ */ core.$constructor(
|
|
|
1310
1363
|
}
|
|
1311
1364
|
);
|
|
1312
1365
|
function readonly(innerType) {
|
|
1313
|
-
return new
|
|
1366
|
+
return new KrustyReadonly({
|
|
1314
1367
|
type: "readonly",
|
|
1315
1368
|
innerType
|
|
1316
1369
|
});
|
|
1317
1370
|
}
|
|
1318
|
-
const
|
|
1319
|
-
|
|
1320
|
-
(inst, def)
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
KrustyType.init(inst, def);
|
|
1324
|
-
}
|
|
1325
|
-
);
|
|
1371
|
+
const KrustyTemplateLiteral = /* @__PURE__ */ core.$constructor("KrustyTemplateLiteral", (inst, def) => {
|
|
1372
|
+
const coreInit = core.$ZodTemplateLiteral.init;
|
|
1373
|
+
coreInit(inst, def);
|
|
1374
|
+
KrustyType.init(inst, def);
|
|
1375
|
+
});
|
|
1326
1376
|
function templateLiteral(parts, params) {
|
|
1327
|
-
return new
|
|
1377
|
+
return new KrustyTemplateLiteral({
|
|
1328
1378
|
type: "template_literal",
|
|
1329
1379
|
parts,
|
|
1330
1380
|
...util.normalizeParams(params)
|
|
1331
1381
|
});
|
|
1332
1382
|
}
|
|
1333
|
-
const
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1383
|
+
const KrustyLazy = /* @__PURE__ */ core.$constructor(
|
|
1384
|
+
"KrustyLazy",
|
|
1385
|
+
(inst, def) => {
|
|
1386
|
+
const coreInit = core.$ZodLazy.init;
|
|
1387
|
+
coreInit(inst, def);
|
|
1388
|
+
KrustyType.init(inst, def);
|
|
1389
|
+
inst.unwrap = () => inst._zod.def.getter();
|
|
1390
|
+
}
|
|
1391
|
+
);
|
|
1339
1392
|
function lazy(getter) {
|
|
1340
|
-
return new
|
|
1393
|
+
return new KrustyLazy({
|
|
1341
1394
|
type: "lazy",
|
|
1342
1395
|
getter
|
|
1343
1396
|
});
|
|
1344
1397
|
}
|
|
1345
|
-
const
|
|
1346
|
-
"
|
|
1398
|
+
const KrustyPromise = /* @__PURE__ */ core.$constructor(
|
|
1399
|
+
"KrustyPromise",
|
|
1347
1400
|
(inst, def) => {
|
|
1348
1401
|
const coreInit = core.$ZodPromise.init;
|
|
1349
1402
|
coreInit(inst, def);
|
|
@@ -1352,13 +1405,13 @@ const ZodPromise = /* @__PURE__ */ core.$constructor(
|
|
|
1352
1405
|
}
|
|
1353
1406
|
);
|
|
1354
1407
|
function promise(innerType) {
|
|
1355
|
-
return new
|
|
1408
|
+
return new KrustyPromise({
|
|
1356
1409
|
type: "promise",
|
|
1357
1410
|
innerType
|
|
1358
1411
|
});
|
|
1359
1412
|
}
|
|
1360
|
-
const
|
|
1361
|
-
"
|
|
1413
|
+
const KrustyFunction = /* @__PURE__ */ core.$constructor(
|
|
1414
|
+
"KrustyFunction",
|
|
1362
1415
|
(inst, def) => {
|
|
1363
1416
|
const coreInit = core.$ZodFunction.init;
|
|
1364
1417
|
coreInit(inst, def);
|
|
@@ -1366,14 +1419,14 @@ const ZodFunction = /* @__PURE__ */ core.$constructor(
|
|
|
1366
1419
|
}
|
|
1367
1420
|
);
|
|
1368
1421
|
function _function(params) {
|
|
1369
|
-
return new
|
|
1422
|
+
return new KrustyFunction({
|
|
1370
1423
|
type: "function",
|
|
1371
1424
|
input: Array.isArray(params?.input) ? tuple(params?.input) : params?.input ?? array(unknown()),
|
|
1372
1425
|
output: params?.output ?? unknown()
|
|
1373
1426
|
});
|
|
1374
1427
|
}
|
|
1375
|
-
const
|
|
1376
|
-
"
|
|
1428
|
+
const KrustyCustom = /* @__PURE__ */ core.$constructor(
|
|
1429
|
+
"KrustyCustom",
|
|
1377
1430
|
(inst, def) => {
|
|
1378
1431
|
const coreInit = core.$ZodCustom.init;
|
|
1379
1432
|
coreInit(inst, def);
|
|
@@ -1389,10 +1442,10 @@ function check(fn) {
|
|
|
1389
1442
|
return ch;
|
|
1390
1443
|
}
|
|
1391
1444
|
function custom(fn, _params) {
|
|
1392
|
-
return core._custom(
|
|
1445
|
+
return core._custom(KrustyCustom, fn ?? (() => true), _params);
|
|
1393
1446
|
}
|
|
1394
1447
|
function refine(fn, _params = {}) {
|
|
1395
|
-
return core._refine(
|
|
1448
|
+
return core._refine(KrustyCustom, fn, _params);
|
|
1396
1449
|
}
|
|
1397
1450
|
function superRefine(fn) {
|
|
1398
1451
|
return core._superRefine(fn);
|
|
@@ -1400,7 +1453,7 @@ function superRefine(fn) {
|
|
|
1400
1453
|
function _instanceof(cls, params = {
|
|
1401
1454
|
error: `Input not instance of ${cls.name}`
|
|
1402
1455
|
}) {
|
|
1403
|
-
const inst = new
|
|
1456
|
+
const inst = new KrustyCustom({
|
|
1404
1457
|
type: "custom",
|
|
1405
1458
|
check: "custom",
|
|
1406
1459
|
fn: (data) => data instanceof cls,
|
|
@@ -1412,9 +1465,9 @@ function _instanceof(cls, params = {
|
|
|
1412
1465
|
}
|
|
1413
1466
|
const stringbool = (...args) => core._stringbool(
|
|
1414
1467
|
{
|
|
1415
|
-
Codec:
|
|
1416
|
-
Boolean:
|
|
1417
|
-
String:
|
|
1468
|
+
Codec: KrustyCodec,
|
|
1469
|
+
Boolean: KrustyBoolean,
|
|
1470
|
+
String: KrustyString
|
|
1418
1471
|
},
|
|
1419
1472
|
...args
|
|
1420
1473
|
);
|
|
@@ -1431,9 +1484,6 @@ function json(params) {
|
|
|
1431
1484
|
});
|
|
1432
1485
|
return jsonSchema;
|
|
1433
1486
|
}
|
|
1434
|
-
function preprocess(fn, schema) {
|
|
1435
|
-
return pipe(transform(fn), schema);
|
|
1436
|
-
}
|
|
1437
1487
|
|
|
1438
1488
|
class SchemaClass {
|
|
1439
1489
|
string(params) {
|
|
@@ -1466,10 +1516,12 @@ class SchemaClass {
|
|
|
1466
1516
|
object(shape, params) {
|
|
1467
1517
|
return object(shape, params);
|
|
1468
1518
|
}
|
|
1469
|
-
// TODO: make this a codec?
|
|
1470
1519
|
date(params) {
|
|
1471
1520
|
return date(params);
|
|
1472
1521
|
}
|
|
1522
|
+
datetime(params) {
|
|
1523
|
+
return datetime(params);
|
|
1524
|
+
}
|
|
1473
1525
|
any() {
|
|
1474
1526
|
return any();
|
|
1475
1527
|
}
|
|
@@ -1553,7 +1605,6 @@ class SchemaClass {
|
|
|
1553
1605
|
*/
|
|
1554
1606
|
/**
|
|
1555
1607
|
* TODO: decide what other helper methods to expose
|
|
1556
|
-
* preprocess
|
|
1557
1608
|
* refine
|
|
1558
1609
|
* superRefine
|
|
1559
1610
|
* custom
|
|
@@ -1571,4 +1622,4 @@ class SchemaClass {
|
|
|
1571
1622
|
*/
|
|
1572
1623
|
}
|
|
1573
1624
|
|
|
1574
|
-
export {
|
|
1625
|
+
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 };
|