zod 4.0.0-beta.1 → 4.0.0-beta.20250410T035006

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.
Files changed (102) hide show
  1. package/LICENSE +1 -1
  2. package/dist/commonjs/checks.d.ts +1 -0
  3. package/dist/commonjs/checks.js +32 -0
  4. package/dist/commonjs/coerce.d.ts +17 -0
  5. package/dist/commonjs/coerce.js +57 -0
  6. package/dist/commonjs/compat.d.ts +47 -0
  7. package/dist/commonjs/compat.js +73 -0
  8. package/dist/commonjs/errors.d.ts +29 -0
  9. package/dist/commonjs/errors.js +61 -0
  10. package/dist/commonjs/external.d.ts +8 -0
  11. package/dist/commonjs/external.js +67 -0
  12. package/dist/commonjs/index.d.ts +4 -0
  13. package/dist/commonjs/index.js +43 -0
  14. package/dist/commonjs/iso.d.ts +22 -0
  15. package/dist/commonjs/iso.js +70 -0
  16. package/dist/commonjs/package.json +3 -0
  17. package/dist/commonjs/parse.d.ts +17 -0
  18. package/dist/commonjs/parse.js +44 -0
  19. package/dist/commonjs/schemas.d.ts +750 -0
  20. package/dist/commonjs/schemas.js +1190 -0
  21. package/dist/esm/checks.d.ts +1 -0
  22. package/dist/esm/checks.js +1 -0
  23. package/dist/esm/coerce.d.ts +17 -0
  24. package/dist/esm/coerce.js +17 -0
  25. package/dist/esm/compat.d.ts +47 -0
  26. package/dist/esm/compat.js +33 -0
  27. package/dist/esm/errors.d.ts +29 -0
  28. package/dist/esm/errors.js +24 -0
  29. package/dist/esm/external.d.ts +8 -0
  30. package/dist/esm/external.js +14 -0
  31. package/dist/esm/index.d.ts +4 -0
  32. package/dist/esm/index.js +4 -0
  33. package/dist/esm/iso.d.ts +22 -0
  34. package/dist/esm/iso.js +30 -0
  35. package/dist/esm/package.json +3 -0
  36. package/dist/esm/parse.d.ts +17 -0
  37. package/dist/esm/parse.js +8 -0
  38. package/dist/esm/schemas.d.ts +750 -0
  39. package/dist/esm/schemas.js +1074 -0
  40. package/package.json +66 -82
  41. package/src/checks.ts +30 -0
  42. package/src/coerce.ts +27 -0
  43. package/src/compat.ts +74 -0
  44. package/src/errors.ts +50 -0
  45. package/src/external.ts +29 -0
  46. package/src/index.ts +5 -0
  47. package/src/iso.ts +90 -0
  48. package/src/parse.ts +32 -0
  49. package/src/schemas.ts +2360 -0
  50. package/CHANGELOG.md +0 -160
  51. package/README.md +0 -1730
  52. package/lib/.DS_Store +0 -0
  53. package/lib/PseudoPromise.d.ts +0 -7
  54. package/lib/PseudoPromise.d.ts.map +0 -1
  55. package/lib/PseudoPromise.js +0 -17
  56. package/lib/PseudoPromise.js.map +0 -1
  57. package/lib/ZodError.d.ts +0 -137
  58. package/lib/ZodError.d.ts.map +0 -1
  59. package/lib/ZodError.js +0 -301
  60. package/lib/ZodError.js.map +0 -1
  61. package/lib/benchmarks/index.d.ts +0 -2
  62. package/lib/benchmarks/index.d.ts.map +0 -1
  63. package/lib/benchmarks/index.js +0 -54
  64. package/lib/benchmarks/index.js.map +0 -1
  65. package/lib/benchmarks/object.d.ts +0 -6
  66. package/lib/benchmarks/object.d.ts.map +0 -1
  67. package/lib/benchmarks/object.js +0 -71
  68. package/lib/benchmarks/object.js.map +0 -1
  69. package/lib/benchmarks/string.d.ts +0 -6
  70. package/lib/benchmarks/string.d.ts.map +0 -1
  71. package/lib/benchmarks/string.js +0 -45
  72. package/lib/benchmarks/string.js.map +0 -1
  73. package/lib/external.d.ts +0 -4
  74. package/lib/external.d.ts.map +0 -1
  75. package/lib/external.js +0 -16
  76. package/lib/external.js.map +0 -1
  77. package/lib/helpers/errorUtil.d.ts +0 -10
  78. package/lib/helpers/errorUtil.d.ts.map +0 -1
  79. package/lib/helpers/errorUtil.js +0 -13
  80. package/lib/helpers/errorUtil.js.map +0 -1
  81. package/lib/helpers/parseUtil.d.ts +0 -74
  82. package/lib/helpers/parseUtil.d.ts.map +0 -1
  83. package/lib/helpers/parseUtil.js +0 -179
  84. package/lib/helpers/parseUtil.js.map +0 -1
  85. package/lib/helpers/partialUtil.d.ts +0 -18
  86. package/lib/helpers/partialUtil.d.ts.map +0 -1
  87. package/lib/helpers/partialUtil.js +0 -3
  88. package/lib/helpers/partialUtil.js.map +0 -1
  89. package/lib/helpers/util.d.ts +0 -18
  90. package/lib/helpers/util.d.ts.map +0 -1
  91. package/lib/helpers/util.js +0 -87
  92. package/lib/helpers/util.js.map +0 -1
  93. package/lib/index.d.ts +0 -4
  94. package/lib/index.d.ts.map +0 -1
  95. package/lib/index.js +0 -29
  96. package/lib/index.js.map +0 -1
  97. package/lib/index.mjs +0 -2808
  98. package/lib/index.mjs.map +0 -1
  99. package/lib/types.d.ts +0 -541
  100. package/lib/types.d.ts.map +0 -1
  101. package/lib/types.js +0 -2282
  102. package/lib/types.js.map +0 -1
