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