lkd-web-kit 0.4.3 → 0.4.5
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/hooks/useZodConfig.cjs +21 -0
- package/dist/hooks/useZodConfig.js +17 -0
- package/dist/index.cjs +2 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.js +1 -0
- package/dist/node_modules/@tanstack/virtual-core/dist/esm/index.cjs +38 -33
- package/dist/node_modules/@tanstack/virtual-core/dist/esm/index.js +38 -33
- package/dist/node_modules/@tanstack/virtual-core/dist/esm/utils.cjs +1 -1
- package/dist/node_modules/@tanstack/virtual-core/dist/esm/utils.js +1 -1
- package/dist/node_modules/zod/v4/classic/coerce.cjs +28 -0
- package/dist/node_modules/zod/v4/classic/coerce.js +20 -0
- package/dist/node_modules/zod/v4/classic/compat.cjs +37 -0
- package/dist/node_modules/zod/v4/classic/compat.js +30 -0
- package/dist/node_modules/zod/v4/classic/errors.cjs +49 -0
- package/dist/node_modules/zod/v4/classic/errors.js +44 -0
- package/dist/node_modules/zod/v4/classic/external.cjs +231 -0
- package/dist/node_modules/zod/v4/classic/external.js +28 -0
- package/dist/node_modules/zod/v4/classic/index.cjs +10 -0
- package/dist/node_modules/zod/v4/classic/index.js +5 -0
- package/dist/node_modules/zod/v4/classic/iso.cjs +46 -0
- package/dist/node_modules/zod/v4/classic/iso.js +35 -0
- package/dist/node_modules/zod/v4/classic/parse.cjs +16 -0
- package/dist/node_modules/zod/v4/classic/parse.js +9 -0
- package/dist/node_modules/zod/v4/classic/schemas.cjs +1155 -0
- package/dist/node_modules/zod/v4/classic/schemas.js +1006 -0
- package/dist/node_modules/zod/v4/core/api.cjs +1016 -0
- package/dist/node_modules/zod/v4/core/api.js +903 -0
- package/dist/node_modules/zod/v4/core/checks.cjs +587 -0
- package/dist/node_modules/zod/v4/core/checks.js +562 -0
- package/dist/node_modules/zod/v4/core/core.cjs +72 -0
- package/dist/node_modules/zod/v4/core/core.js +63 -0
- package/dist/node_modules/zod/v4/core/doc.cjs +41 -0
- package/dist/node_modules/zod/v4/core/doc.js +37 -0
- package/dist/node_modules/zod/v4/core/errors.cjs +204 -0
- package/dist/node_modules/zod/v4/core/errors.js +194 -0
- package/dist/node_modules/zod/v4/core/function.cjs +81 -0
- package/dist/node_modules/zod/v4/core/function.js +76 -0
- package/dist/node_modules/zod/v4/core/index.cjs +261 -0
- package/dist/node_modules/zod/v4/core/index.js +20 -0
- package/dist/node_modules/zod/v4/core/json-schema.cjs +2 -0
- package/dist/node_modules/zod/v4/core/json-schema.js +1 -0
- package/dist/node_modules/zod/v4/core/parse.cjs +71 -0
- package/dist/node_modules/zod/v4/core/parse.js +60 -0
- package/dist/node_modules/zod/v4/core/regexes.cjs +139 -0
- package/dist/node_modules/zod/v4/core/regexes.js +95 -0
- package/dist/node_modules/zod/v4/core/registries.cjs +52 -0
- package/dist/node_modules/zod/v4/core/registries.js +44 -0
- package/dist/node_modules/zod/v4/core/schemas.cjs +1793 -0
- package/dist/node_modules/zod/v4/core/schemas.js +1720 -0
- package/dist/node_modules/zod/v4/core/to-json-schema.cjs +823 -0
- package/dist/node_modules/zod/v4/core/to-json-schema.js +818 -0
- package/dist/node_modules/zod/v4/core/util.cjs +543 -0
- package/dist/node_modules/zod/v4/core/util.js +491 -0
- package/dist/node_modules/zod/v4/core/versions.cjs +11 -0
- package/dist/node_modules/zod/v4/core/versions.js +7 -0
- package/dist/node_modules/zod/v4/index.cjs +10 -0
- package/dist/node_modules/zod/v4/index.js +5 -0
- package/dist/node_modules/zod/v4/locales/ar.cjs +121 -0
- package/dist/node_modules/zod/v4/locales/ar.js +119 -0
- package/dist/node_modules/zod/v4/locales/az.cjs +120 -0
- package/dist/node_modules/zod/v4/locales/az.js +118 -0
- package/dist/node_modules/zod/v4/locales/be.cjs +169 -0
- package/dist/node_modules/zod/v4/locales/be.js +167 -0
- package/dist/node_modules/zod/v4/locales/ca.cjs +123 -0
- package/dist/node_modules/zod/v4/locales/ca.js +121 -0
- package/dist/node_modules/zod/v4/locales/cs.cjs +140 -0
- package/dist/node_modules/zod/v4/locales/cs.js +138 -0
- package/dist/node_modules/zod/v4/locales/de.cjs +121 -0
- package/dist/node_modules/zod/v4/locales/de.js +119 -0
- package/dist/node_modules/zod/v4/locales/en.cjs +125 -0
- package/dist/node_modules/zod/v4/locales/en.js +120 -0
- package/dist/node_modules/zod/v4/locales/eo.cjs +124 -0
- package/dist/node_modules/zod/v4/locales/eo.js +119 -0
- package/dist/node_modules/zod/v4/locales/es.cjs +122 -0
- package/dist/node_modules/zod/v4/locales/es.js +120 -0
- package/dist/node_modules/zod/v4/locales/fa.cjs +127 -0
- package/dist/node_modules/zod/v4/locales/fa.js +125 -0
- package/dist/node_modules/zod/v4/locales/fi.cjs +127 -0
- package/dist/node_modules/zod/v4/locales/fi.js +125 -0
- package/dist/node_modules/zod/v4/locales/fr-CA.cjs +122 -0
- package/dist/node_modules/zod/v4/locales/fr-CA.js +120 -0
- package/dist/node_modules/zod/v4/locales/fr.cjs +121 -0
- package/dist/node_modules/zod/v4/locales/fr.js +119 -0
- package/dist/node_modules/zod/v4/locales/he.cjs +122 -0
- package/dist/node_modules/zod/v4/locales/he.js +120 -0
- package/dist/node_modules/zod/v4/locales/hu.cjs +122 -0
- package/dist/node_modules/zod/v4/locales/hu.js +120 -0
- package/dist/node_modules/zod/v4/locales/id.cjs +121 -0
- package/dist/node_modules/zod/v4/locales/id.js +119 -0
- package/dist/node_modules/zod/v4/locales/index.cjs +85 -0
- package/dist/node_modules/zod/v4/locales/index.js +39 -0
- package/dist/node_modules/zod/v4/locales/it.cjs +122 -0
- package/dist/node_modules/zod/v4/locales/it.js +120 -0
- package/dist/node_modules/zod/v4/locales/ja.cjs +120 -0
- package/dist/node_modules/zod/v4/locales/ja.js +118 -0
- package/dist/node_modules/zod/v4/locales/kh.cjs +122 -0
- package/dist/node_modules/zod/v4/locales/kh.js +120 -0
- package/dist/node_modules/zod/v4/locales/ko.cjs +126 -0
- package/dist/node_modules/zod/v4/locales/ko.js +124 -0
- package/dist/node_modules/zod/v4/locales/mk.cjs +123 -0
- package/dist/node_modules/zod/v4/locales/mk.js +121 -0
- package/dist/node_modules/zod/v4/locales/ms.cjs +121 -0
- package/dist/node_modules/zod/v4/locales/ms.js +119 -0
- package/dist/node_modules/zod/v4/locales/nl.cjs +122 -0
- package/dist/node_modules/zod/v4/locales/nl.js +120 -0
- package/dist/node_modules/zod/v4/locales/no.cjs +121 -0
- package/dist/node_modules/zod/v4/locales/no.js +119 -0
- package/dist/node_modules/zod/v4/locales/ota.cjs +122 -0
- package/dist/node_modules/zod/v4/locales/ota.js +120 -0
- package/dist/node_modules/zod/v4/locales/pl.cjs +122 -0
- package/dist/node_modules/zod/v4/locales/pl.js +120 -0
- package/dist/node_modules/zod/v4/locales/ps.cjs +127 -0
- package/dist/node_modules/zod/v4/locales/ps.js +125 -0
- package/dist/node_modules/zod/v4/locales/pt.cjs +121 -0
- package/dist/node_modules/zod/v4/locales/pt.js +119 -0
- package/dist/node_modules/zod/v4/locales/ru.cjs +169 -0
- package/dist/node_modules/zod/v4/locales/ru.js +167 -0
- package/dist/node_modules/zod/v4/locales/sl.cjs +122 -0
- package/dist/node_modules/zod/v4/locales/sl.js +120 -0
- package/dist/node_modules/zod/v4/locales/sv.cjs +123 -0
- package/dist/node_modules/zod/v4/locales/sv.js +121 -0
- package/dist/node_modules/zod/v4/locales/ta.cjs +122 -0
- package/dist/node_modules/zod/v4/locales/ta.js +120 -0
- package/dist/node_modules/zod/v4/locales/th.cjs +122 -0
- package/dist/node_modules/zod/v4/locales/th.js +120 -0
- package/dist/node_modules/zod/v4/locales/tr.cjs +123 -0
- package/dist/node_modules/zod/v4/locales/tr.js +118 -0
- package/dist/node_modules/zod/v4/locales/ua.cjs +122 -0
- package/dist/node_modules/zod/v4/locales/ua.js +120 -0
- package/dist/node_modules/zod/v4/locales/ur.cjs +122 -0
- package/dist/node_modules/zod/v4/locales/ur.js +120 -0
- package/dist/node_modules/zod/v4/locales/vi.cjs +121 -0
- package/dist/node_modules/zod/v4/locales/vi.js +119 -0
- package/dist/node_modules/zod/v4/locales/zh-CN.cjs +121 -0
- package/dist/node_modules/zod/v4/locales/zh-CN.js +119 -0
- package/dist/node_modules/zod/v4/locales/zh-TW.cjs +122 -0
- package/dist/node_modules/zod/v4/locales/zh-TW.js +120 -0
- package/package.json +1 -1
|
@@ -0,0 +1,1006 @@
|
|
|
1
|
+
import { datetime, date as date$1, time, duration } from './iso.js';
|
|
2
|
+
import { parse, safeParse, parseAsync, safeParseAsync } from './parse.js';
|
|
3
|
+
import { $constructor } from '../core/core.js';
|
|
4
|
+
import { _stringbool, _string, _email, _guid, _uuid, _uuidv4, _uuidv6, _uuidv7, _url, _emoji, _nanoid, _cuid, _cuid2, _ulid, _xid, _ksuid, _ipv4, _ipv6, _cidrv4, _cidrv6, _base64, _base64url, _e164, _jwt, _stringFormat, _number, _int, _float32, _float64, _int32, _uint32, _boolean, _bigint, _int64, _uint64, _symbol, _undefined as _undefined$1, _null as _null$1, _any, _unknown, _never, _void as _void$1, _date, _array, _file, _nan, _custom, _refine, _overwrite, _regex, _includes, _startsWith, _endsWith, _minLength, _maxLength, _length, _lowercase, _uppercase, _trim, _normalize, _toLowerCase, _toUpperCase, _gt, _gte, _lt, _lte, _multipleOf, _minSize, _maxSize, _size, _mime } from '../core/api.js';
|
|
5
|
+
import { normalizeParams, assignProp, issue, clone, defineLazy, extend, merge, pick, omit, partial, required } from '../core/util.js';
|
|
6
|
+
import { $ZodCheck } from '../core/checks.js';
|
|
7
|
+
import { $ZodType, $ZodString, $ZodStringFormat, $ZodEmail, $ZodGUID, $ZodUUID, $ZodURL, $ZodEmoji, $ZodNanoID, $ZodCUID, $ZodCUID2, $ZodULID, $ZodXID, $ZodKSUID, $ZodIPv4, $ZodIPv6, $ZodCIDRv4, $ZodCIDRv6, $ZodBase64, $ZodBase64URL, $ZodE164, $ZodJWT, $ZodCustomStringFormat, $ZodNumber, $ZodNumberFormat, $ZodBoolean, $ZodBigInt, $ZodBigIntFormat, $ZodSymbol, $ZodUndefined, $ZodNull, $ZodAny, $ZodUnknown, $ZodNever, $ZodVoid, $ZodDate, $ZodArray, $ZodObject, $ZodUnion, $ZodDiscriminatedUnion, $ZodIntersection, $ZodTuple, $ZodRecord, $ZodMap, $ZodSet, $ZodEnum, $ZodLiteral, $ZodFile, $ZodTransform, $ZodOptional, $ZodNullable, $ZodDefault, $ZodPrefault, $ZodNonOptional, $ZodSuccess, $ZodCatch, $ZodNaN, $ZodPipe, $ZodReadonly, $ZodTemplateLiteral, $ZodLazy, $ZodPromise, $ZodCustom } from '../core/schemas.js';
|
|
8
|
+
import { globalRegistry } from '../core/registries.js';
|
|
9
|
+
|
|
10
|
+
const ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
|
|
11
|
+
$ZodType.init(inst, def);
|
|
12
|
+
inst.def = def;
|
|
13
|
+
Object.defineProperty(inst, "_def", { value: def });
|
|
14
|
+
// base methods
|
|
15
|
+
inst.check = (...checks) => {
|
|
16
|
+
return inst.clone({
|
|
17
|
+
...def,
|
|
18
|
+
checks: [
|
|
19
|
+
...(def.checks ?? []),
|
|
20
|
+
...checks.map((ch) => typeof ch === "function" ? { _zod: { check: ch, def: { check: "custom" }, onattach: [] } } : ch),
|
|
21
|
+
],
|
|
22
|
+
}
|
|
23
|
+
// { parent: true }
|
|
24
|
+
);
|
|
25
|
+
};
|
|
26
|
+
inst.clone = (def, params) => clone(inst, def, params);
|
|
27
|
+
inst.brand = () => inst;
|
|
28
|
+
inst.register = ((reg, meta) => {
|
|
29
|
+
reg.add(inst, meta);
|
|
30
|
+
return inst;
|
|
31
|
+
});
|
|
32
|
+
// parsing
|
|
33
|
+
inst.parse = (data, params) => parse(inst, data, params, { callee: inst.parse });
|
|
34
|
+
inst.safeParse = (data, params) => safeParse(inst, data, params);
|
|
35
|
+
inst.parseAsync = async (data, params) => parseAsync(inst, data, params, { callee: inst.parseAsync });
|
|
36
|
+
inst.safeParseAsync = async (data, params) => safeParseAsync(inst, data, params);
|
|
37
|
+
inst.spa = inst.safeParseAsync;
|
|
38
|
+
// refinements
|
|
39
|
+
inst.refine = (check, params) => inst.check(refine(check, params));
|
|
40
|
+
inst.superRefine = (refinement) => inst.check(superRefine(refinement));
|
|
41
|
+
inst.overwrite = (fn) => inst.check(_overwrite(fn));
|
|
42
|
+
// wrappers
|
|
43
|
+
inst.optional = () => optional(inst);
|
|
44
|
+
inst.nullable = () => nullable(inst);
|
|
45
|
+
inst.nullish = () => optional(nullable(inst));
|
|
46
|
+
inst.nonoptional = (params) => nonoptional(inst, params);
|
|
47
|
+
inst.array = () => array(inst);
|
|
48
|
+
inst.or = (arg) => union([inst, arg]);
|
|
49
|
+
inst.and = (arg) => intersection(inst, arg);
|
|
50
|
+
inst.transform = (tx) => pipe(inst, transform(tx));
|
|
51
|
+
inst.default = (def) => _default(inst, def);
|
|
52
|
+
inst.prefault = (def) => prefault(inst, def);
|
|
53
|
+
// inst.coalesce = (def, params) => coalesce(inst, def, params);
|
|
54
|
+
inst.catch = (params) => _catch(inst, params);
|
|
55
|
+
inst.pipe = (target) => pipe(inst, target);
|
|
56
|
+
inst.readonly = () => readonly(inst);
|
|
57
|
+
// meta
|
|
58
|
+
inst.describe = (description) => {
|
|
59
|
+
const cl = inst.clone();
|
|
60
|
+
globalRegistry.add(cl, { description });
|
|
61
|
+
return cl;
|
|
62
|
+
};
|
|
63
|
+
Object.defineProperty(inst, "description", {
|
|
64
|
+
get() {
|
|
65
|
+
return globalRegistry.get(inst)?.description;
|
|
66
|
+
},
|
|
67
|
+
configurable: true,
|
|
68
|
+
});
|
|
69
|
+
inst.meta = (...args) => {
|
|
70
|
+
if (args.length === 0) {
|
|
71
|
+
return globalRegistry.get(inst);
|
|
72
|
+
}
|
|
73
|
+
const cl = inst.clone();
|
|
74
|
+
globalRegistry.add(cl, args[0]);
|
|
75
|
+
return cl;
|
|
76
|
+
};
|
|
77
|
+
// helpers
|
|
78
|
+
inst.isOptional = () => inst.safeParse(undefined).success;
|
|
79
|
+
inst.isNullable = () => inst.safeParse(null).success;
|
|
80
|
+
return inst;
|
|
81
|
+
});
|
|
82
|
+
/** @internal */
|
|
83
|
+
const _ZodString = /*@__PURE__*/ $constructor("_ZodString", (inst, def) => {
|
|
84
|
+
$ZodString.init(inst, def);
|
|
85
|
+
ZodType.init(inst, def);
|
|
86
|
+
const bag = inst._zod.bag;
|
|
87
|
+
inst.format = bag.format ?? null;
|
|
88
|
+
inst.minLength = bag.minimum ?? null;
|
|
89
|
+
inst.maxLength = bag.maximum ?? null;
|
|
90
|
+
// validations
|
|
91
|
+
inst.regex = (...args) => inst.check(_regex(...args));
|
|
92
|
+
inst.includes = (...args) => inst.check(_includes(...args));
|
|
93
|
+
inst.startsWith = (...args) => inst.check(_startsWith(...args));
|
|
94
|
+
inst.endsWith = (...args) => inst.check(_endsWith(...args));
|
|
95
|
+
inst.min = (...args) => inst.check(_minLength(...args));
|
|
96
|
+
inst.max = (...args) => inst.check(_maxLength(...args));
|
|
97
|
+
inst.length = (...args) => inst.check(_length(...args));
|
|
98
|
+
inst.nonempty = (...args) => inst.check(_minLength(1, ...args));
|
|
99
|
+
inst.lowercase = (params) => inst.check(_lowercase(params));
|
|
100
|
+
inst.uppercase = (params) => inst.check(_uppercase(params));
|
|
101
|
+
// transforms
|
|
102
|
+
inst.trim = () => inst.check(_trim());
|
|
103
|
+
inst.normalize = (...args) => inst.check(_normalize(...args));
|
|
104
|
+
inst.toLowerCase = () => inst.check(_toLowerCase());
|
|
105
|
+
inst.toUpperCase = () => inst.check(_toUpperCase());
|
|
106
|
+
});
|
|
107
|
+
const ZodString = /*@__PURE__*/ $constructor("ZodString", (inst, def) => {
|
|
108
|
+
$ZodString.init(inst, def);
|
|
109
|
+
_ZodString.init(inst, def);
|
|
110
|
+
inst.email = (params) => inst.check(_email(ZodEmail, params));
|
|
111
|
+
inst.url = (params) => inst.check(_url(ZodURL, params));
|
|
112
|
+
inst.jwt = (params) => inst.check(_jwt(ZodJWT, params));
|
|
113
|
+
inst.emoji = (params) => inst.check(_emoji(ZodEmoji, params));
|
|
114
|
+
inst.guid = (params) => inst.check(_guid(ZodGUID, params));
|
|
115
|
+
inst.uuid = (params) => inst.check(_uuid(ZodUUID, params));
|
|
116
|
+
inst.uuidv4 = (params) => inst.check(_uuidv4(ZodUUID, params));
|
|
117
|
+
inst.uuidv6 = (params) => inst.check(_uuidv6(ZodUUID, params));
|
|
118
|
+
inst.uuidv7 = (params) => inst.check(_uuidv7(ZodUUID, params));
|
|
119
|
+
inst.nanoid = (params) => inst.check(_nanoid(ZodNanoID, params));
|
|
120
|
+
inst.guid = (params) => inst.check(_guid(ZodGUID, params));
|
|
121
|
+
inst.cuid = (params) => inst.check(_cuid(ZodCUID, params));
|
|
122
|
+
inst.cuid2 = (params) => inst.check(_cuid2(ZodCUID2, params));
|
|
123
|
+
inst.ulid = (params) => inst.check(_ulid(ZodULID, params));
|
|
124
|
+
inst.base64 = (params) => inst.check(_base64(ZodBase64, params));
|
|
125
|
+
inst.base64url = (params) => inst.check(_base64url(ZodBase64URL, params));
|
|
126
|
+
inst.xid = (params) => inst.check(_xid(ZodXID, params));
|
|
127
|
+
inst.ksuid = (params) => inst.check(_ksuid(ZodKSUID, params));
|
|
128
|
+
inst.ipv4 = (params) => inst.check(_ipv4(ZodIPv4, params));
|
|
129
|
+
inst.ipv6 = (params) => inst.check(_ipv6(ZodIPv6, params));
|
|
130
|
+
inst.cidrv4 = (params) => inst.check(_cidrv4(ZodCIDRv4, params));
|
|
131
|
+
inst.cidrv6 = (params) => inst.check(_cidrv6(ZodCIDRv6, params));
|
|
132
|
+
inst.e164 = (params) => inst.check(_e164(ZodE164, params));
|
|
133
|
+
// iso
|
|
134
|
+
inst.datetime = (params) => inst.check(datetime(params));
|
|
135
|
+
inst.date = (params) => inst.check(date$1(params));
|
|
136
|
+
inst.time = (params) => inst.check(time(params));
|
|
137
|
+
inst.duration = (params) => inst.check(duration(params));
|
|
138
|
+
});
|
|
139
|
+
function string(params) {
|
|
140
|
+
return _string(ZodString, params);
|
|
141
|
+
}
|
|
142
|
+
const ZodStringFormat = /*@__PURE__*/ $constructor("ZodStringFormat", (inst, def) => {
|
|
143
|
+
$ZodStringFormat.init(inst, def);
|
|
144
|
+
_ZodString.init(inst, def);
|
|
145
|
+
});
|
|
146
|
+
const ZodEmail = /*@__PURE__*/ $constructor("ZodEmail", (inst, def) => {
|
|
147
|
+
// ZodStringFormat.init(inst, def);
|
|
148
|
+
$ZodEmail.init(inst, def);
|
|
149
|
+
ZodStringFormat.init(inst, def);
|
|
150
|
+
});
|
|
151
|
+
function email(params) {
|
|
152
|
+
return _email(ZodEmail, params);
|
|
153
|
+
}
|
|
154
|
+
const ZodGUID = /*@__PURE__*/ $constructor("ZodGUID", (inst, def) => {
|
|
155
|
+
// ZodStringFormat.init(inst, def);
|
|
156
|
+
$ZodGUID.init(inst, def);
|
|
157
|
+
ZodStringFormat.init(inst, def);
|
|
158
|
+
});
|
|
159
|
+
function guid(params) {
|
|
160
|
+
return _guid(ZodGUID, params);
|
|
161
|
+
}
|
|
162
|
+
const ZodUUID = /*@__PURE__*/ $constructor("ZodUUID", (inst, def) => {
|
|
163
|
+
// ZodStringFormat.init(inst, def);
|
|
164
|
+
$ZodUUID.init(inst, def);
|
|
165
|
+
ZodStringFormat.init(inst, def);
|
|
166
|
+
});
|
|
167
|
+
function uuid(params) {
|
|
168
|
+
return _uuid(ZodUUID, params);
|
|
169
|
+
}
|
|
170
|
+
function uuidv4(params) {
|
|
171
|
+
return _uuidv4(ZodUUID, params);
|
|
172
|
+
}
|
|
173
|
+
// ZodUUIDv6
|
|
174
|
+
function uuidv6(params) {
|
|
175
|
+
return _uuidv6(ZodUUID, params);
|
|
176
|
+
}
|
|
177
|
+
// ZodUUIDv7
|
|
178
|
+
function uuidv7(params) {
|
|
179
|
+
return _uuidv7(ZodUUID, params);
|
|
180
|
+
}
|
|
181
|
+
const ZodURL = /*@__PURE__*/ $constructor("ZodURL", (inst, def) => {
|
|
182
|
+
// ZodStringFormat.init(inst, def);
|
|
183
|
+
$ZodURL.init(inst, def);
|
|
184
|
+
ZodStringFormat.init(inst, def);
|
|
185
|
+
});
|
|
186
|
+
function url(params) {
|
|
187
|
+
return _url(ZodURL, params);
|
|
188
|
+
}
|
|
189
|
+
const ZodEmoji = /*@__PURE__*/ $constructor("ZodEmoji", (inst, def) => {
|
|
190
|
+
// ZodStringFormat.init(inst, def);
|
|
191
|
+
$ZodEmoji.init(inst, def);
|
|
192
|
+
ZodStringFormat.init(inst, def);
|
|
193
|
+
});
|
|
194
|
+
function emoji(params) {
|
|
195
|
+
return _emoji(ZodEmoji, params);
|
|
196
|
+
}
|
|
197
|
+
const ZodNanoID = /*@__PURE__*/ $constructor("ZodNanoID", (inst, def) => {
|
|
198
|
+
// ZodStringFormat.init(inst, def);
|
|
199
|
+
$ZodNanoID.init(inst, def);
|
|
200
|
+
ZodStringFormat.init(inst, def);
|
|
201
|
+
});
|
|
202
|
+
function nanoid(params) {
|
|
203
|
+
return _nanoid(ZodNanoID, params);
|
|
204
|
+
}
|
|
205
|
+
const ZodCUID = /*@__PURE__*/ $constructor("ZodCUID", (inst, def) => {
|
|
206
|
+
// ZodStringFormat.init(inst, def);
|
|
207
|
+
$ZodCUID.init(inst, def);
|
|
208
|
+
ZodStringFormat.init(inst, def);
|
|
209
|
+
});
|
|
210
|
+
function cuid(params) {
|
|
211
|
+
return _cuid(ZodCUID, params);
|
|
212
|
+
}
|
|
213
|
+
const ZodCUID2 = /*@__PURE__*/ $constructor("ZodCUID2", (inst, def) => {
|
|
214
|
+
// ZodStringFormat.init(inst, def);
|
|
215
|
+
$ZodCUID2.init(inst, def);
|
|
216
|
+
ZodStringFormat.init(inst, def);
|
|
217
|
+
});
|
|
218
|
+
function cuid2(params) {
|
|
219
|
+
return _cuid2(ZodCUID2, params);
|
|
220
|
+
}
|
|
221
|
+
const ZodULID = /*@__PURE__*/ $constructor("ZodULID", (inst, def) => {
|
|
222
|
+
// ZodStringFormat.init(inst, def);
|
|
223
|
+
$ZodULID.init(inst, def);
|
|
224
|
+
ZodStringFormat.init(inst, def);
|
|
225
|
+
});
|
|
226
|
+
function ulid(params) {
|
|
227
|
+
return _ulid(ZodULID, params);
|
|
228
|
+
}
|
|
229
|
+
const ZodXID = /*@__PURE__*/ $constructor("ZodXID", (inst, def) => {
|
|
230
|
+
// ZodStringFormat.init(inst, def);
|
|
231
|
+
$ZodXID.init(inst, def);
|
|
232
|
+
ZodStringFormat.init(inst, def);
|
|
233
|
+
});
|
|
234
|
+
function xid(params) {
|
|
235
|
+
return _xid(ZodXID, params);
|
|
236
|
+
}
|
|
237
|
+
const ZodKSUID = /*@__PURE__*/ $constructor("ZodKSUID", (inst, def) => {
|
|
238
|
+
// ZodStringFormat.init(inst, def);
|
|
239
|
+
$ZodKSUID.init(inst, def);
|
|
240
|
+
ZodStringFormat.init(inst, def);
|
|
241
|
+
});
|
|
242
|
+
function ksuid(params) {
|
|
243
|
+
return _ksuid(ZodKSUID, params);
|
|
244
|
+
}
|
|
245
|
+
const ZodIPv4 = /*@__PURE__*/ $constructor("ZodIPv4", (inst, def) => {
|
|
246
|
+
// ZodStringFormat.init(inst, def);
|
|
247
|
+
$ZodIPv4.init(inst, def);
|
|
248
|
+
ZodStringFormat.init(inst, def);
|
|
249
|
+
});
|
|
250
|
+
function ipv4(params) {
|
|
251
|
+
return _ipv4(ZodIPv4, params);
|
|
252
|
+
}
|
|
253
|
+
const ZodIPv6 = /*@__PURE__*/ $constructor("ZodIPv6", (inst, def) => {
|
|
254
|
+
// ZodStringFormat.init(inst, def);
|
|
255
|
+
$ZodIPv6.init(inst, def);
|
|
256
|
+
ZodStringFormat.init(inst, def);
|
|
257
|
+
});
|
|
258
|
+
function ipv6(params) {
|
|
259
|
+
return _ipv6(ZodIPv6, params);
|
|
260
|
+
}
|
|
261
|
+
const ZodCIDRv4 = /*@__PURE__*/ $constructor("ZodCIDRv4", (inst, def) => {
|
|
262
|
+
$ZodCIDRv4.init(inst, def);
|
|
263
|
+
ZodStringFormat.init(inst, def);
|
|
264
|
+
});
|
|
265
|
+
function cidrv4(params) {
|
|
266
|
+
return _cidrv4(ZodCIDRv4, params);
|
|
267
|
+
}
|
|
268
|
+
const ZodCIDRv6 = /*@__PURE__*/ $constructor("ZodCIDRv6", (inst, def) => {
|
|
269
|
+
$ZodCIDRv6.init(inst, def);
|
|
270
|
+
ZodStringFormat.init(inst, def);
|
|
271
|
+
});
|
|
272
|
+
function cidrv6(params) {
|
|
273
|
+
return _cidrv6(ZodCIDRv6, params);
|
|
274
|
+
}
|
|
275
|
+
const ZodBase64 = /*@__PURE__*/ $constructor("ZodBase64", (inst, def) => {
|
|
276
|
+
// ZodStringFormat.init(inst, def);
|
|
277
|
+
$ZodBase64.init(inst, def);
|
|
278
|
+
ZodStringFormat.init(inst, def);
|
|
279
|
+
});
|
|
280
|
+
function base64(params) {
|
|
281
|
+
return _base64(ZodBase64, params);
|
|
282
|
+
}
|
|
283
|
+
const ZodBase64URL = /*@__PURE__*/ $constructor("ZodBase64URL", (inst, def) => {
|
|
284
|
+
// ZodStringFormat.init(inst, def);
|
|
285
|
+
$ZodBase64URL.init(inst, def);
|
|
286
|
+
ZodStringFormat.init(inst, def);
|
|
287
|
+
});
|
|
288
|
+
function base64url(params) {
|
|
289
|
+
return _base64url(ZodBase64URL, params);
|
|
290
|
+
}
|
|
291
|
+
const ZodE164 = /*@__PURE__*/ $constructor("ZodE164", (inst, def) => {
|
|
292
|
+
// ZodStringFormat.init(inst, def);
|
|
293
|
+
$ZodE164.init(inst, def);
|
|
294
|
+
ZodStringFormat.init(inst, def);
|
|
295
|
+
});
|
|
296
|
+
function e164(params) {
|
|
297
|
+
return _e164(ZodE164, params);
|
|
298
|
+
}
|
|
299
|
+
const ZodJWT = /*@__PURE__*/ $constructor("ZodJWT", (inst, def) => {
|
|
300
|
+
// ZodStringFormat.init(inst, def);
|
|
301
|
+
$ZodJWT.init(inst, def);
|
|
302
|
+
ZodStringFormat.init(inst, def);
|
|
303
|
+
});
|
|
304
|
+
function jwt(params) {
|
|
305
|
+
return _jwt(ZodJWT, params);
|
|
306
|
+
}
|
|
307
|
+
const ZodCustomStringFormat = /*@__PURE__*/ $constructor("ZodCustomStringFormat", (inst, def) => {
|
|
308
|
+
// ZodStringFormat.init(inst, def);
|
|
309
|
+
$ZodCustomStringFormat.init(inst, def);
|
|
310
|
+
ZodStringFormat.init(inst, def);
|
|
311
|
+
});
|
|
312
|
+
function stringFormat(format, fnOrRegex, _params = {}) {
|
|
313
|
+
return _stringFormat(ZodCustomStringFormat, format, fnOrRegex, _params);
|
|
314
|
+
}
|
|
315
|
+
const ZodNumber = /*@__PURE__*/ $constructor("ZodNumber", (inst, def) => {
|
|
316
|
+
$ZodNumber.init(inst, def);
|
|
317
|
+
ZodType.init(inst, def);
|
|
318
|
+
inst.gt = (value, params) => inst.check(_gt(value, params));
|
|
319
|
+
inst.gte = (value, params) => inst.check(_gte(value, params));
|
|
320
|
+
inst.min = (value, params) => inst.check(_gte(value, params));
|
|
321
|
+
inst.lt = (value, params) => inst.check(_lt(value, params));
|
|
322
|
+
inst.lte = (value, params) => inst.check(_lte(value, params));
|
|
323
|
+
inst.max = (value, params) => inst.check(_lte(value, params));
|
|
324
|
+
inst.int = (params) => inst.check(int(params));
|
|
325
|
+
inst.safe = (params) => inst.check(int(params));
|
|
326
|
+
inst.positive = (params) => inst.check(_gt(0, params));
|
|
327
|
+
inst.nonnegative = (params) => inst.check(_gte(0, params));
|
|
328
|
+
inst.negative = (params) => inst.check(_lt(0, params));
|
|
329
|
+
inst.nonpositive = (params) => inst.check(_lte(0, params));
|
|
330
|
+
inst.multipleOf = (value, params) => inst.check(_multipleOf(value, params));
|
|
331
|
+
inst.step = (value, params) => inst.check(_multipleOf(value, params));
|
|
332
|
+
// inst.finite = (params) => inst.check(core.finite(params));
|
|
333
|
+
inst.finite = () => inst;
|
|
334
|
+
const bag = inst._zod.bag;
|
|
335
|
+
inst.minValue =
|
|
336
|
+
Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;
|
|
337
|
+
inst.maxValue =
|
|
338
|
+
Math.min(bag.maximum ?? Number.POSITIVE_INFINITY, bag.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null;
|
|
339
|
+
inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? 0.5);
|
|
340
|
+
inst.isFinite = true;
|
|
341
|
+
inst.format = bag.format ?? null;
|
|
342
|
+
});
|
|
343
|
+
function number(params) {
|
|
344
|
+
return _number(ZodNumber, params);
|
|
345
|
+
}
|
|
346
|
+
const ZodNumberFormat = /*@__PURE__*/ $constructor("ZodNumberFormat", (inst, def) => {
|
|
347
|
+
$ZodNumberFormat.init(inst, def);
|
|
348
|
+
ZodNumber.init(inst, def);
|
|
349
|
+
});
|
|
350
|
+
function int(params) {
|
|
351
|
+
return _int(ZodNumberFormat, params);
|
|
352
|
+
}
|
|
353
|
+
function float32(params) {
|
|
354
|
+
return _float32(ZodNumberFormat, params);
|
|
355
|
+
}
|
|
356
|
+
function float64(params) {
|
|
357
|
+
return _float64(ZodNumberFormat, params);
|
|
358
|
+
}
|
|
359
|
+
function int32(params) {
|
|
360
|
+
return _int32(ZodNumberFormat, params);
|
|
361
|
+
}
|
|
362
|
+
function uint32(params) {
|
|
363
|
+
return _uint32(ZodNumberFormat, params);
|
|
364
|
+
}
|
|
365
|
+
const ZodBoolean = /*@__PURE__*/ $constructor("ZodBoolean", (inst, def) => {
|
|
366
|
+
$ZodBoolean.init(inst, def);
|
|
367
|
+
ZodType.init(inst, def);
|
|
368
|
+
});
|
|
369
|
+
function boolean(params) {
|
|
370
|
+
return _boolean(ZodBoolean, params);
|
|
371
|
+
}
|
|
372
|
+
const ZodBigInt = /*@__PURE__*/ $constructor("ZodBigInt", (inst, def) => {
|
|
373
|
+
$ZodBigInt.init(inst, def);
|
|
374
|
+
ZodType.init(inst, def);
|
|
375
|
+
inst.gte = (value, params) => inst.check(_gte(value, params));
|
|
376
|
+
inst.min = (value, params) => inst.check(_gte(value, params));
|
|
377
|
+
inst.gt = (value, params) => inst.check(_gt(value, params));
|
|
378
|
+
inst.gte = (value, params) => inst.check(_gte(value, params));
|
|
379
|
+
inst.min = (value, params) => inst.check(_gte(value, params));
|
|
380
|
+
inst.lt = (value, params) => inst.check(_lt(value, params));
|
|
381
|
+
inst.lte = (value, params) => inst.check(_lte(value, params));
|
|
382
|
+
inst.max = (value, params) => inst.check(_lte(value, params));
|
|
383
|
+
inst.positive = (params) => inst.check(_gt(BigInt(0), params));
|
|
384
|
+
inst.negative = (params) => inst.check(_lt(BigInt(0), params));
|
|
385
|
+
inst.nonpositive = (params) => inst.check(_lte(BigInt(0), params));
|
|
386
|
+
inst.nonnegative = (params) => inst.check(_gte(BigInt(0), params));
|
|
387
|
+
inst.multipleOf = (value, params) => inst.check(_multipleOf(value, params));
|
|
388
|
+
const bag = inst._zod.bag;
|
|
389
|
+
inst.minValue = bag.minimum ?? null;
|
|
390
|
+
inst.maxValue = bag.maximum ?? null;
|
|
391
|
+
inst.format = bag.format ?? null;
|
|
392
|
+
});
|
|
393
|
+
function bigint(params) {
|
|
394
|
+
return _bigint(ZodBigInt, params);
|
|
395
|
+
}
|
|
396
|
+
const ZodBigIntFormat = /*@__PURE__*/ $constructor("ZodBigIntFormat", (inst, def) => {
|
|
397
|
+
$ZodBigIntFormat.init(inst, def);
|
|
398
|
+
ZodBigInt.init(inst, def);
|
|
399
|
+
});
|
|
400
|
+
// int64
|
|
401
|
+
function int64(params) {
|
|
402
|
+
return _int64(ZodBigIntFormat, params);
|
|
403
|
+
}
|
|
404
|
+
// uint64
|
|
405
|
+
function uint64(params) {
|
|
406
|
+
return _uint64(ZodBigIntFormat, params);
|
|
407
|
+
}
|
|
408
|
+
const ZodSymbol = /*@__PURE__*/ $constructor("ZodSymbol", (inst, def) => {
|
|
409
|
+
$ZodSymbol.init(inst, def);
|
|
410
|
+
ZodType.init(inst, def);
|
|
411
|
+
});
|
|
412
|
+
function symbol(params) {
|
|
413
|
+
return _symbol(ZodSymbol, params);
|
|
414
|
+
}
|
|
415
|
+
const ZodUndefined = /*@__PURE__*/ $constructor("ZodUndefined", (inst, def) => {
|
|
416
|
+
$ZodUndefined.init(inst, def);
|
|
417
|
+
ZodType.init(inst, def);
|
|
418
|
+
});
|
|
419
|
+
function _undefined(params) {
|
|
420
|
+
return _undefined$1(ZodUndefined, params);
|
|
421
|
+
}
|
|
422
|
+
const ZodNull = /*@__PURE__*/ $constructor("ZodNull", (inst, def) => {
|
|
423
|
+
$ZodNull.init(inst, def);
|
|
424
|
+
ZodType.init(inst, def);
|
|
425
|
+
});
|
|
426
|
+
function _null(params) {
|
|
427
|
+
return _null$1(ZodNull, params);
|
|
428
|
+
}
|
|
429
|
+
const ZodAny = /*@__PURE__*/ $constructor("ZodAny", (inst, def) => {
|
|
430
|
+
$ZodAny.init(inst, def);
|
|
431
|
+
ZodType.init(inst, def);
|
|
432
|
+
});
|
|
433
|
+
function any() {
|
|
434
|
+
return _any(ZodAny);
|
|
435
|
+
}
|
|
436
|
+
const ZodUnknown = /*@__PURE__*/ $constructor("ZodUnknown", (inst, def) => {
|
|
437
|
+
$ZodUnknown.init(inst, def);
|
|
438
|
+
ZodType.init(inst, def);
|
|
439
|
+
});
|
|
440
|
+
function unknown() {
|
|
441
|
+
return _unknown(ZodUnknown);
|
|
442
|
+
}
|
|
443
|
+
const ZodNever = /*@__PURE__*/ $constructor("ZodNever", (inst, def) => {
|
|
444
|
+
$ZodNever.init(inst, def);
|
|
445
|
+
ZodType.init(inst, def);
|
|
446
|
+
});
|
|
447
|
+
function never(params) {
|
|
448
|
+
return _never(ZodNever, params);
|
|
449
|
+
}
|
|
450
|
+
const ZodVoid = /*@__PURE__*/ $constructor("ZodVoid", (inst, def) => {
|
|
451
|
+
$ZodVoid.init(inst, def);
|
|
452
|
+
ZodType.init(inst, def);
|
|
453
|
+
});
|
|
454
|
+
function _void(params) {
|
|
455
|
+
return _void$1(ZodVoid, params);
|
|
456
|
+
}
|
|
457
|
+
const ZodDate = /*@__PURE__*/ $constructor("ZodDate", (inst, def) => {
|
|
458
|
+
$ZodDate.init(inst, def);
|
|
459
|
+
ZodType.init(inst, def);
|
|
460
|
+
inst.min = (value, params) => inst.check(_gte(value, params));
|
|
461
|
+
inst.max = (value, params) => inst.check(_lte(value, params));
|
|
462
|
+
const c = inst._zod.bag;
|
|
463
|
+
inst.minDate = c.minimum ? new Date(c.minimum) : null;
|
|
464
|
+
inst.maxDate = c.maximum ? new Date(c.maximum) : null;
|
|
465
|
+
});
|
|
466
|
+
function date(params) {
|
|
467
|
+
return _date(ZodDate, params);
|
|
468
|
+
}
|
|
469
|
+
const ZodArray = /*@__PURE__*/ $constructor("ZodArray", (inst, def) => {
|
|
470
|
+
$ZodArray.init(inst, def);
|
|
471
|
+
ZodType.init(inst, def);
|
|
472
|
+
inst.element = def.element;
|
|
473
|
+
inst.min = (minLength, params) => inst.check(_minLength(minLength, params));
|
|
474
|
+
inst.nonempty = (params) => inst.check(_minLength(1, params));
|
|
475
|
+
inst.max = (maxLength, params) => inst.check(_maxLength(maxLength, params));
|
|
476
|
+
inst.length = (len, params) => inst.check(_length(len, params));
|
|
477
|
+
inst.unwrap = () => inst.element;
|
|
478
|
+
});
|
|
479
|
+
function array(element, params) {
|
|
480
|
+
return _array(ZodArray, element, params);
|
|
481
|
+
}
|
|
482
|
+
// .keyof
|
|
483
|
+
function keyof(schema) {
|
|
484
|
+
const shape = schema._zod.def.shape;
|
|
485
|
+
return literal(Object.keys(shape));
|
|
486
|
+
}
|
|
487
|
+
const ZodObject = /*@__PURE__*/ $constructor("ZodObject", (inst, def) => {
|
|
488
|
+
$ZodObject.init(inst, def);
|
|
489
|
+
ZodType.init(inst, def);
|
|
490
|
+
defineLazy(inst, "shape", () => def.shape);
|
|
491
|
+
inst.keyof = () => _enum(Object.keys(inst._zod.def.shape));
|
|
492
|
+
inst.catchall = (catchall) => inst.clone({ ...inst._zod.def, catchall: catchall });
|
|
493
|
+
inst.passthrough = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
|
|
494
|
+
// inst.nonstrict = () => inst.clone({ ...inst._zod.def, catchall: api.unknown() });
|
|
495
|
+
inst.loose = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
|
|
496
|
+
inst.strict = () => inst.clone({ ...inst._zod.def, catchall: never() });
|
|
497
|
+
inst.strip = () => inst.clone({ ...inst._zod.def, catchall: undefined });
|
|
498
|
+
inst.extend = (incoming) => {
|
|
499
|
+
return extend(inst, incoming);
|
|
500
|
+
};
|
|
501
|
+
inst.merge = (other) => merge(inst, other);
|
|
502
|
+
inst.pick = (mask) => pick(inst, mask);
|
|
503
|
+
inst.omit = (mask) => omit(inst, mask);
|
|
504
|
+
inst.partial = (...args) => partial(ZodOptional, inst, args[0]);
|
|
505
|
+
inst.required = (...args) => required(ZodNonOptional, inst, args[0]);
|
|
506
|
+
});
|
|
507
|
+
function object(shape, params) {
|
|
508
|
+
const def = {
|
|
509
|
+
type: "object",
|
|
510
|
+
get shape() {
|
|
511
|
+
assignProp(this, "shape", { ...shape });
|
|
512
|
+
return this.shape;
|
|
513
|
+
},
|
|
514
|
+
...normalizeParams(params),
|
|
515
|
+
};
|
|
516
|
+
return new ZodObject(def);
|
|
517
|
+
}
|
|
518
|
+
// strictObject
|
|
519
|
+
function strictObject(shape, params) {
|
|
520
|
+
return new ZodObject({
|
|
521
|
+
type: "object",
|
|
522
|
+
get shape() {
|
|
523
|
+
assignProp(this, "shape", { ...shape });
|
|
524
|
+
return this.shape;
|
|
525
|
+
},
|
|
526
|
+
catchall: never(),
|
|
527
|
+
...normalizeParams(params),
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
// looseObject
|
|
531
|
+
function looseObject(shape, params) {
|
|
532
|
+
return new ZodObject({
|
|
533
|
+
type: "object",
|
|
534
|
+
get shape() {
|
|
535
|
+
assignProp(this, "shape", { ...shape });
|
|
536
|
+
return this.shape;
|
|
537
|
+
},
|
|
538
|
+
catchall: unknown(),
|
|
539
|
+
...normalizeParams(params),
|
|
540
|
+
});
|
|
541
|
+
}
|
|
542
|
+
const ZodUnion = /*@__PURE__*/ $constructor("ZodUnion", (inst, def) => {
|
|
543
|
+
$ZodUnion.init(inst, def);
|
|
544
|
+
ZodType.init(inst, def);
|
|
545
|
+
inst.options = def.options;
|
|
546
|
+
});
|
|
547
|
+
function union(options, params) {
|
|
548
|
+
return new ZodUnion({
|
|
549
|
+
type: "union",
|
|
550
|
+
options: options,
|
|
551
|
+
...normalizeParams(params),
|
|
552
|
+
});
|
|
553
|
+
}
|
|
554
|
+
const ZodDiscriminatedUnion = /*@__PURE__*/ $constructor("ZodDiscriminatedUnion", (inst, def) => {
|
|
555
|
+
ZodUnion.init(inst, def);
|
|
556
|
+
$ZodDiscriminatedUnion.init(inst, def);
|
|
557
|
+
});
|
|
558
|
+
function discriminatedUnion(discriminator, options, params) {
|
|
559
|
+
// const [options, params] = args;
|
|
560
|
+
return new ZodDiscriminatedUnion({
|
|
561
|
+
type: "union",
|
|
562
|
+
options,
|
|
563
|
+
discriminator,
|
|
564
|
+
...normalizeParams(params),
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
const ZodIntersection = /*@__PURE__*/ $constructor("ZodIntersection", (inst, def) => {
|
|
568
|
+
$ZodIntersection.init(inst, def);
|
|
569
|
+
ZodType.init(inst, def);
|
|
570
|
+
});
|
|
571
|
+
function intersection(left, right) {
|
|
572
|
+
return new ZodIntersection({
|
|
573
|
+
type: "intersection",
|
|
574
|
+
left: left,
|
|
575
|
+
right: right,
|
|
576
|
+
});
|
|
577
|
+
}
|
|
578
|
+
const ZodTuple = /*@__PURE__*/ $constructor("ZodTuple", (inst, def) => {
|
|
579
|
+
$ZodTuple.init(inst, def);
|
|
580
|
+
ZodType.init(inst, def);
|
|
581
|
+
inst.rest = (rest) => inst.clone({
|
|
582
|
+
...inst._zod.def,
|
|
583
|
+
rest: rest,
|
|
584
|
+
});
|
|
585
|
+
});
|
|
586
|
+
function tuple(items, _paramsOrRest, _params) {
|
|
587
|
+
const hasRest = _paramsOrRest instanceof $ZodType;
|
|
588
|
+
const params = hasRest ? _params : _paramsOrRest;
|
|
589
|
+
const rest = hasRest ? _paramsOrRest : null;
|
|
590
|
+
return new ZodTuple({
|
|
591
|
+
type: "tuple",
|
|
592
|
+
items: items,
|
|
593
|
+
rest,
|
|
594
|
+
...normalizeParams(params),
|
|
595
|
+
});
|
|
596
|
+
}
|
|
597
|
+
const ZodRecord = /*@__PURE__*/ $constructor("ZodRecord", (inst, def) => {
|
|
598
|
+
$ZodRecord.init(inst, def);
|
|
599
|
+
ZodType.init(inst, def);
|
|
600
|
+
inst.keyType = def.keyType;
|
|
601
|
+
inst.valueType = def.valueType;
|
|
602
|
+
});
|
|
603
|
+
function record(keyType, valueType, params) {
|
|
604
|
+
return new ZodRecord({
|
|
605
|
+
type: "record",
|
|
606
|
+
keyType,
|
|
607
|
+
valueType: valueType,
|
|
608
|
+
...normalizeParams(params),
|
|
609
|
+
});
|
|
610
|
+
}
|
|
611
|
+
// type alksjf = core.output<core.$ZodRecordKey>;
|
|
612
|
+
function partialRecord(keyType, valueType, params) {
|
|
613
|
+
return new ZodRecord({
|
|
614
|
+
type: "record",
|
|
615
|
+
keyType: union([keyType, never()]),
|
|
616
|
+
valueType: valueType,
|
|
617
|
+
...normalizeParams(params),
|
|
618
|
+
});
|
|
619
|
+
}
|
|
620
|
+
const ZodMap = /*@__PURE__*/ $constructor("ZodMap", (inst, def) => {
|
|
621
|
+
$ZodMap.init(inst, def);
|
|
622
|
+
ZodType.init(inst, def);
|
|
623
|
+
inst.keyType = def.keyType;
|
|
624
|
+
inst.valueType = def.valueType;
|
|
625
|
+
});
|
|
626
|
+
function map(keyType, valueType, params) {
|
|
627
|
+
return new ZodMap({
|
|
628
|
+
type: "map",
|
|
629
|
+
keyType: keyType,
|
|
630
|
+
valueType: valueType,
|
|
631
|
+
...normalizeParams(params),
|
|
632
|
+
});
|
|
633
|
+
}
|
|
634
|
+
const ZodSet = /*@__PURE__*/ $constructor("ZodSet", (inst, def) => {
|
|
635
|
+
$ZodSet.init(inst, def);
|
|
636
|
+
ZodType.init(inst, def);
|
|
637
|
+
inst.min = (...args) => inst.check(_minSize(...args));
|
|
638
|
+
inst.nonempty = (params) => inst.check(_minSize(1, params));
|
|
639
|
+
inst.max = (...args) => inst.check(_maxSize(...args));
|
|
640
|
+
inst.size = (...args) => inst.check(_size(...args));
|
|
641
|
+
});
|
|
642
|
+
function set(valueType, params) {
|
|
643
|
+
return new ZodSet({
|
|
644
|
+
type: "set",
|
|
645
|
+
valueType: valueType,
|
|
646
|
+
...normalizeParams(params),
|
|
647
|
+
});
|
|
648
|
+
}
|
|
649
|
+
const ZodEnum = /*@__PURE__*/ $constructor("ZodEnum", (inst, def) => {
|
|
650
|
+
$ZodEnum.init(inst, def);
|
|
651
|
+
ZodType.init(inst, def);
|
|
652
|
+
inst.enum = def.entries;
|
|
653
|
+
inst.options = Object.values(def.entries);
|
|
654
|
+
const keys = new Set(Object.keys(def.entries));
|
|
655
|
+
inst.extract = (values, params) => {
|
|
656
|
+
const newEntries = {};
|
|
657
|
+
for (const value of values) {
|
|
658
|
+
if (keys.has(value)) {
|
|
659
|
+
newEntries[value] = def.entries[value];
|
|
660
|
+
}
|
|
661
|
+
else
|
|
662
|
+
throw new Error(`Key ${value} not found in enum`);
|
|
663
|
+
}
|
|
664
|
+
return new ZodEnum({
|
|
665
|
+
...def,
|
|
666
|
+
checks: [],
|
|
667
|
+
...normalizeParams(params),
|
|
668
|
+
entries: newEntries,
|
|
669
|
+
});
|
|
670
|
+
};
|
|
671
|
+
inst.exclude = (values, params) => {
|
|
672
|
+
const newEntries = { ...def.entries };
|
|
673
|
+
for (const value of values) {
|
|
674
|
+
if (keys.has(value)) {
|
|
675
|
+
delete newEntries[value];
|
|
676
|
+
}
|
|
677
|
+
else
|
|
678
|
+
throw new Error(`Key ${value} not found in enum`);
|
|
679
|
+
}
|
|
680
|
+
return new ZodEnum({
|
|
681
|
+
...def,
|
|
682
|
+
checks: [],
|
|
683
|
+
...normalizeParams(params),
|
|
684
|
+
entries: newEntries,
|
|
685
|
+
});
|
|
686
|
+
};
|
|
687
|
+
});
|
|
688
|
+
function _enum(values, params) {
|
|
689
|
+
const entries = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
|
|
690
|
+
return new ZodEnum({
|
|
691
|
+
type: "enum",
|
|
692
|
+
entries,
|
|
693
|
+
...normalizeParams(params),
|
|
694
|
+
});
|
|
695
|
+
}
|
|
696
|
+
/** @deprecated This API has been merged into `z.enum()`. Use `z.enum()` instead.
|
|
697
|
+
*
|
|
698
|
+
* ```ts
|
|
699
|
+
* enum Colors { red, green, blue }
|
|
700
|
+
* z.enum(Colors);
|
|
701
|
+
* ```
|
|
702
|
+
*/
|
|
703
|
+
function nativeEnum(entries, params) {
|
|
704
|
+
return new ZodEnum({
|
|
705
|
+
type: "enum",
|
|
706
|
+
entries,
|
|
707
|
+
...normalizeParams(params),
|
|
708
|
+
});
|
|
709
|
+
}
|
|
710
|
+
const ZodLiteral = /*@__PURE__*/ $constructor("ZodLiteral", (inst, def) => {
|
|
711
|
+
$ZodLiteral.init(inst, def);
|
|
712
|
+
ZodType.init(inst, def);
|
|
713
|
+
inst.values = new Set(def.values);
|
|
714
|
+
Object.defineProperty(inst, "value", {
|
|
715
|
+
get() {
|
|
716
|
+
if (def.values.length > 1) {
|
|
717
|
+
throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");
|
|
718
|
+
}
|
|
719
|
+
return def.values[0];
|
|
720
|
+
},
|
|
721
|
+
});
|
|
722
|
+
});
|
|
723
|
+
function literal(value, params) {
|
|
724
|
+
return new ZodLiteral({
|
|
725
|
+
type: "literal",
|
|
726
|
+
values: Array.isArray(value) ? value : [value],
|
|
727
|
+
...normalizeParams(params),
|
|
728
|
+
});
|
|
729
|
+
}
|
|
730
|
+
const ZodFile = /*@__PURE__*/ $constructor("ZodFile", (inst, def) => {
|
|
731
|
+
$ZodFile.init(inst, def);
|
|
732
|
+
ZodType.init(inst, def);
|
|
733
|
+
inst.min = (size, params) => inst.check(_minSize(size, params));
|
|
734
|
+
inst.max = (size, params) => inst.check(_maxSize(size, params));
|
|
735
|
+
inst.mime = (types, params) => inst.check(_mime(Array.isArray(types) ? types : [types], params));
|
|
736
|
+
});
|
|
737
|
+
function file(params) {
|
|
738
|
+
return _file(ZodFile, params);
|
|
739
|
+
}
|
|
740
|
+
const ZodTransform = /*@__PURE__*/ $constructor("ZodTransform", (inst, def) => {
|
|
741
|
+
$ZodTransform.init(inst, def);
|
|
742
|
+
ZodType.init(inst, def);
|
|
743
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
744
|
+
payload.addIssue = (issue$1) => {
|
|
745
|
+
if (typeof issue$1 === "string") {
|
|
746
|
+
payload.issues.push(issue(issue$1, payload.value, def));
|
|
747
|
+
}
|
|
748
|
+
else {
|
|
749
|
+
// for Zod 3 backwards compatibility
|
|
750
|
+
const _issue = issue$1;
|
|
751
|
+
if (_issue.fatal)
|
|
752
|
+
_issue.continue = false;
|
|
753
|
+
_issue.code ?? (_issue.code = "custom");
|
|
754
|
+
_issue.input ?? (_issue.input = payload.value);
|
|
755
|
+
_issue.inst ?? (_issue.inst = inst);
|
|
756
|
+
_issue.continue ?? (_issue.continue = true);
|
|
757
|
+
payload.issues.push(issue(_issue));
|
|
758
|
+
}
|
|
759
|
+
};
|
|
760
|
+
const output = def.transform(payload.value, payload);
|
|
761
|
+
if (output instanceof Promise) {
|
|
762
|
+
return output.then((output) => {
|
|
763
|
+
payload.value = output;
|
|
764
|
+
return payload;
|
|
765
|
+
});
|
|
766
|
+
}
|
|
767
|
+
payload.value = output;
|
|
768
|
+
return payload;
|
|
769
|
+
};
|
|
770
|
+
});
|
|
771
|
+
function transform(fn) {
|
|
772
|
+
return new ZodTransform({
|
|
773
|
+
type: "transform",
|
|
774
|
+
transform: fn,
|
|
775
|
+
});
|
|
776
|
+
}
|
|
777
|
+
const ZodOptional = /*@__PURE__*/ $constructor("ZodOptional", (inst, def) => {
|
|
778
|
+
$ZodOptional.init(inst, def);
|
|
779
|
+
ZodType.init(inst, def);
|
|
780
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
781
|
+
});
|
|
782
|
+
function optional(innerType) {
|
|
783
|
+
return new ZodOptional({
|
|
784
|
+
type: "optional",
|
|
785
|
+
innerType: innerType,
|
|
786
|
+
});
|
|
787
|
+
}
|
|
788
|
+
const ZodNullable = /*@__PURE__*/ $constructor("ZodNullable", (inst, def) => {
|
|
789
|
+
$ZodNullable.init(inst, def);
|
|
790
|
+
ZodType.init(inst, def);
|
|
791
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
792
|
+
});
|
|
793
|
+
function nullable(innerType) {
|
|
794
|
+
return new ZodNullable({
|
|
795
|
+
type: "nullable",
|
|
796
|
+
innerType: innerType,
|
|
797
|
+
});
|
|
798
|
+
}
|
|
799
|
+
// nullish
|
|
800
|
+
function nullish(innerType) {
|
|
801
|
+
return optional(nullable(innerType));
|
|
802
|
+
}
|
|
803
|
+
const ZodDefault = /*@__PURE__*/ $constructor("ZodDefault", (inst, def) => {
|
|
804
|
+
$ZodDefault.init(inst, def);
|
|
805
|
+
ZodType.init(inst, def);
|
|
806
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
807
|
+
inst.removeDefault = inst.unwrap;
|
|
808
|
+
});
|
|
809
|
+
function _default(innerType, defaultValue) {
|
|
810
|
+
return new ZodDefault({
|
|
811
|
+
type: "default",
|
|
812
|
+
innerType: innerType,
|
|
813
|
+
get defaultValue() {
|
|
814
|
+
return typeof defaultValue === "function" ? defaultValue() : defaultValue;
|
|
815
|
+
},
|
|
816
|
+
});
|
|
817
|
+
}
|
|
818
|
+
const ZodPrefault = /*@__PURE__*/ $constructor("ZodPrefault", (inst, def) => {
|
|
819
|
+
$ZodPrefault.init(inst, def);
|
|
820
|
+
ZodType.init(inst, def);
|
|
821
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
822
|
+
});
|
|
823
|
+
function prefault(innerType, defaultValue) {
|
|
824
|
+
return new ZodPrefault({
|
|
825
|
+
type: "prefault",
|
|
826
|
+
innerType: innerType,
|
|
827
|
+
get defaultValue() {
|
|
828
|
+
return typeof defaultValue === "function" ? defaultValue() : defaultValue;
|
|
829
|
+
},
|
|
830
|
+
});
|
|
831
|
+
}
|
|
832
|
+
const ZodNonOptional = /*@__PURE__*/ $constructor("ZodNonOptional", (inst, def) => {
|
|
833
|
+
$ZodNonOptional.init(inst, def);
|
|
834
|
+
ZodType.init(inst, def);
|
|
835
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
836
|
+
});
|
|
837
|
+
function nonoptional(innerType, params) {
|
|
838
|
+
return new ZodNonOptional({
|
|
839
|
+
type: "nonoptional",
|
|
840
|
+
innerType: innerType,
|
|
841
|
+
...normalizeParams(params),
|
|
842
|
+
});
|
|
843
|
+
}
|
|
844
|
+
const ZodSuccess = /*@__PURE__*/ $constructor("ZodSuccess", (inst, def) => {
|
|
845
|
+
$ZodSuccess.init(inst, def);
|
|
846
|
+
ZodType.init(inst, def);
|
|
847
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
848
|
+
});
|
|
849
|
+
function success(innerType) {
|
|
850
|
+
return new ZodSuccess({
|
|
851
|
+
type: "success",
|
|
852
|
+
innerType: innerType,
|
|
853
|
+
});
|
|
854
|
+
}
|
|
855
|
+
const ZodCatch = /*@__PURE__*/ $constructor("ZodCatch", (inst, def) => {
|
|
856
|
+
$ZodCatch.init(inst, def);
|
|
857
|
+
ZodType.init(inst, def);
|
|
858
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
859
|
+
inst.removeCatch = inst.unwrap;
|
|
860
|
+
});
|
|
861
|
+
function _catch(innerType, catchValue) {
|
|
862
|
+
return new ZodCatch({
|
|
863
|
+
type: "catch",
|
|
864
|
+
innerType: innerType,
|
|
865
|
+
catchValue: (typeof catchValue === "function" ? catchValue : () => catchValue),
|
|
866
|
+
});
|
|
867
|
+
}
|
|
868
|
+
const ZodNaN = /*@__PURE__*/ $constructor("ZodNaN", (inst, def) => {
|
|
869
|
+
$ZodNaN.init(inst, def);
|
|
870
|
+
ZodType.init(inst, def);
|
|
871
|
+
});
|
|
872
|
+
function nan(params) {
|
|
873
|
+
return _nan(ZodNaN, params);
|
|
874
|
+
}
|
|
875
|
+
const ZodPipe = /*@__PURE__*/ $constructor("ZodPipe", (inst, def) => {
|
|
876
|
+
$ZodPipe.init(inst, def);
|
|
877
|
+
ZodType.init(inst, def);
|
|
878
|
+
inst.in = def.in;
|
|
879
|
+
inst.out = def.out;
|
|
880
|
+
});
|
|
881
|
+
function pipe(in_, out) {
|
|
882
|
+
return new ZodPipe({
|
|
883
|
+
type: "pipe",
|
|
884
|
+
in: in_,
|
|
885
|
+
out: out,
|
|
886
|
+
// ...util.normalizeParams(params),
|
|
887
|
+
});
|
|
888
|
+
}
|
|
889
|
+
const ZodReadonly = /*@__PURE__*/ $constructor("ZodReadonly", (inst, def) => {
|
|
890
|
+
$ZodReadonly.init(inst, def);
|
|
891
|
+
ZodType.init(inst, def);
|
|
892
|
+
});
|
|
893
|
+
function readonly(innerType) {
|
|
894
|
+
return new ZodReadonly({
|
|
895
|
+
type: "readonly",
|
|
896
|
+
innerType: innerType,
|
|
897
|
+
});
|
|
898
|
+
}
|
|
899
|
+
const ZodTemplateLiteral = /*@__PURE__*/ $constructor("ZodTemplateLiteral", (inst, def) => {
|
|
900
|
+
$ZodTemplateLiteral.init(inst, def);
|
|
901
|
+
ZodType.init(inst, def);
|
|
902
|
+
});
|
|
903
|
+
function templateLiteral(parts, params) {
|
|
904
|
+
return new ZodTemplateLiteral({
|
|
905
|
+
type: "template_literal",
|
|
906
|
+
parts,
|
|
907
|
+
...normalizeParams(params),
|
|
908
|
+
});
|
|
909
|
+
}
|
|
910
|
+
const ZodLazy = /*@__PURE__*/ $constructor("ZodLazy", (inst, def) => {
|
|
911
|
+
$ZodLazy.init(inst, def);
|
|
912
|
+
ZodType.init(inst, def);
|
|
913
|
+
inst.unwrap = () => inst._zod.def.getter();
|
|
914
|
+
});
|
|
915
|
+
function lazy(getter) {
|
|
916
|
+
return new ZodLazy({
|
|
917
|
+
type: "lazy",
|
|
918
|
+
getter: getter,
|
|
919
|
+
});
|
|
920
|
+
}
|
|
921
|
+
const ZodPromise = /*@__PURE__*/ $constructor("ZodPromise", (inst, def) => {
|
|
922
|
+
$ZodPromise.init(inst, def);
|
|
923
|
+
ZodType.init(inst, def);
|
|
924
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
925
|
+
});
|
|
926
|
+
function promise(innerType) {
|
|
927
|
+
return new ZodPromise({
|
|
928
|
+
type: "promise",
|
|
929
|
+
innerType: innerType,
|
|
930
|
+
});
|
|
931
|
+
}
|
|
932
|
+
const ZodCustom = /*@__PURE__*/ $constructor("ZodCustom", (inst, def) => {
|
|
933
|
+
$ZodCustom.init(inst, def);
|
|
934
|
+
ZodType.init(inst, def);
|
|
935
|
+
});
|
|
936
|
+
// custom checks
|
|
937
|
+
function check(fn, params) {
|
|
938
|
+
const ch = new $ZodCheck({
|
|
939
|
+
check: "custom",
|
|
940
|
+
...normalizeParams(params),
|
|
941
|
+
});
|
|
942
|
+
ch._zod.check = fn;
|
|
943
|
+
return ch;
|
|
944
|
+
}
|
|
945
|
+
function custom(fn, _params) {
|
|
946
|
+
return _custom(ZodCustom, fn ?? (() => true), _params);
|
|
947
|
+
}
|
|
948
|
+
function refine(fn, _params = {}) {
|
|
949
|
+
return _refine(ZodCustom, fn, _params);
|
|
950
|
+
}
|
|
951
|
+
// superRefine
|
|
952
|
+
function superRefine(fn, params) {
|
|
953
|
+
const ch = check((payload) => {
|
|
954
|
+
payload.addIssue = (issue$1) => {
|
|
955
|
+
if (typeof issue$1 === "string") {
|
|
956
|
+
payload.issues.push(issue(issue$1, payload.value, ch._zod.def));
|
|
957
|
+
}
|
|
958
|
+
else {
|
|
959
|
+
// for Zod 3 backwards compatibility
|
|
960
|
+
const _issue = issue$1;
|
|
961
|
+
if (_issue.fatal)
|
|
962
|
+
_issue.continue = false;
|
|
963
|
+
_issue.code ?? (_issue.code = "custom");
|
|
964
|
+
_issue.input ?? (_issue.input = payload.value);
|
|
965
|
+
_issue.inst ?? (_issue.inst = ch);
|
|
966
|
+
_issue.continue ?? (_issue.continue = !ch._zod.def.abort);
|
|
967
|
+
payload.issues.push(issue(_issue));
|
|
968
|
+
}
|
|
969
|
+
};
|
|
970
|
+
return fn(payload.value, payload);
|
|
971
|
+
}, params);
|
|
972
|
+
return ch;
|
|
973
|
+
}
|
|
974
|
+
function _instanceof(cls, params = {
|
|
975
|
+
error: `Input not instance of ${cls.name}`,
|
|
976
|
+
}) {
|
|
977
|
+
const inst = new ZodCustom({
|
|
978
|
+
type: "custom",
|
|
979
|
+
check: "custom",
|
|
980
|
+
fn: (data) => data instanceof cls,
|
|
981
|
+
abort: true,
|
|
982
|
+
...normalizeParams(params),
|
|
983
|
+
});
|
|
984
|
+
inst._zod.bag.Class = cls;
|
|
985
|
+
return inst;
|
|
986
|
+
}
|
|
987
|
+
// stringbool
|
|
988
|
+
const stringbool = (...args) => _stringbool({
|
|
989
|
+
Pipe: ZodPipe,
|
|
990
|
+
Boolean: ZodBoolean,
|
|
991
|
+
String: ZodString,
|
|
992
|
+
Transform: ZodTransform,
|
|
993
|
+
}, ...args);
|
|
994
|
+
function json(params) {
|
|
995
|
+
const jsonSchema = lazy(() => {
|
|
996
|
+
return union([string(params), number(), boolean(), _null(), array(jsonSchema), record(string(), jsonSchema)]);
|
|
997
|
+
});
|
|
998
|
+
return jsonSchema;
|
|
999
|
+
}
|
|
1000
|
+
// preprocess
|
|
1001
|
+
// /** @deprecated Use `z.pipe()` and `z.transform()` instead. */
|
|
1002
|
+
function preprocess(fn, schema) {
|
|
1003
|
+
return pipe(transform(fn), schema);
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
export { ZodAny, ZodArray, ZodBase64, ZodBase64URL, ZodBigInt, ZodBigIntFormat, ZodBoolean, ZodCIDRv4, ZodCIDRv6, ZodCUID, ZodCUID2, ZodCatch, ZodCustom, ZodCustomStringFormat, ZodDate, ZodDefault, ZodDiscriminatedUnion, ZodE164, ZodEmail, ZodEmoji, ZodEnum, ZodFile, ZodGUID, ZodIPv4, ZodIPv6, ZodIntersection, ZodJWT, ZodKSUID, ZodLazy, ZodLiteral, ZodMap, ZodNaN, ZodNanoID, ZodNever, ZodNonOptional, ZodNull, ZodNullable, ZodNumber, ZodNumberFormat, ZodObject, ZodOptional, ZodPipe, ZodPrefault, ZodPromise, ZodReadonly, ZodRecord, ZodSet, ZodString, ZodStringFormat, ZodSuccess, ZodSymbol, ZodTemplateLiteral, ZodTransform, ZodTuple, ZodType, ZodULID, ZodURL, ZodUUID, ZodUndefined, ZodUnion, ZodUnknown, ZodVoid, ZodXID, _ZodString, _default, any, array, base64, base64url, bigint, boolean, _catch as catch, check, cidrv4, cidrv6, cuid, cuid2, custom, date, discriminatedUnion, e164, email, emoji, _enum as enum, file, float32, float64, guid, _instanceof as instanceof, int, int32, int64, intersection, ipv4, ipv6, json, jwt, keyof, ksuid, lazy, literal, looseObject, map, nan, nanoid, nativeEnum, never, nonoptional, _null as null, nullable, nullish, number, object, optional, partialRecord, pipe, prefault, preprocess, promise, readonly, record, refine, 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 };
|