@@ -0,0 +1,1190 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.ZodFile = exports.ZodLiteral = exports.ZodEnum = exports.ZodSet = exports.ZodMap = exports.ZodRecord = exports.ZodTuple = exports.ZodIntersection = exports.ZodDiscriminatedUnion = exports.ZodUnion = exports.ZodObject = exports.ZodInterface = exports.ZodObjectLike = exports.ZodArray = exports.ZodDate = exports.ZodVoid = exports.ZodNever = exports.ZodUnknown = exports.ZodAny = exports.ZodNull = exports.ZodUndefined = exports.ZodSymbol = exports.ZodBigIntFormat = exports.ZodBigInt = exports.ZodBoolean = exports.ZodNumberFormat = exports.ZodNumber = exports.ZodJWT = exports.ZodE164 = exports.ZodBase64 = exports.ZodCIDRv6 = exports.ZodCIDRv4 = exports.ZodIPv6 = exports.ZodIPv4 = exports.ZodKSUID = exports.ZodXID = exports.ZodULID = exports.ZodCUID2 = exports.ZodCUID = exports.ZodNanoID = exports.ZodEmoji = exports.ZodURL = exports.ZodUUID = exports.ZodGUID = exports.ZodEmail = exports.ZodStringFormat = exports.ZodString = exports.ZodType = exports.coerce = exports.iso = void 0;
37
+ exports.stringbool = exports.ZodCustom = exports.ZodPromise = exports.ZodLazy = exports.ZodTemplateLiteral = exports.ZodReadonly = exports.ZodPipe = exports.ZodNaN = exports.ZodCatch = exports.ZodSuccess = exports.ZodNonOptional = exports.ZodDefault = exports.ZodNullable = exports.ZodOptional = exports.ZodTransform = void 0;
38
+ exports.string = string;
39
+ exports.email = email;
40
+ exports.guid = guid;
41
+ exports.uuid = uuid;
42
+ exports.uuidv4 = uuidv4;
43
+ exports.uuidv6 = uuidv6;
44
+ exports.uuidv7 = uuidv7;
45
+ exports.url = url;
46
+ exports.emoji = emoji;
47
+ exports.nanoid = nanoid;
48
+ exports.cuid = cuid;
49
+ exports.cuid2 = cuid2;
50
+ exports.ulid = ulid;
51
+ exports.xid = xid;
52
+ exports.ksuid = ksuid;
53
+ exports.ipv4 = ipv4;
54
+ exports.ipv6 = ipv6;
55
+ exports.cidrv4 = cidrv4;
56
+ exports.cidrv6 = cidrv6;
57
+ exports.base64 = base64;
58
+ exports.e164 = e164;
59
+ exports.jwt = jwt;
60
+ exports.number = number;
61
+ exports.int = int;
62
+ exports.float32 = float32;
63
+ exports.float64 = float64;
64
+ exports.int32 = int32;
65
+ exports.uint32 = uint32;
66
+ exports.boolean = boolean;
67
+ exports.bigint = bigint;
68
+ exports.int64 = int64;
69
+ exports.uint64 = uint64;
70
+ exports.symbol = symbol;
71
+ exports.undefined = _undefined;
72
+ exports.null = _null;
73
+ exports.any = any;
74
+ exports.unknown = unknown;
75
+ exports.never = never;
76
+ exports.void = _void;
77
+ exports.date = date;
78
+ exports.array = array;
79
+ exports.keyof = keyof;
80
+ exports.interface = _interface;
81
+ exports.strictInterface = strictInterface;
82
+ exports.looseInterface = looseInterface;
83
+ exports.object = object;
84
+ exports.strictObject = strictObject;
85
+ exports.looseObject = looseObject;
86
+ exports.extend = extend;
87
+ exports.merge = merge;
88
+ exports.pick = pick;
89
+ exports.omit = omit;
90
+ exports.partial = partial;
91
+ exports.required = required;
92
+ exports.union = union;
93
+ exports.discriminatedUnion = discriminatedUnion;
94
+ exports.intersection = intersection;
95
+ exports.tuple = tuple;
96
+ exports.record = record;
97
+ exports.map = map;
98
+ exports.set = set;
99
+ exports.enum = _enum;
100
+ exports.nativeEnum = nativeEnum;
101
+ exports.literal = literal;
102
+ exports.file = file;
103
+ exports.transform = transform;
104
+ exports.optional = optional;
105
+ exports.nullable = nullable;
106
+ exports.nullish = nullish;
107
+ exports._default = _default;
108
+ exports.nonoptional = nonoptional;
109
+ exports.success = success;
110
+ exports.catch = _catch;
111
+ exports.nan = nan;
112
+ exports.pipe = pipe;
113
+ exports.readonly = readonly;
114
+ exports.templateLiteral = templateLiteral;
115
+ exports.lazy = lazy;
116
+ exports.promise = promise;
117
+ exports.check = check;
118
+ exports.custom = custom;
119
+ exports.refine = refine;
120
+ exports.superRefine = superRefine;
121
+ exports.instanceof = _instanceof;
122
+ exports.json = json;
123
+ exports.preprocess = preprocess;
124
+ const core = __importStar(require("@zod/core"));
125
+ const util = __importStar(require("@zod/core/util"));
126
+ const checks = __importStar(require("./checks.js"));
127
+ const iso = __importStar(require("./iso.js"));
128
+ const parse = __importStar(require("./parse.js"));
129
+ exports.iso = __importStar(require("./iso.js"));
130
+ exports.coerce = __importStar(require("./coerce.js"));
131
+ exports.ZodType = core.$constructor("ZodType", (inst, def) => {
132
+ core.$ZodType.init(inst, def);
133
+ inst.def = def;
134
+ inst._def = def;
135
+ // base methods
136
+ inst.check = (...checks) => {
137
+ return inst.clone({
138
+ ...def,
139
+ checks: [
140
+ ...(def.checks ?? []),
141
+ ...checks.map((ch) => (typeof ch === "function" ? { _zod: { check: ch, def: { check: "custom" } } } : ch)),
142
+ ],
143
+ });
144
+ };
145
+ inst.clone = (_def) => core.clone(inst, _def ?? def);
146
+ inst.brand = () => inst;
147
+ inst.register = ((reg, meta) => {
148
+ reg.add(inst, meta);
149
+ return inst;
150
+ });
151
+ // parsing
152
+ inst.parse = (data, params) => parse.parse(inst, data, params);
153
+ inst.safeParse = (data, params) => parse.safeParse(inst, data, params);
154
+ inst.parseAsync = async (data, params) => parse.parseAsync(inst, data, params);
155
+ inst.safeParseAsync = async (data, params) => parse.safeParseAsync(inst, data, params);
156
+ inst.spa = inst.safeParseAsync;
157
+ // refinements
158
+ inst.refine = (check, params) => inst.check(refine(check, params));
159
+ inst.superRefine = (refinement) => inst.check(superRefine(refinement));
160
+ inst.overwrite = (fn) => inst.check(checks.overwrite(fn));
161
+ // wrappers
162
+ inst.optional = (params) => optional(inst, params);
163
+ inst.nullable = (params) => nullable(inst, params);
164
+ inst.nullish = () => optional(nullable(inst));
165
+ inst.nonoptional = (params) => nonoptional(inst, params);
166
+ inst.array = () => array(inst);
167
+ inst.or = (arg) => union([inst, arg]);
168
+ // inst.and = (arg) => intersection(inst, arg);
169
+ inst.transform = (tx) => pipe(inst, transform(tx));
170
+ inst.default = (def, params) => _default(inst, def, params);
171
+ // inst.coalesce = (def, params) => coalesce(inst, def, params);
172
+ inst.catch = (params) => _catch(inst, params);
173
+ inst.pipe = (target) => pipe(inst, target);
174
+ inst.readonly = () => readonly(inst);
175
+ // meta
176
+ inst.describe = (description) => {
177
+ const cl = inst.clone();
178
+ const meta = core.globalRegistry.get(inst) ?? {};
179
+ meta.description = description;
180
+ core.globalRegistry.add(cl, meta);
181
+ return cl;
182
+ };
183
+ Object.defineProperty(inst, "description", {
184
+ get() {
185
+ return core.globalRegistry.get(inst)?.description;
186
+ },
187
+ configurable: true,
188
+ });
189
+ inst.meta = (...args) => {
190
+ if (args.length === 0)
191
+ return core.globalRegistry.get(inst);
192
+ const cl = inst.clone();
193
+ core.globalRegistry.add(cl, args[0]);
194
+ return cl;
195
+ };
196
+ // helpers
197
+ inst.isOptional = () => inst.safeParse(undefined).success;
198
+ inst.isNullable = () => inst.safeParse(null).success;
199
+ return inst;
200
+ });
201
+ exports.ZodString = core.$constructor("ZodString", (inst, def) => {
202
+ core.$ZodString.init(inst, def);
203
+ exports.ZodType.init(inst, def);
204
+ inst.format = inst._zod.computed.format ?? null;
205
+ inst.minLength = inst._zod.computed.minimum ?? null;
206
+ inst.maxLength = inst._zod.computed.maximum ?? null;
207
+ inst.email = (params) => inst.check(core._email(exports.ZodEmail, params));
208
+ inst.url = (params) => inst.check(core._url(exports.ZodURL, params));
209
+ inst.jwt = (params) => inst.check(core._jwt(exports.ZodJWT, params));
210
+ inst.emoji = (params) => inst.check(core._emoji(exports.ZodEmoji, params));
211
+ inst.guid = (params) => inst.check(core._guid(exports.ZodGUID, params));
212
+ inst.uuid = (params) => inst.check(core._uuid(exports.ZodUUID, params));
213
+ inst.uuidv4 = (params) => inst.check(core._uuidv4(exports.ZodUUID, params));
214
+ inst.uuidv6 = (params) => inst.check(core._uuidv6(exports.ZodUUID, params));
215
+ inst.uuidv7 = (params) => inst.check(core._uuidv7(exports.ZodUUID, params));
216
+ inst.nanoid = (params) => inst.check(core._nanoid(exports.ZodNanoID, params));
217
+ inst.guid = (params) => inst.check(core._guid(exports.ZodGUID, params));
218
+ inst.cuid = (params) => inst.check(core._cuid(exports.ZodCUID, params));
219
+ inst.cuid2 = (params) => inst.check(core._cuid2(exports.ZodCUID2, params));
220
+ inst.ulid = (params) => inst.check(core._ulid(exports.ZodULID, params));
221
+ inst.base64 = (params) => inst.check(core._base64(exports.ZodBase64, params));
222
+ // inst.jsonString = (params) => inst.check(core._jsonString(Zodinst,params));
223
+ // inst.json = (params) => inst.check(core._jsonString(Zodinst,params));
224
+ inst.xid = (params) => inst.check(core._xid(exports.ZodXID, params));
225
+ inst.ksuid = (params) => inst.check(core._ksuid(exports.ZodKSUID, params));
226
+ // inst.ip = (params) => {
227
+ // const version = (params ?? {} as any)?.version;
228
+ // if (version === "v4") return inst.check(core._ipv4(ZodIPv4, params));
229
+ // if (version === "v6") return inst.check(core._ipv6(ZodIPv6, params as any));
230
+ // return union([inst.ipv4(params), inst.ipv6(params as any)]);
231
+ // };
232
+ inst.ipv4 = (params) => inst.check(core._ipv4(exports.ZodIPv4, params));
233
+ inst.ipv6 = (params) => inst.check(core._ipv6(exports.ZodIPv6, params));
234
+ inst.cidrv4 = (params) => inst.check(core._cidrv4(exports.ZodCIDRv4, params));
235
+ inst.cidrv6 = (params) => inst.check(core._cidrv6(exports.ZodCIDRv6, params));
236
+ inst.e164 = (params) => inst.check(core._e164(exports.ZodE164, params));
237
+ // iso
238
+ inst.datetime = (params) => inst.check(iso.datetime(params));
239
+ inst.date = (params) => inst.check(iso.date(params));
240
+ inst.time = (params) => inst.check(iso.time(params));
241
+ inst.duration = (params) => inst.check(iso.duration(params));
242
+ // validations
243
+ inst.regex = (params) => inst.check(checks.regex(params));
244
+ inst.includes = (...args) => inst.check(checks.includes(...args));
245
+ inst.startsWith = (params) => inst.check(checks.startsWith(params));
246
+ inst.endsWith = (params) => inst.check(checks.endsWith(params));
247
+ inst.min = (...args) => inst.check(checks.minLength(...args));
248
+ inst.max = (...args) => inst.check(checks.maxLength(...args));
249
+ inst.length = (...args) => inst.check(checks.length(...args));
250
+ inst.nonempty = (...args) => inst.check(checks.minLength(1, ...args));
251
+ inst.lowercase = (params) => inst.check(checks.lowercase(params));
252
+ inst.uppercase = (params) => inst.check(checks.uppercase(params));
253
+ // transforms
254
+ inst.trim = () => inst.check(checks.trim());
255
+ inst.normalize = (...args) => inst.check(checks.normalize(...args));
256
+ inst.toLowerCase = () => inst.check(checks.toLowerCase());
257
+ inst.toUpperCase = () => inst.check(checks.toUpperCase());
258
+ });
259
+ function string(params) {
260
+ return core._string(exports.ZodString, params);
261
+ }
262
+ exports.ZodStringFormat = core.$constructor("ZodStringFormat", (inst, def) => {
263
+ core.$ZodStringFormat.init(inst, def);
264
+ exports.ZodString.init(inst, def);
265
+ });
266
+ exports.ZodEmail = core.$constructor("ZodEmail", (inst, def) => {
267
+ // ZodStringFormat.init(inst, def);
268
+ core.$ZodEmail.init(inst, def);
269
+ exports.ZodType.init(inst, def);
270
+ });
271
+ function email(params) {
272
+ return core._email(exports.ZodEmail, params);
273
+ }
274
+ exports.ZodGUID = core.$constructor("ZodGUID", (inst, def) => {
275
+ // ZodStringFormat.init(inst, def);
276
+ core.$ZodGUID.init(inst, def);
277
+ exports.ZodType.init(inst, def);
278
+ });
279
+ function guid(params) {
280
+ return core._guid(exports.ZodGUID, params);
281
+ }
282
+ exports.ZodUUID = core.$constructor("ZodUUID", (inst, def) => {
283
+ // ZodStringFormat.init(inst, def);
284
+ core.$ZodUUID.init(inst, def);
285
+ exports.ZodType.init(inst, def);
286
+ });
287
+ function uuid(params) {
288
+ return core._uuid(exports.ZodUUID, params);
289
+ }
290
+ function uuidv4(params) {
291
+ return core._uuidv4(exports.ZodUUID, params);
292
+ }
293
+ // ZodUUIDv6
294
+ function uuidv6(params) {
295
+ return core._uuidv6(exports.ZodUUID, params);
296
+ }
297
+ // ZodUUIDv7
298
+ function uuidv7(params) {
299
+ return core._uuidv7(exports.ZodUUID, params);
300
+ }
301
+ exports.ZodURL = core.$constructor("ZodURL", (inst, def) => {
302
+ // ZodStringFormat.init(inst, def);
303
+ core.$ZodURL.init(inst, def);
304
+ exports.ZodType.init(inst, def);
305
+ });
306
+ function url(params) {
307
+ return core._url(exports.ZodURL, params);
308
+ }
309
+ exports.ZodEmoji = core.$constructor("ZodEmoji", (inst, def) => {
310
+ // ZodStringFormat.init(inst, def);
311
+ core.$ZodEmoji.init(inst, def);
312
+ exports.ZodType.init(inst, def);
313
+ });
314
+ function emoji(params) {
315
+ return core._emoji(exports.ZodEmoji, params);
316
+ }
317
+ exports.ZodNanoID = core.$constructor("ZodNanoID", (inst, def) => {
318
+ // ZodStringFormat.init(inst, def);
319
+ core.$ZodNanoID.init(inst, def);
320
+ exports.ZodType.init(inst, def);
321
+ });
322
+ function nanoid(params) {
323
+ return core._nanoid(exports.ZodNanoID, params);
324
+ }
325
+ exports.ZodCUID = core.$constructor("ZodCUID", (inst, def) => {
326
+ // ZodStringFormat.init(inst, def);
327
+ core.$ZodCUID.init(inst, def);
328
+ exports.ZodType.init(inst, def);
329
+ });
330
+ function cuid(params) {
331
+ return core._cuid(exports.ZodCUID, params);
332
+ }
333
+ exports.ZodCUID2 = core.$constructor("ZodCUID2", (inst, def) => {
334
+ // ZodStringFormat.init(inst, def);
335
+ core.$ZodCUID2.init(inst, def);
336
+ exports.ZodType.init(inst, def);
337
+ });
338
+ function cuid2(params) {
339
+ return core._cuid2(exports.ZodCUID2, params);
340
+ }
341
+ exports.ZodULID = core.$constructor("ZodULID", (inst, def) => {
342
+ // ZodStringFormat.init(inst, def);
343
+ core.$ZodULID.init(inst, def);
344
+ exports.ZodType.init(inst, def);
345
+ });
346
+ function ulid(params) {
347
+ return core._ulid(exports.ZodULID, params);
348
+ }
349
+ exports.ZodXID = core.$constructor("ZodXID", (inst, def) => {
350
+ // ZodStringFormat.init(inst, def);
351
+ core.$ZodXID.init(inst, def);
352
+ exports.ZodType.init(inst, def);
353
+ });
354
+ function xid(params) {
355
+ return core._xid(exports.ZodXID, params);
356
+ }
357
+ exports.ZodKSUID = core.$constructor("ZodKSUID", (inst, def) => {
358
+ // ZodStringFormat.init(inst, def);
359
+ core.$ZodKSUID.init(inst, def);
360
+ exports.ZodType.init(inst, def);
361
+ });
362
+ function ksuid(params) {
363
+ return core._ksuid(exports.ZodKSUID, params);
364
+ }
365
+ exports.ZodIPv4 = core.$constructor("ZodIPv4", (inst, def) => {
366
+ // ZodStringFormat.init(inst, def);
367
+ core.$ZodIPv4.init(inst, def);
368
+ exports.ZodType.init(inst, def);
369
+ });
370
+ function ipv4(params) {
371
+ return core._ipv4(exports.ZodIPv4, params);
372
+ }
373
+ exports.ZodIPv6 = core.$constructor("ZodIPv6", (inst, def) => {
374
+ // ZodStringFormat.init(inst, def);
375
+ core.$ZodIPv6.init(inst, def);
376
+ exports.ZodType.init(inst, def);
377
+ });
378
+ function ipv6(params) {
379
+ return core._ipv6(exports.ZodIPv6, params);
380
+ }
381
+ exports.ZodCIDRv4 = core.$constructor("ZodCIDRv4", (inst, def) => {
382
+ core.$ZodCIDRv4.init(inst, def);
383
+ exports.ZodType.init(inst, def);
384
+ });
385
+ function cidrv4(params) {
386
+ return core._cidrv4(exports.ZodCIDRv4, params);
387
+ }
388
+ exports.ZodCIDRv6 = core.$constructor("ZodCIDRv6", (inst, def) => {
389
+ core.$ZodCIDRv6.init(inst, def);
390
+ exports.ZodType.init(inst, def);
391
+ });
392
+ function cidrv6(params) {
393
+ return core._cidrv6(exports.ZodCIDRv6, params);
394
+ }
395
+ exports.ZodBase64 = core.$constructor("ZodBase64", (inst, def) => {
396
+ // ZodStringFormat.init(inst, def);
397
+ core.$ZodBase64.init(inst, def);
398
+ exports.ZodType.init(inst, def);
399
+ });
400
+ function base64(params) {
401
+ return core._base64(exports.ZodBase64, params);
402
+ }
403
+ exports.ZodE164 = core.$constructor("ZodE164", (inst, def) => {
404
+ // ZodStringFormat.init(inst, def);
405
+ core.$ZodE164.init(inst, def);
406
+ exports.ZodType.init(inst, def);
407
+ });
408
+ function e164(params) {
409
+ return core._e164(exports.ZodE164, params);
410
+ }
411
+ exports.ZodJWT = core.$constructor("ZodJWT", (inst, def) => {
412
+ // ZodStringFormat.init(inst, def);
413
+ core.$ZodJWT.init(inst, def);
414
+ exports.ZodType.init(inst, def);
415
+ });
416
+ function jwt(params) {
417
+ return core._jwt(exports.ZodJWT, params);
418
+ }
419
+ exports.ZodNumber = core.$constructor("ZodNumber", (inst, def) => {
420
+ core.$ZodNumber.init(inst, def);
421
+ exports.ZodType.init(inst, def);
422
+ inst.gt = (value, params) => inst.check(checks.gt(value, params));
423
+ inst.gte = (value, params) => inst.check(checks.gte(value, params));
424
+ inst.min = (value, params) => inst.check(checks.gte(value, params));
425
+ inst.lt = (value, params) => inst.check(checks.lt(value, params));
426
+ inst.lte = (value, params) => inst.check(checks.lte(value, params));
427
+ inst.max = (value, params) => inst.check(checks.lte(value, params));
428
+ inst.int = (params) => inst.check(int(params));
429
+ inst.safe = (params) => inst.check(int(params));
430
+ inst.positive = (params) => inst.check(checks.gt(0, params));
431
+ inst.nonnegative = (params) => inst.check(checks.gte(0, params));
432
+ inst.negative = (params) => inst.check(checks.lt(0, params));
433
+ inst.nonpositive = (params) => inst.check(checks.lte(0, params));
434
+ inst.multipleOf = (value, params) => inst.check(checks.multipleOf(value, params));
435
+ inst.step = (value, params) => inst.check(checks.multipleOf(value, params));
436
+ // inst.finite = (params) => inst.check(core.finite(params));
437
+ inst.finite = () => inst;
438
+ inst.minValue = inst._zod.computed.minimum ?? null;
439
+ inst.maxValue = inst._zod.computed.maximum ?? null;
440
+ inst.isInt =
441
+ (inst._zod.computed.format ?? "").includes("int") || Number.isSafeInteger(inst._zod.computed.multipleOf ?? 0.5);
442
+ inst.isFinite = true;
443
+ inst.format = inst._zod.computed.format ?? null;
444
+ });
445
+ function number(params) {
446
+ return core._number(exports.ZodNumber, params);
447
+ }
448
+ exports.ZodNumberFormat = core.$constructor("ZodNumberFormat", (inst, def) => {
449
+ core.$ZodNumberFormat.init(inst, def);
450
+ exports.ZodType.init(inst, def);
451
+ });
452
+ function int(params) {
453
+ return core._int(exports.ZodNumberFormat, params);
454
+ }
455
+ function float32(params) {
456
+ return core._float32(exports.ZodNumberFormat, params);
457
+ }
458
+ function float64(params) {
459
+ return core._float64(exports.ZodNumberFormat, params);
460
+ }
461
+ function int32(params) {
462
+ return core._int32(exports.ZodNumberFormat, params);
463
+ }
464
+ function uint32(params) {
465
+ return core._uint32(exports.ZodNumberFormat, params);
466
+ }
467
+ exports.ZodBoolean = core.$constructor("ZodBoolean", (inst, def) => {
468
+ core.$ZodBoolean.init(inst, def);
469
+ exports.ZodType.init(inst, def);
470
+ });
471
+ function boolean(params) {
472
+ return core._boolean(exports.ZodBoolean, params);
473
+ }
474
+ exports.ZodBigInt = core.$constructor("ZodBigInt", (inst, def) => {
475
+ core.$ZodBigInt.init(inst, def);
476
+ exports.ZodType.init(inst, def);
477
+ inst.gte = (value, params) => inst.check(checks.gte(value, params));
478
+ inst.min = (value, params) => inst.check(checks.gte(value, params));
479
+ inst.gt = (value, params) => inst.check(checks.gt(value, params));
480
+ inst.gte = (value, params) => inst.check(checks.gte(value, params));
481
+ inst.min = (value, params) => inst.check(checks.gte(value, params));
482
+ inst.lt = (value, params) => inst.check(checks.lt(value, params));
483
+ inst.lte = (value, params) => inst.check(checks.lte(value, params));
484
+ inst.max = (value, params) => inst.check(checks.lte(value, params));
485
+ inst.positive = (params) => inst.check(checks.gt(BigInt(0), params));
486
+ inst.negative = (params) => inst.check(checks.lt(BigInt(0), params));
487
+ inst.nonpositive = (params) => inst.check(checks.lte(BigInt(0), params));
488
+ inst.nonnegative = (params) => inst.check(checks.gte(BigInt(0), params));
489
+ inst.multipleOf = (value, params) => inst.check(checks.multipleOf(value, params));
490
+ inst.minValue = inst._zod.computed.minimum ?? null;
491
+ inst.maxValue = inst._zod.computed.maximum ?? null;
492
+ inst.format = inst._zod.computed.format ?? null;
493
+ });
494
+ function bigint(params) {
495
+ return core._bigint(exports.ZodBigInt, params);
496
+ }
497
+ exports.ZodBigIntFormat = core.$constructor("ZodBigIntFormat", (inst, def) => {
498
+ core.$ZodBigIntFormat.init(inst, def);
499
+ exports.ZodBigInt.init(inst, def);
500
+ });
501
+ // int64
502
+ function int64(params) {
503
+ return core._int64(exports.ZodBigIntFormat, params);
504
+ }
505
+ // uint64
506
+ function uint64(params) {
507
+ return core._uint64(exports.ZodBigIntFormat, params);
508
+ }
509
+ exports.ZodSymbol = core.$constructor("ZodSymbol", (inst, def) => {
510
+ core.$ZodSymbol.init(inst, def);
511
+ exports.ZodType.init(inst, def);
512
+ });
513
+ function symbol(params) {
514
+ return core._symbol(exports.ZodSymbol, params);
515
+ }
516
+ exports.ZodUndefined = core.$constructor("ZodUndefined", (inst, def) => {
517
+ core.$ZodUndefined.init(inst, def);
518
+ exports.ZodType.init(inst, def);
519
+ });
520
+ function _undefined(params) {
521
+ return core._undefined(exports.ZodUndefined, params);
522
+ }
523
+ exports.ZodNull = core.$constructor("ZodNull", (inst, def) => {
524
+ core.$ZodNull.init(inst, def);
525
+ exports.ZodType.init(inst, def);
526
+ });
527
+ function _null(params) {
528
+ return core._null(exports.ZodNull, params);
529
+ }
530
+ exports.ZodAny = core.$constructor("ZodAny", (inst, def) => {
531
+ core.$ZodAny.init(inst, def);
532
+ exports.ZodType.init(inst, def);
533
+ });
534
+ function any(params) {
535
+ return core._any(exports.ZodAny, params);
536
+ }
537
+ exports.ZodUnknown = core.$constructor("ZodUnknown", (inst, def) => {
538
+ core.$ZodUnknown.init(inst, def);
539
+ exports.ZodType.init(inst, def);
540
+ });
541
+ function unknown(params) {
542
+ return core._unknown(exports.ZodUnknown, params);
543
+ }
544
+ exports.ZodNever = core.$constructor("ZodNever", (inst, def) => {
545
+ core.$ZodNever.init(inst, def);
546
+ exports.ZodType.init(inst, def);
547
+ });
548
+ function never(params) {
549
+ return core._never(exports.ZodNever, params);
550
+ }
551
+ exports.ZodVoid = core.$constructor("ZodVoid", (inst, def) => {
552
+ core.$ZodVoid.init(inst, def);
553
+ exports.ZodType.init(inst, def);
554
+ });
555
+ function _void(params) {
556
+ return core._void(exports.ZodVoid, params);
557
+ }
558
+ exports.ZodDate = core.$constructor("ZodDate", (inst, def) => {
559
+ core.$ZodDate.init(inst, def);
560
+ exports.ZodType.init(inst, def);
561
+ inst.min = (value, params) => inst.check(checks.gte(value, params));
562
+ inst.max = (value, params) => inst.check(checks.lte(value, params));
563
+ const c = inst._zod.computed;
564
+ inst.minDate = c.minimum ? new Date(c.minimum) : null;
565
+ inst.maxDate = c.maximum ? new Date(c.maximum) : null;
566
+ });
567
+ function date(params) {
568
+ return core._date(exports.ZodDate, params);
569
+ }
570
+ exports.ZodArray = core.$constructor("ZodArray", (inst, def) => {
571
+ core.$ZodArray.init(inst, def);
572
+ exports.ZodType.init(inst, def);
573
+ inst.element = def.element;
574
+ inst.min = (minLength, params) => inst.check(checks.minLength(minLength, params));
575
+ inst.nonempty = (params) => inst.check(checks.minLength(1, params));
576
+ inst.max = (maxLength, params) => inst.check(checks.maxLength(maxLength, params));
577
+ inst.length = (len, params) => inst.check(checks.length(len, params));
578
+ });
579
+ function array(element, params) {
580
+ return core._array(exports.ZodArray, element, params);
581
+ }
582
+ exports.ZodObjectLike = core.$constructor("ZodObjectLike", (inst, def) => {
583
+ core.$ZodObjectLike.init(inst, def);
584
+ exports.ZodType.init(inst, def);
585
+ });
586
+ function keyof(schema) {
587
+ const shape = schema._zod.def.type === "interface"
588
+ ? util.cleanInterfaceShape(schema._zod.def.shape).shape
589
+ : schema._zod.def.shape;
590
+ return literal(Object.keys(shape));
591
+ }
592
+ exports.ZodInterface = core.$constructor("ZodInterface", (inst, def) => {
593
+ core.$ZodInterface.init(inst, def);
594
+ exports.ZodType.init(inst, def);
595
+ util.defineLazy(inst._zod, "shape", () => def.shape);
596
+ inst.keyof = () => _enum(Object.keys(inst._zod.def.shape));
597
+ inst.catchall = (catchall) => inst.clone({ ...inst._zod.def, catchall });
598
+ inst.loose = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
599
+ inst.strict = () => inst.clone({ ...inst._zod.def, catchall: never() });
600
+ inst.strip = () => inst.clone({ ...inst._zod.def, catchall: undefined });
601
+ inst.extend = (incoming) => {
602
+ if (incoming instanceof core.$ZodInterface)
603
+ return util.extendObjectLike(inst, incoming);
604
+ return util.extendObjectLike(inst, _interface(incoming));
605
+ };
606
+ inst.merge = (other) => util.mergeObjectLike(inst, other);
607
+ inst.pick = (mask) => util.pick(inst, mask);
608
+ inst.omit = (mask) => util.omit(inst, mask);
609
+ inst.partial = (...args) => util.partialObjectLike(exports.ZodOptional, inst, args[0]);
610
+ inst.required = (...args) => util.requiredObjectLike(exports.ZodNonOptional, inst, args[0]);
611
+ });
612
+ function _interface(shape, params, Class = exports.ZodInterface) {
613
+ const cleaned = util.cached(() => util.cleanInterfaceShape(shape));
614
+ const def = {
615
+ type: "interface",
616
+ get shape() {
617
+ // return cleaned.value.shape;
618
+ const _shape = cleaned.value.shape;
619
+ util.assignProp(this, "shape", _shape);
620
+ return _shape;
621
+ },
622
+ get optional() {
623
+ return cleaned.value.optional;
624
+ },
625
+ ...util.normalizeParams(params),
626
+ };
627
+ return new Class(def);
628
+ }
629
+ // strictInterface
630
+ function strictInterface(shape, params) {
631
+ const cleaned = util.cached(() => util.cleanInterfaceShape(shape));
632
+ const def = {
633
+ type: "interface",
634
+ get shape() {
635
+ // return cleaned.value.shape;
636
+ const _shape = cleaned.value.shape;
637
+ util.assignProp(this, "shape", _shape);
638
+ return _shape;
639
+ },
640
+ get optional() {
641
+ return cleaned.value.optional;
642
+ },
643
+ catchall: never(),
644
+ ...util.normalizeParams(params),
645
+ };
646
+ return new exports.ZodInterface(def);
647
+ }
648
+ // looseInterface
649
+ function looseInterface(shape, params) {
650
+ const cleaned = util.cached(() => util.cleanInterfaceShape(shape));
651
+ const def = {
652
+ type: "interface",
653
+ get optional() {
654
+ return cleaned.value.optional;
655
+ },
656
+ get shape() {
657
+ // return cleaned.value.shape;
658
+ const _shape = cleaned.value.shape;
659
+ util.assignProp(this, "shape", _shape);
660
+ return _shape;
661
+ },
662
+ catchall: unknown(),
663
+ ...util.normalizeParams(params),
664
+ };
665
+ return new exports.ZodInterface(def);
666
+ }
667
+ exports.ZodObject = core.$constructor("ZodObject", (inst, def) => {
668
+ core.$ZodObject.init(inst, def);
669
+ exports.ZodType.init(inst, def);
670
+ inst.shape = def.shape;
671
+ inst.keyof = () => _enum(Object.keys(inst._zod.def.shape));
672
+ inst.catchall = (catchall) => inst.clone({ ...inst._zod.def, catchall });
673
+ inst.passthrough = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
674
+ // inst.nonstrict = () => inst.clone({ ...inst._zod.def, catchall: api.unknown() });
675
+ inst.loose = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
676
+ inst.strict = () => inst.clone({ ...inst._zod.def, catchall: never() });
677
+ inst.strip = () => inst.clone({ ...inst._zod.def, catchall: undefined });
678
+ inst.extend = (incoming) => {
679
+ if (incoming instanceof exports.ZodObject)
680
+ return util.extendObjectLike(inst, incoming);
681
+ return util.extendObjectLike(inst, object(incoming));
682
+ };
683
+ inst.merge = (other) => util.mergeObjectLike(inst, other);
684
+ inst.pick = (mask) => util.pick(inst, mask);
685
+ inst.omit = (mask) => util.omit(inst, mask);
686
+ inst.partial = (...args) => util.partialObjectLike(exports.ZodOptional, inst, args[0]);
687
+ inst.required = (...args) => util.requiredObjectLike(exports.ZodNonOptional, inst, args[0]);
688
+ });
689
+ function object(shape, params) {
690
+ const def = {
691
+ type: "object",
692
+ shape: shape ?? {},
693
+ get optional() {
694
+ return util.optionalObjectKeys(shape ?? {});
695
+ },
696
+ ...util.normalizeParams(params),
697
+ };
698
+ return new exports.ZodObject(def);
699
+ }
700
+ // strictObject
701
+ function strictObject(shape, params) {
702
+ return new exports.ZodObject({
703
+ type: "object",
704
+ shape: shape,
705
+ get optional() {
706
+ return util.optionalObjectKeys(shape);
707
+ },
708
+ catchall: never(),
709
+ ...util.normalizeParams(params),
710
+ });
711
+ }
712
+ // looseObject
713
+ function looseObject(shape, params) {
714
+ return new exports.ZodObject({
715
+ type: "object",
716
+ shape: shape,
717
+ get optional() {
718
+ return util.optionalObjectKeys(shape);
719
+ },
720
+ catchall: unknown(),
721
+ ...util.normalizeParams(params),
722
+ });
723
+ }
724
+ function extend(schema, shape) {
725
+ if (shape instanceof core.$ZodType)
726
+ return util.mergeObjectLike(schema, shape);
727
+ if (schema instanceof exports.ZodInterface) {
728
+ return util.mergeObjectLike(schema, _interface(shape));
729
+ }
730
+ if (schema instanceof exports.ZodObject)
731
+ return util.mergeObjectLike(schema, object(shape));
732
+ return util.extend(schema, shape);
733
+ }
734
+ function merge(a, b) {
735
+ return util.mergeObjectLike(a, b);
736
+ }
737
+ function pick(schema, mask) {
738
+ // const picked = util.pick(schema, mask);
739
+ return util.pick(schema, mask);
740
+ }
741
+ function omit(schema, mask) {
742
+ return util.omit(schema, mask);
743
+ }
744
+ function partial(schema, mask) {
745
+ return util.partialObjectLike(exports.ZodOptional, schema, mask);
746
+ }
747
+ function required(schema, mask) {
748
+ return util.requiredObjectLike(exports.ZodNonOptional, schema, mask);
749
+ }
750
+ exports.ZodUnion = core.$constructor("ZodUnion", (inst, def) => {
751
+ core.$ZodUnion.init(inst, def);
752
+ exports.ZodType.init(inst, def);
753
+ inst.options = def.options;
754
+ });
755
+ function union(options, params) {
756
+ return new exports.ZodUnion({
757
+ type: "union",
758
+ options,
759
+ ...util.normalizeParams(params),
760
+ });
761
+ }
762
+ exports.ZodDiscriminatedUnion = core.$constructor("ZodDiscriminatedUnion", (inst, def) => {
763
+ core.$ZodDiscriminatedUnion.init(inst, def);
764
+ exports.ZodType.init(inst, def);
765
+ });
766
+ function discriminatedUnion(...args) {
767
+ if (typeof args[0] === "string")
768
+ args = args.slice(1);
769
+ const [options, params] = args;
770
+ return new exports.ZodDiscriminatedUnion({
771
+ type: "union",
772
+ options,
773
+ ...util.normalizeParams(params),
774
+ });
775
+ }
776
+ exports.ZodIntersection = core.$constructor("ZodIntersection", (inst, def) => {
777
+ core.$ZodIntersection.init(inst, def);
778
+ exports.ZodType.init(inst, def);
779
+ });
780
+ function intersection(left, right, params) {
781
+ return new exports.ZodIntersection({
782
+ type: "intersection",
783
+ left,
784
+ right,
785
+ ...util.normalizeParams(params),
786
+ });
787
+ }
788
+ exports.ZodTuple = core.$constructor("ZodTuple", (inst, def) => {
789
+ core.$ZodTuple.init(inst, def);
790
+ exports.ZodType.init(inst, def);
791
+ inst.rest = (rest) => inst.clone({
792
+ ...inst._zod.def,
793
+ rest,
794
+ });
795
+ });
796
+ function tuple(items, _paramsOrRest, _params) {
797
+ const hasRest = _paramsOrRest instanceof core.$ZodType;
798
+ const params = hasRest ? _params : _paramsOrRest;
799
+ const rest = hasRest ? _paramsOrRest : null;
800
+ return new exports.ZodTuple({
801
+ type: "tuple",
802
+ items,
803
+ rest,
804
+ ...util.normalizeParams(params),
805
+ });
806
+ }
807
+ exports.ZodRecord = core.$constructor("ZodRecord", (inst, def) => {
808
+ core.$ZodRecord.init(inst, def);
809
+ exports.ZodType.init(inst, def);
810
+ inst.keyType = def.keyType;
811
+ inst.valueType = def.valueType;
812
+ });
813
+ function record(keyType, valueType, params) {
814
+ return new exports.ZodRecord({
815
+ type: "record",
816
+ keyType,
817
+ valueType,
818
+ ...util.normalizeParams(params),
819
+ });
820
+ }
821
+ exports.ZodMap = core.$constructor("ZodMap", (inst, def) => {
822
+ core.$ZodMap.init(inst, def);
823
+ exports.ZodType.init(inst, def);
824
+ inst.keyType = def.keyType;
825
+ inst.valueType = def.valueType;
826
+ });
827
+ function map(keyType, valueType, params) {
828
+ return new exports.ZodMap({
829
+ type: "map",
830
+ keyType,
831
+ valueType,
832
+ ...util.normalizeParams(params),
833
+ });
834
+ }
835
+ exports.ZodSet = core.$constructor("ZodSet", (inst, def) => {
836
+ core.$ZodSet.init(inst, def);
837
+ exports.ZodType.init(inst, def);
838
+ inst.min = (...args) => inst.check(core._minSize(...args));
839
+ inst.nonempty = (params) => inst.check(core._minSize(1, params));
840
+ inst.max = (...args) => inst.check(core._maxSize(...args));
841
+ inst.size = (...args) => inst.check(core._size(...args));
842
+ });
843
+ function set(valueType, params) {
844
+ return new exports.ZodSet({
845
+ type: "set",
846
+ valueType,
847
+ ...util.normalizeParams(params),
848
+ });
849
+ }
850
+ exports.ZodEnum = core.$constructor("ZodEnum", (inst, def) => {
851
+ core.$ZodEnum.init(inst, def);
852
+ exports.ZodType.init(inst, def);
853
+ inst.enum = def.entries;
854
+ inst.options = Object.values(def.entries);
855
+ const keys = new Set(Object.keys(def.entries));
856
+ inst.extract = (values, params) => {
857
+ const newEntries = {};
858
+ for (const value of values) {
859
+ if (keys.has(value)) {
860
+ newEntries[value] = def.entries[value];
861
+ }
862
+ else
863
+ throw new Error(`Key ${value} not found in enum`);
864
+ }
865
+ return new exports.ZodEnum({
866
+ ...def,
867
+ checks: [],
868
+ ...util.normalizeParams(params),
869
+ entries: newEntries,
870
+ });
871
+ };
872
+ inst.exclude = (values, params) => {
873
+ const newEntries = { ...def.entries };
874
+ for (const value of values) {
875
+ if (keys.has(value)) {
876
+ delete newEntries[value];
877
+ }
878
+ else
879
+ throw new Error(`Key ${value} not found in enum`);
880
+ }
881
+ return new exports.ZodEnum({
882
+ ...def,
883
+ checks: [],
884
+ ...util.normalizeParams(params),
885
+ entries: newEntries,
886
+ });
887
+ };
888
+ });
889
+ function _enum(values, params) {
890
+ const entries = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
891
+ return new exports.ZodEnum({
892
+ type: "enum",
893
+ entries,
894
+ ...util.normalizeParams(params),
895
+ });
896
+ }
897
+ /** @deprecated This API has been merged into `z.enum()`. Use `z.enum()` instead.
898
+ *
899
+ * ```ts
900
+ * enum Colors { red, green, blue }
901
+ * z.enum(Colors);
902
+ * ```
903
+ */
904
+ function nativeEnum(entries, params) {
905
+ return new exports.ZodEnum({
906
+ type: "enum",
907
+ entries,
908
+ ...util.normalizeParams(params),
909
+ });
910
+ }
911
+ exports.ZodLiteral = core.$constructor("ZodLiteral", (inst, def) => {
912
+ core.$ZodLiteral.init(inst, def);
913
+ exports.ZodType.init(inst, def);
914
+ inst.values = new Set(def.values);
915
+ });
916
+ function literal(value, params) {
917
+ return new exports.ZodLiteral({
918
+ type: "literal",
919
+ values: Array.isArray(value) ? value : [value],
920
+ ...util.normalizeParams(params),
921
+ });
922
+ }
923
+ exports.ZodFile = core.$constructor("ZodFile", (inst, def) => {
924
+ core.$ZodFile.init(inst, def);
925
+ exports.ZodType.init(inst, def);
926
+ inst.min = (size, params) => inst.check(core._minSize(size, params));
927
+ inst.max = (size, params) => inst.check(core._maxSize(size, params));
928
+ inst.mime = (types, params) => inst.check(core._mime(types, params));
929
+ });
930
+ function file(params) {
931
+ return core._file(exports.ZodFile, params);
932
+ }
933
+ exports.ZodTransform = core.$constructor("ZodTransform", (inst, def) => {
934
+ core.$ZodTransform.init(inst, def);
935
+ exports.ZodType.init(inst, def);
936
+ inst._zod.parse = (payload, _ctx) => {
937
+ payload.addIssue = (issue) => {
938
+ if (typeof issue === "string") {
939
+ payload.issues.push(util.issue(issue, payload.value, def));
940
+ }
941
+ else {
942
+ // for Zod 3 backwards compatibility
943
+ const _issue = issue;
944
+ if (_issue.fatal)
945
+ _issue.continue = false;
946
+ _issue.code ?? (_issue.code = "custom");
947
+ _issue.input ?? (_issue.input = payload.value);
948
+ _issue.inst ?? (_issue.inst = inst);
949
+ _issue.continue ?? (_issue.continue = !def.abort);
950
+ payload.issues.push(util.issue(_issue));
951
+ }
952
+ };
953
+ const output = def.transform(payload.value, payload);
954
+ if (output instanceof Promise) {
955
+ return output.then((output) => {
956
+ payload.value = output;
957
+ return payload;
958
+ });
959
+ }
960
+ payload.value = output;
961
+ return payload;
962
+ };
963
+ });
964
+ function transform(fn, params) {
965
+ return new exports.ZodTransform({
966
+ type: "transform",
967
+ transform: fn,
968
+ ...util.normalizeParams(params),
969
+ });
970
+ }
971
+ exports.ZodOptional = core.$constructor("ZodOptional", (inst, def) => {
972
+ core.$ZodOptional.init(inst, def);
973
+ exports.ZodType.init(inst, def);
974
+ inst.unwrap = () => inst._zod.def.innerType;
975
+ });
976
+ function optional(innerType, params) {
977
+ return new exports.ZodOptional({
978
+ type: "optional",
979
+ innerType,
980
+ ...util.normalizeParams(params),
981
+ });
982
+ }
983
+ exports.ZodNullable = core.$constructor("ZodNullable", (inst, def) => {
984
+ core.$ZodNullable.init(inst, def);
985
+ exports.ZodType.init(inst, def);
986
+ inst.unwrap = () => inst._zod.def.innerType;
987
+ });
988
+ function nullable(innerType, params) {
989
+ return new exports.ZodNullable({
990
+ type: "nullable",
991
+ innerType,
992
+ ...util.normalizeParams(params),
993
+ });
994
+ }
995
+ // nullish
996
+ function nullish(innerType) {
997
+ return optional(nullable(innerType));
998
+ }
999
+ exports.ZodDefault = core.$constructor("ZodDefault", (inst, def) => {
1000
+ core.$ZodDefault.init(inst, def);
1001
+ exports.ZodType.init(inst, def);
1002
+ inst.unwrap = () => inst._zod.def.innerType;
1003
+ inst.removeDefault = inst.unwrap;
1004
+ });
1005
+ function _default(innerType, defaultValue, params) {
1006
+ return new exports.ZodDefault({
1007
+ type: "default",
1008
+ defaultValue: (typeof defaultValue === "function" ? defaultValue : () => defaultValue),
1009
+ innerType,
1010
+ ...util.normalizeParams(params),
1011
+ });
1012
+ }
1013
+ exports.ZodNonOptional = core.$constructor("ZodNonOptional", (inst, def) => {
1014
+ core.$ZodNonOptional.init(inst, def);
1015
+ exports.ZodType.init(inst, def);
1016
+ inst.unwrap = () => inst._zod.def.innerType;
1017
+ });
1018
+ function nonoptional(innerType, params) {
1019
+ return new exports.ZodNonOptional({
1020
+ type: "nonoptional",
1021
+ innerType,
1022
+ ...util.normalizeParams(params),
1023
+ });
1024
+ }
1025
+ exports.ZodSuccess = core.$constructor("ZodSuccess", (inst, def) => {
1026
+ core.$ZodSuccess.init(inst, def);
1027
+ exports.ZodType.init(inst, def);
1028
+ inst.unwrap = () => inst._zod.def.innerType;
1029
+ });
1030
+ function success(innerType, params) {
1031
+ return new exports.ZodSuccess({
1032
+ type: "success",
1033
+ innerType,
1034
+ ...util.normalizeParams(params),
1035
+ });
1036
+ }
1037
+ exports.ZodCatch = core.$constructor("ZodCatch", (inst, def) => {
1038
+ core.$ZodCatch.init(inst, def);
1039
+ exports.ZodType.init(inst, def);
1040
+ inst.unwrap = () => inst._zod.def.innerType;
1041
+ inst.removeCatch = inst.unwrap;
1042
+ });
1043
+ function _catch(innerType, catchValue, params) {
1044
+ return new exports.ZodCatch({
1045
+ type: "catch",
1046
+ innerType,
1047
+ catchValue: (typeof catchValue === "function" ? catchValue : () => catchValue),
1048
+ ...util.normalizeParams(params),
1049
+ });
1050
+ }
1051
+ exports.ZodNaN = core.$constructor("ZodNaN", (inst, def) => {
1052
+ core.$ZodNaN.init(inst, def);
1053
+ exports.ZodType.init(inst, def);
1054
+ });
1055
+ function nan(params) {
1056
+ return core._nan(exports.ZodNaN, params);
1057
+ }
1058
+ exports.ZodPipe = core.$constructor("ZodPipe", (inst, def) => {
1059
+ core.$ZodPipe.init(inst, def);
1060
+ exports.ZodType.init(inst, def);
1061
+ inst.in = def.in;
1062
+ inst.out = def.out;
1063
+ });
1064
+ function pipe(in_, out, params) {
1065
+ return new exports.ZodPipe({
1066
+ type: "pipe",
1067
+ in: in_,
1068
+ out,
1069
+ ...util.normalizeParams(params),
1070
+ });
1071
+ }
1072
+ exports.ZodReadonly = core.$constructor("ZodReadonly", (inst, def) => {
1073
+ core.$ZodReadonly.init(inst, def);
1074
+ exports.ZodType.init(inst, def);
1075
+ });
1076
+ function readonly(innerType, params) {
1077
+ return new exports.ZodReadonly({
1078
+ type: "readonly",
1079
+ innerType,
1080
+ ...util.normalizeParams(params),
1081
+ });
1082
+ }
1083
+ exports.ZodTemplateLiteral = core.$constructor("ZodTemplateLiteral", (inst, def) => {
1084
+ core.$ZodTemplateLiteral.init(inst, def);
1085
+ exports.ZodType.init(inst, def);
1086
+ });
1087
+ function templateLiteral(parts, params) {
1088
+ return new exports.ZodTemplateLiteral({
1089
+ type: "template_literal",
1090
+ parts,
1091
+ ...util.normalizeParams(params),
1092
+ });
1093
+ }
1094
+ exports.ZodLazy = core.$constructor("ZodLazy", (inst, def) => {
1095
+ core.$ZodLazy.init(inst, def);
1096
+ exports.ZodType.init(inst, def);
1097
+ inst.unwrap = () => inst._zod.def.getter();
1098
+ });
1099
+ function lazy(getter) {
1100
+ return new exports.ZodLazy({
1101
+ type: "lazy",
1102
+ getter,
1103
+ });
1104
+ }
1105
+ exports.ZodPromise = core.$constructor("ZodPromise", (inst, def) => {
1106
+ core.$ZodPromise.init(inst, def);
1107
+ exports.ZodType.init(inst, def);
1108
+ inst.unwrap = () => inst._zod.def.innerType;
1109
+ });
1110
+ function promise(innerType, params) {
1111
+ return new exports.ZodPromise({
1112
+ type: "promise",
1113
+ innerType,
1114
+ ...util.normalizeParams(params),
1115
+ });
1116
+ }
1117
+ exports.ZodCustom = core.$constructor("ZodCustom", (inst, def) => {
1118
+ core.$ZodCustom.init(inst, def);
1119
+ exports.ZodType.init(inst, def);
1120
+ });
1121
+ // custom checks
1122
+ function check(fn, params) {
1123
+ const ch = new core.$ZodCheck({
1124
+ check: "custom",
1125
+ ...util.normalizeParams(params),
1126
+ });
1127
+ ch._zod.check = fn;
1128
+ return ch;
1129
+ }
1130
+ function custom(fn, _params) {
1131
+ return core._custom(exports.ZodCustom, fn ?? (() => true), _params);
1132
+ }
1133
+ function refine(fn, _params = {}) {
1134
+ return core._custom(exports.ZodCustom, fn, _params);
1135
+ }
1136
+ // superRefine
1137
+ function superRefine(fn, params) {
1138
+ const ch = check((payload) => {
1139
+ payload.addIssue = (issue) => {
1140
+ if (typeof issue === "string") {
1141
+ payload.issues.push(util.issue(issue, payload.value, ch._zod.def));
1142
+ }
1143
+ else {
1144
+ // for Zod 3 backwards compatibility
1145
+ const _issue = issue;
1146
+ if (_issue.fatal)
1147
+ _issue.continue = false;
1148
+ _issue.code ?? (_issue.code = "custom");
1149
+ _issue.input ?? (_issue.input = payload.value);
1150
+ _issue.inst ?? (_issue.inst = ch);
1151
+ _issue.continue ?? (_issue.continue = !ch._zod.def.abort);
1152
+ payload.issues.push(util.issue(_issue));
1153
+ }
1154
+ };
1155
+ return fn(payload.value, payload);
1156
+ }, params);
1157
+ return ch;
1158
+ }
1159
+ // instanceof
1160
+ class Class {
1161
+ constructor(..._args) { }
1162
+ }
1163
+ function _instanceof(cls, params = {
1164
+ error: `Input not instance of ${cls.name}`,
1165
+ }) {
1166
+ return new exports.ZodCustom({
1167
+ type: "custom",
1168
+ check: "custom",
1169
+ fn: (data) => data instanceof cls,
1170
+ abort: true,
1171
+ ...util.normalizeParams(params),
1172
+ });
1173
+ }
1174
+ // stringbool
1175
+ exports.stringbool =
1176
+ /*@__PURE__*/ core._stringbool.bind(null, {
1177
+ Pipe: exports.ZodPipe,
1178
+ Boolean: exports.ZodBoolean,
1179
+ Unknown: exports.ZodUnknown,
1180
+ });
1181
+ function json(params) {
1182
+ const jsonSchema = lazy(() => {
1183
+ return union([string(params), number(), boolean(), _null(), array(jsonSchema), record(string(), jsonSchema)]);
1184
+ });
1185
+ return jsonSchema;
1186
+ }
1187
+ // /** @deprecated Use `z.pipe()` and `z.transform()` instead. */
1188
+ function preprocess(fn, schema, params) {
1189
+ return pipe(transform(fn, params), schema, params);
1190
+ }