lkd-web-kit 0.4.8 → 0.4.9

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 (132) hide show
  1. package/dist/hooks/useZodConfig.cjs +2 -2
  2. package/dist/hooks/useZodConfig.js +2 -2
  3. package/dist/index.d.ts +2 -2
  4. package/package.json +7 -7
  5. package/dist/node_modules/zod/v4/classic/coerce.cjs +0 -28
  6. package/dist/node_modules/zod/v4/classic/coerce.js +0 -20
  7. package/dist/node_modules/zod/v4/classic/compat.cjs +0 -37
  8. package/dist/node_modules/zod/v4/classic/compat.js +0 -30
  9. package/dist/node_modules/zod/v4/classic/errors.cjs +0 -49
  10. package/dist/node_modules/zod/v4/classic/errors.js +0 -44
  11. package/dist/node_modules/zod/v4/classic/external.cjs +0 -231
  12. package/dist/node_modules/zod/v4/classic/external.js +0 -28
  13. package/dist/node_modules/zod/v4/classic/index.cjs +0 -10
  14. package/dist/node_modules/zod/v4/classic/index.js +0 -5
  15. package/dist/node_modules/zod/v4/classic/iso.cjs +0 -46
  16. package/dist/node_modules/zod/v4/classic/iso.js +0 -35
  17. package/dist/node_modules/zod/v4/classic/parse.cjs +0 -16
  18. package/dist/node_modules/zod/v4/classic/parse.js +0 -9
  19. package/dist/node_modules/zod/v4/classic/schemas.cjs +0 -1155
  20. package/dist/node_modules/zod/v4/classic/schemas.js +0 -1006
  21. package/dist/node_modules/zod/v4/core/api.cjs +0 -1016
  22. package/dist/node_modules/zod/v4/core/api.js +0 -903
  23. package/dist/node_modules/zod/v4/core/checks.cjs +0 -587
  24. package/dist/node_modules/zod/v4/core/checks.js +0 -562
  25. package/dist/node_modules/zod/v4/core/core.cjs +0 -72
  26. package/dist/node_modules/zod/v4/core/core.js +0 -63
  27. package/dist/node_modules/zod/v4/core/doc.cjs +0 -41
  28. package/dist/node_modules/zod/v4/core/doc.js +0 -37
  29. package/dist/node_modules/zod/v4/core/errors.cjs +0 -204
  30. package/dist/node_modules/zod/v4/core/errors.js +0 -194
  31. package/dist/node_modules/zod/v4/core/function.cjs +0 -81
  32. package/dist/node_modules/zod/v4/core/function.js +0 -76
  33. package/dist/node_modules/zod/v4/core/index.cjs +0 -261
  34. package/dist/node_modules/zod/v4/core/index.js +0 -20
  35. package/dist/node_modules/zod/v4/core/json-schema.cjs +0 -2
  36. package/dist/node_modules/zod/v4/core/json-schema.js +0 -1
  37. package/dist/node_modules/zod/v4/core/parse.cjs +0 -71
  38. package/dist/node_modules/zod/v4/core/parse.js +0 -60
  39. package/dist/node_modules/zod/v4/core/regexes.cjs +0 -139
  40. package/dist/node_modules/zod/v4/core/regexes.js +0 -95
  41. package/dist/node_modules/zod/v4/core/registries.cjs +0 -52
  42. package/dist/node_modules/zod/v4/core/registries.js +0 -44
  43. package/dist/node_modules/zod/v4/core/schemas.cjs +0 -1793
  44. package/dist/node_modules/zod/v4/core/schemas.js +0 -1720
  45. package/dist/node_modules/zod/v4/core/to-json-schema.cjs +0 -823
  46. package/dist/node_modules/zod/v4/core/to-json-schema.js +0 -818
  47. package/dist/node_modules/zod/v4/core/util.cjs +0 -543
  48. package/dist/node_modules/zod/v4/core/util.js +0 -491
  49. package/dist/node_modules/zod/v4/core/versions.cjs +0 -11
  50. package/dist/node_modules/zod/v4/core/versions.js +0 -7
  51. package/dist/node_modules/zod/v4/index.cjs +0 -10
  52. package/dist/node_modules/zod/v4/index.js +0 -5
  53. package/dist/node_modules/zod/v4/locales/ar.cjs +0 -121
  54. package/dist/node_modules/zod/v4/locales/ar.js +0 -119
  55. package/dist/node_modules/zod/v4/locales/az.cjs +0 -120
  56. package/dist/node_modules/zod/v4/locales/az.js +0 -118
  57. package/dist/node_modules/zod/v4/locales/be.cjs +0 -169
  58. package/dist/node_modules/zod/v4/locales/be.js +0 -167
  59. package/dist/node_modules/zod/v4/locales/ca.cjs +0 -123
  60. package/dist/node_modules/zod/v4/locales/ca.js +0 -121
  61. package/dist/node_modules/zod/v4/locales/cs.cjs +0 -140
  62. package/dist/node_modules/zod/v4/locales/cs.js +0 -138
  63. package/dist/node_modules/zod/v4/locales/de.cjs +0 -121
  64. package/dist/node_modules/zod/v4/locales/de.js +0 -119
  65. package/dist/node_modules/zod/v4/locales/en.cjs +0 -125
  66. package/dist/node_modules/zod/v4/locales/en.js +0 -120
  67. package/dist/node_modules/zod/v4/locales/eo.cjs +0 -124
  68. package/dist/node_modules/zod/v4/locales/eo.js +0 -119
  69. package/dist/node_modules/zod/v4/locales/es.cjs +0 -122
  70. package/dist/node_modules/zod/v4/locales/es.js +0 -120
  71. package/dist/node_modules/zod/v4/locales/fa.cjs +0 -127
  72. package/dist/node_modules/zod/v4/locales/fa.js +0 -125
  73. package/dist/node_modules/zod/v4/locales/fi.cjs +0 -127
  74. package/dist/node_modules/zod/v4/locales/fi.js +0 -125
  75. package/dist/node_modules/zod/v4/locales/fr-CA.cjs +0 -122
  76. package/dist/node_modules/zod/v4/locales/fr-CA.js +0 -120
  77. package/dist/node_modules/zod/v4/locales/fr.cjs +0 -121
  78. package/dist/node_modules/zod/v4/locales/fr.js +0 -119
  79. package/dist/node_modules/zod/v4/locales/he.cjs +0 -122
  80. package/dist/node_modules/zod/v4/locales/he.js +0 -120
  81. package/dist/node_modules/zod/v4/locales/hu.cjs +0 -122
  82. package/dist/node_modules/zod/v4/locales/hu.js +0 -120
  83. package/dist/node_modules/zod/v4/locales/id.cjs +0 -121
  84. package/dist/node_modules/zod/v4/locales/id.js +0 -119
  85. package/dist/node_modules/zod/v4/locales/index.cjs +0 -85
  86. package/dist/node_modules/zod/v4/locales/index.js +0 -39
  87. package/dist/node_modules/zod/v4/locales/it.cjs +0 -122
  88. package/dist/node_modules/zod/v4/locales/it.js +0 -120
  89. package/dist/node_modules/zod/v4/locales/ja.cjs +0 -120
  90. package/dist/node_modules/zod/v4/locales/ja.js +0 -118
  91. package/dist/node_modules/zod/v4/locales/kh.cjs +0 -122
  92. package/dist/node_modules/zod/v4/locales/kh.js +0 -120
  93. package/dist/node_modules/zod/v4/locales/ko.cjs +0 -126
  94. package/dist/node_modules/zod/v4/locales/ko.js +0 -124
  95. package/dist/node_modules/zod/v4/locales/mk.cjs +0 -123
  96. package/dist/node_modules/zod/v4/locales/mk.js +0 -121
  97. package/dist/node_modules/zod/v4/locales/ms.cjs +0 -121
  98. package/dist/node_modules/zod/v4/locales/ms.js +0 -119
  99. package/dist/node_modules/zod/v4/locales/nl.cjs +0 -122
  100. package/dist/node_modules/zod/v4/locales/nl.js +0 -120
  101. package/dist/node_modules/zod/v4/locales/no.cjs +0 -121
  102. package/dist/node_modules/zod/v4/locales/no.js +0 -119
  103. package/dist/node_modules/zod/v4/locales/ota.cjs +0 -122
  104. package/dist/node_modules/zod/v4/locales/ota.js +0 -120
  105. package/dist/node_modules/zod/v4/locales/pl.cjs +0 -122
  106. package/dist/node_modules/zod/v4/locales/pl.js +0 -120
  107. package/dist/node_modules/zod/v4/locales/ps.cjs +0 -127
  108. package/dist/node_modules/zod/v4/locales/ps.js +0 -125
  109. package/dist/node_modules/zod/v4/locales/pt.cjs +0 -121
  110. package/dist/node_modules/zod/v4/locales/pt.js +0 -119
  111. package/dist/node_modules/zod/v4/locales/ru.cjs +0 -169
  112. package/dist/node_modules/zod/v4/locales/ru.js +0 -167
  113. package/dist/node_modules/zod/v4/locales/sl.cjs +0 -122
  114. package/dist/node_modules/zod/v4/locales/sl.js +0 -120
  115. package/dist/node_modules/zod/v4/locales/sv.cjs +0 -123
  116. package/dist/node_modules/zod/v4/locales/sv.js +0 -121
  117. package/dist/node_modules/zod/v4/locales/ta.cjs +0 -122
  118. package/dist/node_modules/zod/v4/locales/ta.js +0 -120
  119. package/dist/node_modules/zod/v4/locales/th.cjs +0 -122
  120. package/dist/node_modules/zod/v4/locales/th.js +0 -120
  121. package/dist/node_modules/zod/v4/locales/tr.cjs +0 -123
  122. package/dist/node_modules/zod/v4/locales/tr.js +0 -118
  123. package/dist/node_modules/zod/v4/locales/ua.cjs +0 -122
  124. package/dist/node_modules/zod/v4/locales/ua.js +0 -120
  125. package/dist/node_modules/zod/v4/locales/ur.cjs +0 -122
  126. package/dist/node_modules/zod/v4/locales/ur.js +0 -120
  127. package/dist/node_modules/zod/v4/locales/vi.cjs +0 -121
  128. package/dist/node_modules/zod/v4/locales/vi.js +0 -119
  129. package/dist/node_modules/zod/v4/locales/zh-CN.cjs +0 -121
  130. package/dist/node_modules/zod/v4/locales/zh-CN.js +0 -119
  131. package/dist/node_modules/zod/v4/locales/zh-TW.cjs +0 -122
  132. package/dist/node_modules/zod/v4/locales/zh-TW.js +0 -120
@@ -1,1793 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
-
5
- const checks = require('./checks.cjs');
6
- const core = require('./core.cjs');
7
- const doc = require('./doc.cjs');
8
- const parse = require('./parse.cjs');
9
- const regexes = require('./regexes.cjs');
10
- const util = require('./util.cjs');
11
- const versions = require('./versions.cjs');
12
-
13
- const $ZodType = /*@__PURE__*/ core.$constructor("$ZodType", (inst, def) => {
14
- var _a;
15
- inst ?? (inst = {});
16
- inst._zod.def = def; // set _def property
17
- inst._zod.bag = inst._zod.bag || {}; // initialize _bag object
18
- inst._zod.version = versions.version;
19
- const checks = [...(inst._zod.def.checks ?? [])];
20
- // if inst is itself a checks.$ZodCheck, run it as a check
21
- if (inst._zod.traits.has("$ZodCheck")) {
22
- checks.unshift(inst);
23
- }
24
- //
25
- for (const ch of checks) {
26
- for (const fn of ch._zod.onattach) {
27
- fn(inst);
28
- }
29
- }
30
- if (checks.length === 0) {
31
- // deferred initializer
32
- // inst._zod.parse is not yet defined
33
- (_a = inst._zod).deferred ?? (_a.deferred = []);
34
- inst._zod.deferred?.push(() => {
35
- inst._zod.run = inst._zod.parse;
36
- });
37
- }
38
- else {
39
- const runChecks = (payload, checks, ctx) => {
40
- let isAborted = util.aborted(payload);
41
- let asyncResult;
42
- for (const ch of checks) {
43
- if (ch._zod.when) {
44
- const shouldRun = ch._zod.when(payload);
45
- if (!shouldRun)
46
- continue;
47
- }
48
- else if (isAborted) {
49
- continue;
50
- }
51
- const currLen = payload.issues.length;
52
- const _ = ch._zod.check(payload);
53
- if (_ instanceof Promise && ctx?.async === false) {
54
- throw new core.$ZodAsyncError();
55
- }
56
- if (asyncResult || _ instanceof Promise) {
57
- asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
58
- await _;
59
- const nextLen = payload.issues.length;
60
- if (nextLen === currLen)
61
- return;
62
- if (!isAborted)
63
- isAborted = util.aborted(payload, currLen);
64
- });
65
- }
66
- else {
67
- const nextLen = payload.issues.length;
68
- if (nextLen === currLen)
69
- continue;
70
- if (!isAborted)
71
- isAborted = util.aborted(payload, currLen);
72
- }
73
- }
74
- if (asyncResult) {
75
- return asyncResult.then(() => {
76
- return payload;
77
- });
78
- }
79
- return payload;
80
- };
81
- inst._zod.run = (payload, ctx) => {
82
- const result = inst._zod.parse(payload, ctx);
83
- if (result instanceof Promise) {
84
- if (ctx.async === false)
85
- throw new core.$ZodAsyncError();
86
- return result.then((result) => runChecks(result, checks, ctx));
87
- }
88
- return runChecks(result, checks, ctx);
89
- };
90
- }
91
- inst["~standard"] = {
92
- validate: (value) => {
93
- try {
94
- const r = parse.safeParse(inst, value);
95
- return r.success ? { value: r.data } : { issues: r.error?.issues };
96
- }
97
- catch (_) {
98
- return parse.safeParseAsync(inst, value).then((r) => (r.success ? { value: r.data } : { issues: r.error?.issues }));
99
- }
100
- },
101
- vendor: "zod",
102
- version: 1,
103
- };
104
- });
105
- const $ZodString = /*@__PURE__*/ core.$constructor("$ZodString", (inst, def) => {
106
- $ZodType.init(inst, def);
107
- inst._zod.pattern = [...(inst?._zod.bag?.patterns ?? [])].pop() ?? regexes.string(inst._zod.bag);
108
- inst._zod.parse = (payload, _) => {
109
- if (def.coerce)
110
- try {
111
- payload.value = String(payload.value);
112
- }
113
- catch (_) { }
114
- if (typeof payload.value === "string")
115
- return payload;
116
- payload.issues.push({
117
- expected: "string",
118
- code: "invalid_type",
119
- input: payload.value,
120
- inst,
121
- });
122
- return payload;
123
- };
124
- });
125
- const $ZodStringFormat = /*@__PURE__*/ core.$constructor("$ZodStringFormat", (inst, def) => {
126
- // check initialization must come first
127
- checks.$ZodCheckStringFormat.init(inst, def);
128
- $ZodString.init(inst, def);
129
- });
130
- const $ZodGUID = /*@__PURE__*/ core.$constructor("$ZodGUID", (inst, def) => {
131
- def.pattern ?? (def.pattern = regexes.guid);
132
- $ZodStringFormat.init(inst, def);
133
- });
134
- const $ZodUUID = /*@__PURE__*/ core.$constructor("$ZodUUID", (inst, def) => {
135
- if (def.version) {
136
- const versionMap = {
137
- v1: 1,
138
- v2: 2,
139
- v3: 3,
140
- v4: 4,
141
- v5: 5,
142
- v6: 6,
143
- v7: 7,
144
- v8: 8,
145
- };
146
- const v = versionMap[def.version];
147
- if (v === undefined)
148
- throw new Error(`Invalid UUID version: "${def.version}"`);
149
- def.pattern ?? (def.pattern = regexes.uuid(v));
150
- }
151
- else
152
- def.pattern ?? (def.pattern = regexes.uuid());
153
- $ZodStringFormat.init(inst, def);
154
- });
155
- const $ZodEmail = /*@__PURE__*/ core.$constructor("$ZodEmail", (inst, def) => {
156
- def.pattern ?? (def.pattern = regexes.email);
157
- $ZodStringFormat.init(inst, def);
158
- });
159
- const $ZodURL = /*@__PURE__*/ core.$constructor("$ZodURL", (inst, def) => {
160
- $ZodStringFormat.init(inst, def);
161
- inst._zod.check = (payload) => {
162
- try {
163
- const orig = payload.value;
164
- const url = new URL(orig);
165
- const href = url.href;
166
- if (def.hostname) {
167
- def.hostname.lastIndex = 0;
168
- if (!def.hostname.test(url.hostname)) {
169
- payload.issues.push({
170
- code: "invalid_format",
171
- format: "url",
172
- note: "Invalid hostname",
173
- pattern: regexes.hostname.source,
174
- input: payload.value,
175
- inst,
176
- continue: !def.abort,
177
- });
178
- }
179
- }
180
- if (def.protocol) {
181
- def.protocol.lastIndex = 0;
182
- if (!def.protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol)) {
183
- payload.issues.push({
184
- code: "invalid_format",
185
- format: "url",
186
- note: "Invalid protocol",
187
- pattern: def.protocol.source,
188
- input: payload.value,
189
- inst,
190
- continue: !def.abort,
191
- });
192
- }
193
- }
194
- // payload.value = url.href;
195
- if (!orig.endsWith("/") && href.endsWith("/")) {
196
- payload.value = href.slice(0, -1);
197
- }
198
- else {
199
- payload.value = href;
200
- }
201
- return;
202
- }
203
- catch (_) {
204
- payload.issues.push({
205
- code: "invalid_format",
206
- format: "url",
207
- input: payload.value,
208
- inst,
209
- continue: !def.abort,
210
- });
211
- }
212
- };
213
- });
214
- const $ZodEmoji = /*@__PURE__*/ core.$constructor("$ZodEmoji", (inst, def) => {
215
- def.pattern ?? (def.pattern = regexes.emoji());
216
- $ZodStringFormat.init(inst, def);
217
- });
218
- const $ZodNanoID = /*@__PURE__*/ core.$constructor("$ZodNanoID", (inst, def) => {
219
- def.pattern ?? (def.pattern = regexes.nanoid);
220
- $ZodStringFormat.init(inst, def);
221
- });
222
- const $ZodCUID = /*@__PURE__*/ core.$constructor("$ZodCUID", (inst, def) => {
223
- def.pattern ?? (def.pattern = regexes.cuid);
224
- $ZodStringFormat.init(inst, def);
225
- });
226
- const $ZodCUID2 = /*@__PURE__*/ core.$constructor("$ZodCUID2", (inst, def) => {
227
- def.pattern ?? (def.pattern = regexes.cuid2);
228
- $ZodStringFormat.init(inst, def);
229
- });
230
- const $ZodULID = /*@__PURE__*/ core.$constructor("$ZodULID", (inst, def) => {
231
- def.pattern ?? (def.pattern = regexes.ulid);
232
- $ZodStringFormat.init(inst, def);
233
- });
234
- const $ZodXID = /*@__PURE__*/ core.$constructor("$ZodXID", (inst, def) => {
235
- def.pattern ?? (def.pattern = regexes.xid);
236
- $ZodStringFormat.init(inst, def);
237
- });
238
- const $ZodKSUID = /*@__PURE__*/ core.$constructor("$ZodKSUID", (inst, def) => {
239
- def.pattern ?? (def.pattern = regexes.ksuid);
240
- $ZodStringFormat.init(inst, def);
241
- });
242
- const $ZodISODateTime = /*@__PURE__*/ core.$constructor("$ZodISODateTime", (inst, def) => {
243
- def.pattern ?? (def.pattern = regexes.datetime(def));
244
- $ZodStringFormat.init(inst, def);
245
- });
246
- const $ZodISODate = /*@__PURE__*/ core.$constructor("$ZodISODate", (inst, def) => {
247
- def.pattern ?? (def.pattern = regexes.date);
248
- $ZodStringFormat.init(inst, def);
249
- });
250
- const $ZodISOTime = /*@__PURE__*/ core.$constructor("$ZodISOTime", (inst, def) => {
251
- def.pattern ?? (def.pattern = regexes.time(def));
252
- $ZodStringFormat.init(inst, def);
253
- });
254
- const $ZodISODuration = /*@__PURE__*/ core.$constructor("$ZodISODuration", (inst, def) => {
255
- def.pattern ?? (def.pattern = regexes.duration);
256
- $ZodStringFormat.init(inst, def);
257
- });
258
- const $ZodIPv4 = /*@__PURE__*/ core.$constructor("$ZodIPv4", (inst, def) => {
259
- def.pattern ?? (def.pattern = regexes.ipv4);
260
- $ZodStringFormat.init(inst, def);
261
- inst._zod.onattach.push((inst) => {
262
- const bag = inst._zod.bag;
263
- bag.format = `ipv4`;
264
- });
265
- });
266
- const $ZodIPv6 = /*@__PURE__*/ core.$constructor("$ZodIPv6", (inst, def) => {
267
- def.pattern ?? (def.pattern = regexes.ipv6);
268
- $ZodStringFormat.init(inst, def);
269
- inst._zod.onattach.push((inst) => {
270
- const bag = inst._zod.bag;
271
- bag.format = `ipv6`;
272
- });
273
- inst._zod.check = (payload) => {
274
- try {
275
- new URL(`http://[${payload.value}]`);
276
- // return;
277
- }
278
- catch {
279
- payload.issues.push({
280
- code: "invalid_format",
281
- format: "ipv6",
282
- input: payload.value,
283
- inst,
284
- continue: !def.abort,
285
- });
286
- }
287
- };
288
- });
289
- const $ZodCIDRv4 = /*@__PURE__*/ core.$constructor("$ZodCIDRv4", (inst, def) => {
290
- def.pattern ?? (def.pattern = regexes.cidrv4);
291
- $ZodStringFormat.init(inst, def);
292
- });
293
- const $ZodCIDRv6 = /*@__PURE__*/ core.$constructor("$ZodCIDRv6", (inst, def) => {
294
- def.pattern ?? (def.pattern = regexes.cidrv6); // not used for validation
295
- $ZodStringFormat.init(inst, def);
296
- inst._zod.check = (payload) => {
297
- const [address, prefix] = payload.value.split("/");
298
- try {
299
- if (!prefix)
300
- throw new Error();
301
- const prefixNum = Number(prefix);
302
- if (`${prefixNum}` !== prefix)
303
- throw new Error();
304
- if (prefixNum < 0 || prefixNum > 128)
305
- throw new Error();
306
- new URL(`http://[${address}]`);
307
- }
308
- catch {
309
- payload.issues.push({
310
- code: "invalid_format",
311
- format: "cidrv6",
312
- input: payload.value,
313
- inst,
314
- continue: !def.abort,
315
- });
316
- }
317
- };
318
- });
319
- ////////////////////////////// ZodBase64 //////////////////////////////
320
- function isValidBase64(data) {
321
- if (data === "")
322
- return true;
323
- if (data.length % 4 !== 0)
324
- return false;
325
- try {
326
- atob(data);
327
- return true;
328
- }
329
- catch {
330
- return false;
331
- }
332
- }
333
- const $ZodBase64 = /*@__PURE__*/ core.$constructor("$ZodBase64", (inst, def) => {
334
- def.pattern ?? (def.pattern = regexes.base64);
335
- $ZodStringFormat.init(inst, def);
336
- inst._zod.onattach.push((inst) => {
337
- inst._zod.bag.contentEncoding = "base64";
338
- });
339
- inst._zod.check = (payload) => {
340
- if (isValidBase64(payload.value))
341
- return;
342
- payload.issues.push({
343
- code: "invalid_format",
344
- format: "base64",
345
- input: payload.value,
346
- inst,
347
- continue: !def.abort,
348
- });
349
- };
350
- });
351
- ////////////////////////////// ZodBase64 //////////////////////////////
352
- function isValidBase64URL(data) {
353
- if (!regexes.base64url.test(data))
354
- return false;
355
- const base64 = data.replace(/[-_]/g, (c) => (c === "-" ? "+" : "/"));
356
- const padded = base64.padEnd(Math.ceil(base64.length / 4) * 4, "=");
357
- return isValidBase64(padded);
358
- }
359
- const $ZodBase64URL = /*@__PURE__*/ core.$constructor("$ZodBase64URL", (inst, def) => {
360
- def.pattern ?? (def.pattern = regexes.base64url);
361
- $ZodStringFormat.init(inst, def);
362
- inst._zod.onattach.push((inst) => {
363
- inst._zod.bag.contentEncoding = "base64url";
364
- });
365
- inst._zod.check = (payload) => {
366
- if (isValidBase64URL(payload.value))
367
- return;
368
- payload.issues.push({
369
- code: "invalid_format",
370
- format: "base64url",
371
- input: payload.value,
372
- inst,
373
- continue: !def.abort,
374
- });
375
- };
376
- });
377
- const $ZodE164 = /*@__PURE__*/ core.$constructor("$ZodE164", (inst, def) => {
378
- def.pattern ?? (def.pattern = regexes.e164);
379
- $ZodStringFormat.init(inst, def);
380
- });
381
- ////////////////////////////// ZodJWT //////////////////////////////
382
- function isValidJWT(token, algorithm = null) {
383
- try {
384
- const tokensParts = token.split(".");
385
- if (tokensParts.length !== 3)
386
- return false;
387
- const [header] = tokensParts;
388
- if (!header)
389
- return false;
390
- const parsedHeader = JSON.parse(atob(header));
391
- if ("typ" in parsedHeader && parsedHeader?.typ !== "JWT")
392
- return false;
393
- if (!parsedHeader.alg)
394
- return false;
395
- if (algorithm && (!("alg" in parsedHeader) || parsedHeader.alg !== algorithm))
396
- return false;
397
- return true;
398
- }
399
- catch {
400
- return false;
401
- }
402
- }
403
- const $ZodJWT = /*@__PURE__*/ core.$constructor("$ZodJWT", (inst, def) => {
404
- $ZodStringFormat.init(inst, def);
405
- inst._zod.check = (payload) => {
406
- if (isValidJWT(payload.value, def.alg))
407
- return;
408
- payload.issues.push({
409
- code: "invalid_format",
410
- format: "jwt",
411
- input: payload.value,
412
- inst,
413
- continue: !def.abort,
414
- });
415
- };
416
- });
417
- const $ZodCustomStringFormat = /*@__PURE__*/ core.$constructor("$ZodCustomStringFormat", (inst, def) => {
418
- $ZodStringFormat.init(inst, def);
419
- inst._zod.check = (payload) => {
420
- if (def.fn(payload.value))
421
- return;
422
- payload.issues.push({
423
- code: "invalid_format",
424
- format: def.format,
425
- input: payload.value,
426
- inst,
427
- continue: !def.abort,
428
- });
429
- };
430
- });
431
- const $ZodNumber = /*@__PURE__*/ core.$constructor("$ZodNumber", (inst, def) => {
432
- $ZodType.init(inst, def);
433
- inst._zod.pattern = inst._zod.bag.pattern ?? regexes.number;
434
- inst._zod.parse = (payload, _ctx) => {
435
- if (def.coerce)
436
- try {
437
- payload.value = Number(payload.value);
438
- }
439
- catch (_) { }
440
- const input = payload.value;
441
- if (typeof input === "number" && !Number.isNaN(input) && Number.isFinite(input)) {
442
- return payload;
443
- }
444
- const received = typeof input === "number"
445
- ? Number.isNaN(input)
446
- ? "NaN"
447
- : !Number.isFinite(input)
448
- ? "Infinity"
449
- : undefined
450
- : undefined;
451
- payload.issues.push({
452
- expected: "number",
453
- code: "invalid_type",
454
- input,
455
- inst,
456
- ...(received ? { received } : {}),
457
- });
458
- return payload;
459
- };
460
- });
461
- const $ZodNumberFormat = /*@__PURE__*/ core.$constructor("$ZodNumber", (inst, def) => {
462
- checks.$ZodCheckNumberFormat.init(inst, def);
463
- $ZodNumber.init(inst, def); // no format checksp
464
- });
465
- const $ZodBoolean = /*@__PURE__*/ core.$constructor("$ZodBoolean", (inst, def) => {
466
- $ZodType.init(inst, def);
467
- inst._zod.pattern = regexes.boolean;
468
- inst._zod.parse = (payload, _ctx) => {
469
- if (def.coerce)
470
- try {
471
- payload.value = Boolean(payload.value);
472
- }
473
- catch (_) { }
474
- const input = payload.value;
475
- if (typeof input === "boolean")
476
- return payload;
477
- payload.issues.push({
478
- expected: "boolean",
479
- code: "invalid_type",
480
- input,
481
- inst,
482
- });
483
- return payload;
484
- };
485
- });
486
- const $ZodBigInt = /*@__PURE__*/ core.$constructor("$ZodBigInt", (inst, def) => {
487
- $ZodType.init(inst, def);
488
- inst._zod.pattern = regexes.bigint;
489
- inst._zod.parse = (payload, _ctx) => {
490
- if (def.coerce)
491
- try {
492
- payload.value = BigInt(payload.value);
493
- }
494
- catch (_) { }
495
- if (typeof payload.value === "bigint")
496
- return payload;
497
- payload.issues.push({
498
- expected: "bigint",
499
- code: "invalid_type",
500
- input: payload.value,
501
- inst,
502
- });
503
- return payload;
504
- };
505
- });
506
- const $ZodBigIntFormat = /*@__PURE__*/ core.$constructor("$ZodBigInt", (inst, def) => {
507
- checks.$ZodCheckBigIntFormat.init(inst, def);
508
- $ZodBigInt.init(inst, def); // no format checks
509
- });
510
- const $ZodSymbol = /*@__PURE__*/ core.$constructor("$ZodSymbol", (inst, def) => {
511
- $ZodType.init(inst, def);
512
- inst._zod.parse = (payload, _ctx) => {
513
- const input = payload.value;
514
- if (typeof input === "symbol")
515
- return payload;
516
- payload.issues.push({
517
- expected: "symbol",
518
- code: "invalid_type",
519
- input,
520
- inst,
521
- });
522
- return payload;
523
- };
524
- });
525
- const $ZodUndefined = /*@__PURE__*/ core.$constructor("$ZodUndefined", (inst, def) => {
526
- $ZodType.init(inst, def);
527
- inst._zod.pattern = regexes.undefined;
528
- inst._zod.values = new Set([undefined]);
529
- inst._zod.optin = "optional";
530
- inst._zod.optout = "optional";
531
- inst._zod.parse = (payload, _ctx) => {
532
- const input = payload.value;
533
- if (typeof input === "undefined")
534
- return payload;
535
- payload.issues.push({
536
- expected: "undefined",
537
- code: "invalid_type",
538
- input,
539
- inst,
540
- });
541
- return payload;
542
- };
543
- });
544
- const $ZodNull = /*@__PURE__*/ core.$constructor("$ZodNull", (inst, def) => {
545
- $ZodType.init(inst, def);
546
- inst._zod.pattern = regexes.null;
547
- inst._zod.values = new Set([null]);
548
- inst._zod.parse = (payload, _ctx) => {
549
- const input = payload.value;
550
- if (input === null)
551
- return payload;
552
- payload.issues.push({
553
- expected: "null",
554
- code: "invalid_type",
555
- input,
556
- inst,
557
- });
558
- return payload;
559
- };
560
- });
561
- const $ZodAny = /*@__PURE__*/ core.$constructor("$ZodAny", (inst, def) => {
562
- $ZodType.init(inst, def);
563
- inst._zod.parse = (payload) => payload;
564
- });
565
- const $ZodUnknown = /*@__PURE__*/ core.$constructor("$ZodUnknown", (inst, def) => {
566
- $ZodType.init(inst, def);
567
- inst._zod.parse = (payload) => payload;
568
- });
569
- const $ZodNever = /*@__PURE__*/ core.$constructor("$ZodNever", (inst, def) => {
570
- $ZodType.init(inst, def);
571
- inst._zod.parse = (payload, _ctx) => {
572
- payload.issues.push({
573
- expected: "never",
574
- code: "invalid_type",
575
- input: payload.value,
576
- inst,
577
- });
578
- return payload;
579
- };
580
- });
581
- const $ZodVoid = /*@__PURE__*/ core.$constructor("$ZodVoid", (inst, def) => {
582
- $ZodType.init(inst, def);
583
- inst._zod.parse = (payload, _ctx) => {
584
- const input = payload.value;
585
- if (typeof input === "undefined")
586
- return payload;
587
- payload.issues.push({
588
- expected: "void",
589
- code: "invalid_type",
590
- input,
591
- inst,
592
- });
593
- return payload;
594
- };
595
- });
596
- const $ZodDate = /*@__PURE__*/ core.$constructor("$ZodDate", (inst, def) => {
597
- $ZodType.init(inst, def);
598
- inst._zod.parse = (payload, _ctx) => {
599
- if (def.coerce) {
600
- try {
601
- payload.value = new Date(payload.value);
602
- }
603
- catch (_err) { }
604
- }
605
- const input = payload.value;
606
- const isDate = input instanceof Date;
607
- const isValidDate = isDate && !Number.isNaN(input.getTime());
608
- if (isValidDate)
609
- return payload;
610
- payload.issues.push({
611
- expected: "date",
612
- code: "invalid_type",
613
- input,
614
- ...(isDate ? { received: "Invalid Date" } : {}),
615
- inst,
616
- });
617
- return payload;
618
- };
619
- });
620
- function handleArrayResult(result, final, index) {
621
- if (result.issues.length) {
622
- final.issues.push(...util.prefixIssues(index, result.issues));
623
- }
624
- final.value[index] = result.value;
625
- }
626
- const $ZodArray = /*@__PURE__*/ core.$constructor("$ZodArray", (inst, def) => {
627
- $ZodType.init(inst, def);
628
- inst._zod.parse = (payload, ctx) => {
629
- const input = payload.value;
630
- if (!Array.isArray(input)) {
631
- payload.issues.push({
632
- expected: "array",
633
- code: "invalid_type",
634
- input,
635
- inst,
636
- });
637
- return payload;
638
- }
639
- payload.value = Array(input.length);
640
- const proms = [];
641
- for (let i = 0; i < input.length; i++) {
642
- const item = input[i];
643
- const result = def.element._zod.run({
644
- value: item,
645
- issues: [],
646
- }, ctx);
647
- if (result instanceof Promise) {
648
- proms.push(result.then((result) => handleArrayResult(result, payload, i)));
649
- }
650
- else {
651
- handleArrayResult(result, payload, i);
652
- }
653
- }
654
- if (proms.length) {
655
- return Promise.all(proms).then(() => payload);
656
- }
657
- return payload; //handleArrayResultsAsync(parseResults, final);
658
- };
659
- });
660
- function handleObjectResult(result, final, key) {
661
- // if(isOptional)
662
- if (result.issues.length) {
663
- final.issues.push(...util.prefixIssues(key, result.issues));
664
- }
665
- final.value[key] = result.value;
666
- }
667
- function handleOptionalObjectResult(result, final, key, input) {
668
- if (result.issues.length) {
669
- // validation failed against value schema
670
- if (input[key] === undefined) {
671
- // if input was undefined, ignore the error
672
- if (key in input) {
673
- final.value[key] = undefined;
674
- }
675
- else {
676
- final.value[key] = result.value;
677
- }
678
- }
679
- else {
680
- final.issues.push(...util.prefixIssues(key, result.issues));
681
- }
682
- }
683
- else if (result.value === undefined) {
684
- // validation returned `undefined`
685
- if (key in input)
686
- final.value[key] = undefined;
687
- }
688
- else {
689
- // non-undefined value
690
- final.value[key] = result.value;
691
- }
692
- }
693
- const $ZodObject = /*@__PURE__*/ core.$constructor("$ZodObject", (inst, def) => {
694
- // requires cast because technically $ZodObject doesn't extend
695
- $ZodType.init(inst, def);
696
- const _normalized = util.cached(() => {
697
- const keys = Object.keys(def.shape);
698
- for (const k of keys) {
699
- if (!(def.shape[k] instanceof $ZodType)) {
700
- throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
701
- }
702
- }
703
- const okeys = util.optionalKeys(def.shape);
704
- return {
705
- shape: def.shape,
706
- keys,
707
- keySet: new Set(keys),
708
- numKeys: keys.length,
709
- optionalKeys: new Set(okeys),
710
- };
711
- });
712
- util.defineLazy(inst._zod, "propValues", () => {
713
- const shape = def.shape;
714
- const propValues = {};
715
- for (const key in shape) {
716
- const field = shape[key]._zod;
717
- if (field.values) {
718
- propValues[key] ?? (propValues[key] = new Set());
719
- for (const v of field.values)
720
- propValues[key].add(v);
721
- }
722
- }
723
- return propValues;
724
- });
725
- const generateFastpass = (shape) => {
726
- const doc$1 = new doc.Doc(["shape", "payload", "ctx"]);
727
- const normalized = _normalized.value;
728
- const parseStr = (key) => {
729
- const k = util.esc(key);
730
- return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
731
- };
732
- doc$1.write(`const input = payload.value;`);
733
- const ids = Object.create(null);
734
- let counter = 0;
735
- for (const key of normalized.keys) {
736
- ids[key] = `key_${counter++}`;
737
- }
738
- // A: preserve key order {
739
- doc$1.write(`const newResult = {}`);
740
- for (const key of normalized.keys) {
741
- if (normalized.optionalKeys.has(key)) {
742
- const id = ids[key];
743
- doc$1.write(`const ${id} = ${parseStr(key)};`);
744
- const k = util.esc(key);
745
- doc$1.write(`
746
- if (${id}.issues.length) {
747
- if (input[${k}] === undefined) {
748
- if (${k} in input) {
749
- newResult[${k}] = undefined;
750
- }
751
- } else {
752
- payload.issues = payload.issues.concat(
753
- ${id}.issues.map((iss) => ({
754
- ...iss,
755
- path: iss.path ? [${k}, ...iss.path] : [${k}],
756
- }))
757
- );
758
- }
759
- } else if (${id}.value === undefined) {
760
- if (${k} in input) newResult[${k}] = undefined;
761
- } else {
762
- newResult[${k}] = ${id}.value;
763
- }
764
- `);
765
- }
766
- else {
767
- const id = ids[key];
768
- // const id = ids[key];
769
- doc$1.write(`const ${id} = ${parseStr(key)};`);
770
- doc$1.write(`
771
- if (${id}.issues.length) payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
772
- ...iss,
773
- path: iss.path ? [${util.esc(key)}, ...iss.path] : [${util.esc(key)}]
774
- })));`);
775
- doc$1.write(`newResult[${util.esc(key)}] = ${id}.value`);
776
- }
777
- }
778
- doc$1.write(`payload.value = newResult;`);
779
- doc$1.write(`return payload;`);
780
- const fn = doc$1.compile();
781
- return (payload, ctx) => fn(shape, payload, ctx);
782
- };
783
- let fastpass;
784
- const isObject = util.isObject;
785
- const jit = !core.globalConfig.jitless;
786
- const allowsEval = util.allowsEval;
787
- const fastEnabled = jit && allowsEval.value; // && !def.catchall;
788
- const catchall = def.catchall;
789
- let value;
790
- inst._zod.parse = (payload, ctx) => {
791
- value ?? (value = _normalized.value);
792
- const input = payload.value;
793
- if (!isObject(input)) {
794
- payload.issues.push({
795
- expected: "object",
796
- code: "invalid_type",
797
- input,
798
- inst,
799
- });
800
- return payload;
801
- }
802
- const proms = [];
803
- if (jit && fastEnabled && ctx?.async === false && ctx.jitless !== true) {
804
- // always synchronous
805
- if (!fastpass)
806
- fastpass = generateFastpass(def.shape);
807
- payload = fastpass(payload, ctx);
808
- }
809
- else {
810
- payload.value = {};
811
- const shape = value.shape;
812
- for (const key of value.keys) {
813
- const el = shape[key];
814
- // do not add omitted optional keys
815
- // if (!(key in input)) {
816
- // if (optionalKeys.has(key)) continue;
817
- // payload.issues.push({
818
- // code: "invalid_type",
819
- // path: [key],
820
- // expected: "nonoptional",
821
- // note: `Missing required key: "${key}"`,
822
- // input,
823
- // inst,
824
- // });
825
- // }
826
- const r = el._zod.run({ value: input[key], issues: [] }, ctx);
827
- const isOptional = el._zod.optin === "optional" && el._zod.optout === "optional";
828
- if (r instanceof Promise) {
829
- proms.push(r.then((r) => isOptional ? handleOptionalObjectResult(r, payload, key, input) : handleObjectResult(r, payload, key)));
830
- }
831
- else if (isOptional) {
832
- handleOptionalObjectResult(r, payload, key, input);
833
- }
834
- else {
835
- handleObjectResult(r, payload, key);
836
- }
837
- }
838
- }
839
- if (!catchall) {
840
- // return payload;
841
- return proms.length ? Promise.all(proms).then(() => payload) : payload;
842
- }
843
- const unrecognized = [];
844
- // iterate over input keys
845
- const keySet = value.keySet;
846
- const _catchall = catchall._zod;
847
- const t = _catchall.def.type;
848
- for (const key of Object.keys(input)) {
849
- if (keySet.has(key))
850
- continue;
851
- if (t === "never") {
852
- unrecognized.push(key);
853
- continue;
854
- }
855
- const r = _catchall.run({ value: input[key], issues: [] }, ctx);
856
- if (r instanceof Promise) {
857
- proms.push(r.then((r) => handleObjectResult(r, payload, key)));
858
- }
859
- else {
860
- handleObjectResult(r, payload, key);
861
- }
862
- }
863
- if (unrecognized.length) {
864
- payload.issues.push({
865
- code: "unrecognized_keys",
866
- keys: unrecognized,
867
- input,
868
- inst,
869
- });
870
- }
871
- if (!proms.length)
872
- return payload;
873
- return Promise.all(proms).then(() => {
874
- return payload;
875
- });
876
- };
877
- });
878
- function handleUnionResults(results, final, inst, ctx) {
879
- for (const result of results) {
880
- if (result.issues.length === 0) {
881
- final.value = result.value;
882
- return final;
883
- }
884
- }
885
- final.issues.push({
886
- code: "invalid_union",
887
- input: final.value,
888
- inst,
889
- errors: results.map((result) => result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config()))),
890
- });
891
- return final;
892
- }
893
- const $ZodUnion = /*@__PURE__*/ core.$constructor("$ZodUnion", (inst, def) => {
894
- $ZodType.init(inst, def);
895
- util.defineLazy(inst._zod, "optin", () => def.options.some((o) => o._zod.optin === "optional") ? "optional" : undefined);
896
- util.defineLazy(inst._zod, "optout", () => def.options.some((o) => o._zod.optout === "optional") ? "optional" : undefined);
897
- util.defineLazy(inst._zod, "values", () => {
898
- if (def.options.every((o) => o._zod.values)) {
899
- return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
900
- }
901
- return undefined;
902
- });
903
- util.defineLazy(inst._zod, "pattern", () => {
904
- if (def.options.every((o) => o._zod.pattern)) {
905
- const patterns = def.options.map((o) => o._zod.pattern);
906
- return new RegExp(`^(${patterns.map((p) => util.cleanRegex(p.source)).join("|")})$`);
907
- }
908
- return undefined;
909
- });
910
- inst._zod.parse = (payload, ctx) => {
911
- let async = false;
912
- const results = [];
913
- for (const option of def.options) {
914
- const result = option._zod.run({
915
- value: payload.value,
916
- issues: [],
917
- }, ctx);
918
- if (result instanceof Promise) {
919
- results.push(result);
920
- async = true;
921
- }
922
- else {
923
- if (result.issues.length === 0)
924
- return result;
925
- results.push(result);
926
- }
927
- }
928
- if (!async)
929
- return handleUnionResults(results, payload, inst, ctx);
930
- return Promise.all(results).then((results) => {
931
- return handleUnionResults(results, payload, inst, ctx);
932
- });
933
- };
934
- });
935
- const $ZodDiscriminatedUnion =
936
- /*@__PURE__*/
937
- core.$constructor("$ZodDiscriminatedUnion", (inst, def) => {
938
- $ZodUnion.init(inst, def);
939
- const _super = inst._zod.parse;
940
- util.defineLazy(inst._zod, "propValues", () => {
941
- const propValues = {};
942
- for (const option of def.options) {
943
- const pv = option._zod.propValues;
944
- if (!pv || Object.keys(pv).length === 0)
945
- throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
946
- for (const [k, v] of Object.entries(pv)) {
947
- if (!propValues[k])
948
- propValues[k] = new Set();
949
- for (const val of v) {
950
- propValues[k].add(val);
951
- }
952
- }
953
- }
954
- return propValues;
955
- });
956
- const disc = util.cached(() => {
957
- const opts = def.options;
958
- const map = new Map();
959
- for (const o of opts) {
960
- const values = o._zod.propValues[def.discriminator];
961
- if (!values || values.size === 0)
962
- throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
963
- for (const v of values) {
964
- if (map.has(v)) {
965
- throw new Error(`Duplicate discriminator value "${String(v)}"`);
966
- }
967
- map.set(v, o);
968
- }
969
- }
970
- return map;
971
- });
972
- inst._zod.parse = (payload, ctx) => {
973
- const input = payload.value;
974
- if (!util.isObject(input)) {
975
- payload.issues.push({
976
- code: "invalid_type",
977
- expected: "object",
978
- input,
979
- inst,
980
- });
981
- return payload;
982
- }
983
- const opt = disc.value.get(input?.[def.discriminator]);
984
- if (opt) {
985
- return opt._zod.run(payload, ctx);
986
- }
987
- if (def.unionFallback) {
988
- return _super(payload, ctx);
989
- }
990
- // no matching discriminator
991
- payload.issues.push({
992
- code: "invalid_union",
993
- errors: [],
994
- note: "No matching discriminator",
995
- input,
996
- path: [def.discriminator],
997
- inst,
998
- });
999
- return payload;
1000
- };
1001
- });
1002
- const $ZodIntersection = /*@__PURE__*/ core.$constructor("$ZodIntersection", (inst, def) => {
1003
- $ZodType.init(inst, def);
1004
- inst._zod.parse = (payload, ctx) => {
1005
- const input = payload.value;
1006
- const left = def.left._zod.run({ value: input, issues: [] }, ctx);
1007
- const right = def.right._zod.run({ value: input, issues: [] }, ctx);
1008
- const async = left instanceof Promise || right instanceof Promise;
1009
- if (async) {
1010
- return Promise.all([left, right]).then(([left, right]) => {
1011
- return handleIntersectionResults(payload, left, right);
1012
- });
1013
- }
1014
- return handleIntersectionResults(payload, left, right);
1015
- };
1016
- });
1017
- function mergeValues(a, b) {
1018
- // const aType = parse.t(a);
1019
- // const bType = parse.t(b);
1020
- if (a === b) {
1021
- return { valid: true, data: a };
1022
- }
1023
- if (a instanceof Date && b instanceof Date && +a === +b) {
1024
- return { valid: true, data: a };
1025
- }
1026
- if (util.isPlainObject(a) && util.isPlainObject(b)) {
1027
- const bKeys = Object.keys(b);
1028
- const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
1029
- const newObj = { ...a, ...b };
1030
- for (const key of sharedKeys) {
1031
- const sharedValue = mergeValues(a[key], b[key]);
1032
- if (!sharedValue.valid) {
1033
- return {
1034
- valid: false,
1035
- mergeErrorPath: [key, ...sharedValue.mergeErrorPath],
1036
- };
1037
- }
1038
- newObj[key] = sharedValue.data;
1039
- }
1040
- return { valid: true, data: newObj };
1041
- }
1042
- if (Array.isArray(a) && Array.isArray(b)) {
1043
- if (a.length !== b.length) {
1044
- return { valid: false, mergeErrorPath: [] };
1045
- }
1046
- const newArray = [];
1047
- for (let index = 0; index < a.length; index++) {
1048
- const itemA = a[index];
1049
- const itemB = b[index];
1050
- const sharedValue = mergeValues(itemA, itemB);
1051
- if (!sharedValue.valid) {
1052
- return {
1053
- valid: false,
1054
- mergeErrorPath: [index, ...sharedValue.mergeErrorPath],
1055
- };
1056
- }
1057
- newArray.push(sharedValue.data);
1058
- }
1059
- return { valid: true, data: newArray };
1060
- }
1061
- return { valid: false, mergeErrorPath: [] };
1062
- }
1063
- function handleIntersectionResults(result, left, right) {
1064
- if (left.issues.length) {
1065
- result.issues.push(...left.issues);
1066
- }
1067
- if (right.issues.length) {
1068
- result.issues.push(...right.issues);
1069
- }
1070
- if (util.aborted(result))
1071
- return result;
1072
- const merged = mergeValues(left.value, right.value);
1073
- if (!merged.valid) {
1074
- throw new Error(`Unmergable intersection. Error path: ` + `${JSON.stringify(merged.mergeErrorPath)}`);
1075
- }
1076
- result.value = merged.data;
1077
- return result;
1078
- }
1079
- const $ZodTuple = /*@__PURE__*/ core.$constructor("$ZodTuple", (inst, def) => {
1080
- $ZodType.init(inst, def);
1081
- const items = def.items;
1082
- const optStart = items.length - [...items].reverse().findIndex((item) => item._zod.optin !== "optional");
1083
- inst._zod.parse = (payload, ctx) => {
1084
- const input = payload.value;
1085
- if (!Array.isArray(input)) {
1086
- payload.issues.push({
1087
- input,
1088
- inst,
1089
- expected: "tuple",
1090
- code: "invalid_type",
1091
- });
1092
- return payload;
1093
- }
1094
- payload.value = [];
1095
- const proms = [];
1096
- if (!def.rest) {
1097
- const tooBig = input.length > items.length;
1098
- const tooSmall = input.length < optStart - 1;
1099
- if (tooBig || tooSmall) {
1100
- payload.issues.push({
1101
- input,
1102
- inst,
1103
- origin: "array",
1104
- ...(tooBig ? { code: "too_big", maximum: items.length } : { code: "too_small", minimum: items.length }),
1105
- });
1106
- return payload;
1107
- }
1108
- }
1109
- let i = -1;
1110
- for (const item of items) {
1111
- i++;
1112
- if (i >= input.length)
1113
- if (i >= optStart)
1114
- continue;
1115
- const result = item._zod.run({
1116
- value: input[i],
1117
- issues: [],
1118
- }, ctx);
1119
- if (result instanceof Promise) {
1120
- proms.push(result.then((result) => handleTupleResult(result, payload, i)));
1121
- }
1122
- else {
1123
- handleTupleResult(result, payload, i);
1124
- }
1125
- }
1126
- if (def.rest) {
1127
- const rest = input.slice(items.length);
1128
- for (const el of rest) {
1129
- i++;
1130
- const result = def.rest._zod.run({
1131
- value: el,
1132
- issues: [],
1133
- }, ctx);
1134
- if (result instanceof Promise) {
1135
- proms.push(result.then((result) => handleTupleResult(result, payload, i)));
1136
- }
1137
- else {
1138
- handleTupleResult(result, payload, i);
1139
- }
1140
- }
1141
- }
1142
- if (proms.length)
1143
- return Promise.all(proms).then(() => payload);
1144
- return payload;
1145
- };
1146
- });
1147
- function handleTupleResult(result, final, index) {
1148
- if (result.issues.length) {
1149
- final.issues.push(...util.prefixIssues(index, result.issues));
1150
- }
1151
- final.value[index] = result.value;
1152
- }
1153
- const $ZodRecord = /*@__PURE__*/ core.$constructor("$ZodRecord", (inst, def) => {
1154
- $ZodType.init(inst, def);
1155
- inst._zod.parse = (payload, ctx) => {
1156
- const input = payload.value;
1157
- if (!util.isPlainObject(input)) {
1158
- payload.issues.push({
1159
- expected: "record",
1160
- code: "invalid_type",
1161
- input,
1162
- inst,
1163
- });
1164
- return payload;
1165
- }
1166
- const proms = [];
1167
- if (def.keyType._zod.values) {
1168
- const values = def.keyType._zod.values;
1169
- payload.value = {};
1170
- for (const key of values) {
1171
- if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
1172
- const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
1173
- if (result instanceof Promise) {
1174
- proms.push(result.then((result) => {
1175
- if (result.issues.length) {
1176
- payload.issues.push(...util.prefixIssues(key, result.issues));
1177
- }
1178
- payload.value[key] = result.value;
1179
- }));
1180
- }
1181
- else {
1182
- if (result.issues.length) {
1183
- payload.issues.push(...util.prefixIssues(key, result.issues));
1184
- }
1185
- payload.value[key] = result.value;
1186
- }
1187
- }
1188
- }
1189
- let unrecognized;
1190
- for (const key in input) {
1191
- if (!values.has(key)) {
1192
- unrecognized = unrecognized ?? [];
1193
- unrecognized.push(key);
1194
- }
1195
- }
1196
- if (unrecognized && unrecognized.length > 0) {
1197
- payload.issues.push({
1198
- code: "unrecognized_keys",
1199
- input,
1200
- inst,
1201
- keys: unrecognized,
1202
- });
1203
- }
1204
- }
1205
- else {
1206
- payload.value = {};
1207
- for (const key of Reflect.ownKeys(input)) {
1208
- if (key === "__proto__")
1209
- continue;
1210
- const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
1211
- if (keyResult instanceof Promise) {
1212
- throw new Error("Async schemas not supported in object keys currently");
1213
- }
1214
- if (keyResult.issues.length) {
1215
- payload.issues.push({
1216
- origin: "record",
1217
- code: "invalid_key",
1218
- issues: keyResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
1219
- input: key,
1220
- path: [key],
1221
- inst,
1222
- });
1223
- payload.value[keyResult.value] = keyResult.value;
1224
- continue;
1225
- }
1226
- const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
1227
- if (result instanceof Promise) {
1228
- proms.push(result.then((result) => {
1229
- if (result.issues.length) {
1230
- payload.issues.push(...util.prefixIssues(key, result.issues));
1231
- }
1232
- payload.value[keyResult.value] = result.value;
1233
- }));
1234
- }
1235
- else {
1236
- if (result.issues.length) {
1237
- payload.issues.push(...util.prefixIssues(key, result.issues));
1238
- }
1239
- payload.value[keyResult.value] = result.value;
1240
- }
1241
- }
1242
- }
1243
- if (proms.length) {
1244
- return Promise.all(proms).then(() => payload);
1245
- }
1246
- return payload;
1247
- };
1248
- });
1249
- const $ZodMap = /*@__PURE__*/ core.$constructor("$ZodMap", (inst, def) => {
1250
- $ZodType.init(inst, def);
1251
- inst._zod.parse = (payload, ctx) => {
1252
- const input = payload.value;
1253
- if (!(input instanceof Map)) {
1254
- payload.issues.push({
1255
- expected: "map",
1256
- code: "invalid_type",
1257
- input,
1258
- inst,
1259
- });
1260
- return payload;
1261
- }
1262
- const proms = [];
1263
- payload.value = new Map();
1264
- for (const [key, value] of input) {
1265
- const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
1266
- const valueResult = def.valueType._zod.run({ value: value, issues: [] }, ctx);
1267
- if (keyResult instanceof Promise || valueResult instanceof Promise) {
1268
- proms.push(Promise.all([keyResult, valueResult]).then(([keyResult, valueResult]) => {
1269
- handleMapResult(keyResult, valueResult, payload, key, input, inst, ctx);
1270
- }));
1271
- }
1272
- else {
1273
- handleMapResult(keyResult, valueResult, payload, key, input, inst, ctx);
1274
- }
1275
- }
1276
- if (proms.length)
1277
- return Promise.all(proms).then(() => payload);
1278
- return payload;
1279
- };
1280
- });
1281
- function handleMapResult(keyResult, valueResult, final, key, input, inst, ctx) {
1282
- if (keyResult.issues.length) {
1283
- if (util.propertyKeyTypes.has(typeof key)) {
1284
- final.issues.push(...util.prefixIssues(key, keyResult.issues));
1285
- }
1286
- else {
1287
- final.issues.push({
1288
- origin: "map",
1289
- code: "invalid_key",
1290
- input,
1291
- inst,
1292
- issues: keyResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
1293
- });
1294
- }
1295
- }
1296
- if (valueResult.issues.length) {
1297
- if (util.propertyKeyTypes.has(typeof key)) {
1298
- final.issues.push(...util.prefixIssues(key, valueResult.issues));
1299
- }
1300
- else {
1301
- final.issues.push({
1302
- origin: "map",
1303
- code: "invalid_element",
1304
- input,
1305
- inst,
1306
- key: key,
1307
- issues: valueResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
1308
- });
1309
- }
1310
- }
1311
- final.value.set(keyResult.value, valueResult.value);
1312
- }
1313
- const $ZodSet = /*@__PURE__*/ core.$constructor("$ZodSet", (inst, def) => {
1314
- $ZodType.init(inst, def);
1315
- inst._zod.parse = (payload, ctx) => {
1316
- const input = payload.value;
1317
- if (!(input instanceof Set)) {
1318
- payload.issues.push({
1319
- input,
1320
- inst,
1321
- expected: "set",
1322
- code: "invalid_type",
1323
- });
1324
- return payload;
1325
- }
1326
- const proms = [];
1327
- payload.value = new Set();
1328
- for (const item of input) {
1329
- const result = def.valueType._zod.run({ value: item, issues: [] }, ctx);
1330
- if (result instanceof Promise) {
1331
- proms.push(result.then((result) => handleSetResult(result, payload)));
1332
- }
1333
- else
1334
- handleSetResult(result, payload);
1335
- }
1336
- if (proms.length)
1337
- return Promise.all(proms).then(() => payload);
1338
- return payload;
1339
- };
1340
- });
1341
- function handleSetResult(result, final) {
1342
- if (result.issues.length) {
1343
- final.issues.push(...result.issues);
1344
- }
1345
- final.value.add(result.value);
1346
- }
1347
- const $ZodEnum = /*@__PURE__*/ core.$constructor("$ZodEnum", (inst, def) => {
1348
- $ZodType.init(inst, def);
1349
- const values = util.getEnumValues(def.entries);
1350
- inst._zod.values = new Set(values);
1351
- inst._zod.pattern = new RegExp(`^(${values
1352
- .filter((k) => util.propertyKeyTypes.has(typeof k))
1353
- .map((o) => (typeof o === "string" ? util.escapeRegex(o) : o.toString()))
1354
- .join("|")})$`);
1355
- inst._zod.parse = (payload, _ctx) => {
1356
- const input = payload.value;
1357
- if (inst._zod.values.has(input)) {
1358
- return payload;
1359
- }
1360
- payload.issues.push({
1361
- code: "invalid_value",
1362
- values,
1363
- input,
1364
- inst,
1365
- });
1366
- return payload;
1367
- };
1368
- });
1369
- const $ZodLiteral = /*@__PURE__*/ core.$constructor("$ZodLiteral", (inst, def) => {
1370
- $ZodType.init(inst, def);
1371
- inst._zod.values = new Set(def.values);
1372
- inst._zod.pattern = new RegExp(`^(${def.values
1373
- .map((o) => (typeof o === "string" ? util.escapeRegex(o) : o ? o.toString() : String(o)))
1374
- .join("|")})$`);
1375
- inst._zod.parse = (payload, _ctx) => {
1376
- const input = payload.value;
1377
- if (inst._zod.values.has(input)) {
1378
- return payload;
1379
- }
1380
- payload.issues.push({
1381
- code: "invalid_value",
1382
- values: def.values,
1383
- input,
1384
- inst,
1385
- });
1386
- return payload;
1387
- };
1388
- });
1389
- const $ZodFile = /*@__PURE__*/ core.$constructor("$ZodFile", (inst, def) => {
1390
- $ZodType.init(inst, def);
1391
- inst._zod.parse = (payload, _ctx) => {
1392
- const input = payload.value;
1393
- if (input instanceof File)
1394
- return payload;
1395
- payload.issues.push({
1396
- expected: "file",
1397
- code: "invalid_type",
1398
- input,
1399
- inst,
1400
- });
1401
- return payload;
1402
- };
1403
- });
1404
- const $ZodTransform = /*@__PURE__*/ core.$constructor("$ZodTransform", (inst, def) => {
1405
- $ZodType.init(inst, def);
1406
- inst._zod.parse = (payload, _ctx) => {
1407
- const _out = def.transform(payload.value, payload);
1408
- if (_ctx.async) {
1409
- const output = _out instanceof Promise ? _out : Promise.resolve(_out);
1410
- return output.then((output) => {
1411
- payload.value = output;
1412
- return payload;
1413
- });
1414
- }
1415
- if (_out instanceof Promise) {
1416
- throw new core.$ZodAsyncError();
1417
- }
1418
- payload.value = _out;
1419
- return payload;
1420
- };
1421
- });
1422
- const $ZodOptional = /*@__PURE__*/ core.$constructor("$ZodOptional", (inst, def) => {
1423
- $ZodType.init(inst, def);
1424
- inst._zod.optin = "optional";
1425
- inst._zod.optout = "optional";
1426
- util.defineLazy(inst._zod, "values", () => {
1427
- return def.innerType._zod.values ? new Set([...def.innerType._zod.values, undefined]) : undefined;
1428
- });
1429
- util.defineLazy(inst._zod, "pattern", () => {
1430
- const pattern = def.innerType._zod.pattern;
1431
- return pattern ? new RegExp(`^(${util.cleanRegex(pattern.source)})?$`) : undefined;
1432
- });
1433
- inst._zod.parse = (payload, ctx) => {
1434
- if (def.innerType._zod.optin === "optional") {
1435
- return def.innerType._zod.run(payload, ctx);
1436
- }
1437
- if (payload.value === undefined) {
1438
- return payload;
1439
- }
1440
- return def.innerType._zod.run(payload, ctx);
1441
- };
1442
- });
1443
- const $ZodNullable = /*@__PURE__*/ core.$constructor("$ZodNullable", (inst, def) => {
1444
- $ZodType.init(inst, def);
1445
- util.defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
1446
- util.defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
1447
- util.defineLazy(inst._zod, "pattern", () => {
1448
- const pattern = def.innerType._zod.pattern;
1449
- return pattern ? new RegExp(`^(${util.cleanRegex(pattern.source)}|null)$`) : undefined;
1450
- });
1451
- util.defineLazy(inst._zod, "values", () => {
1452
- return def.innerType._zod.values ? new Set([...def.innerType._zod.values, null]) : undefined;
1453
- });
1454
- inst._zod.parse = (payload, ctx) => {
1455
- if (payload.value === null)
1456
- return payload;
1457
- return def.innerType._zod.run(payload, ctx);
1458
- };
1459
- });
1460
- const $ZodDefault = /*@__PURE__*/ core.$constructor("$ZodDefault", (inst, def) => {
1461
- $ZodType.init(inst, def);
1462
- // inst._zod.qin = "true";
1463
- inst._zod.optin = "optional";
1464
- util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
1465
- inst._zod.parse = (payload, ctx) => {
1466
- if (payload.value === undefined) {
1467
- payload.value = def.defaultValue;
1468
- /**
1469
- * $ZodDefault always returns the default value immediately.
1470
- * It doesn't pass the default value into the validator ("prefault"). There's no reason to pass the default value through validation. The validity of the default is enforced by TypeScript statically. Otherwise, it's the responsibility of the user to ensure the default is valid. In the case of pipes with divergent in/out types, you can specify the default on the `in` schema of your ZodPipe to set a "prefault" for the pipe. */
1471
- return payload;
1472
- }
1473
- const result = def.innerType._zod.run(payload, ctx);
1474
- if (result instanceof Promise) {
1475
- return result.then((result) => handleDefaultResult(result, def));
1476
- }
1477
- return handleDefaultResult(result, def);
1478
- };
1479
- });
1480
- function handleDefaultResult(payload, def) {
1481
- if (payload.value === undefined) {
1482
- payload.value = def.defaultValue;
1483
- }
1484
- return payload;
1485
- }
1486
- const $ZodPrefault = /*@__PURE__*/ core.$constructor("$ZodPrefault", (inst, def) => {
1487
- $ZodType.init(inst, def);
1488
- inst._zod.optin = "optional";
1489
- util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
1490
- inst._zod.parse = (payload, ctx) => {
1491
- if (payload.value === undefined) {
1492
- payload.value = def.defaultValue;
1493
- }
1494
- return def.innerType._zod.run(payload, ctx);
1495
- };
1496
- });
1497
- const $ZodNonOptional = /*@__PURE__*/ core.$constructor("$ZodNonOptional", (inst, def) => {
1498
- $ZodType.init(inst, def);
1499
- util.defineLazy(inst._zod, "values", () => {
1500
- const v = def.innerType._zod.values;
1501
- return v ? new Set([...v].filter((x) => x !== undefined)) : undefined;
1502
- });
1503
- inst._zod.parse = (payload, ctx) => {
1504
- const result = def.innerType._zod.run(payload, ctx);
1505
- if (result instanceof Promise) {
1506
- return result.then((result) => handleNonOptionalResult(result, inst));
1507
- }
1508
- return handleNonOptionalResult(result, inst);
1509
- };
1510
- });
1511
- function handleNonOptionalResult(payload, inst) {
1512
- if (!payload.issues.length && payload.value === undefined) {
1513
- payload.issues.push({
1514
- code: "invalid_type",
1515
- expected: "nonoptional",
1516
- input: payload.value,
1517
- inst,
1518
- });
1519
- }
1520
- return payload;
1521
- }
1522
- const $ZodSuccess = /*@__PURE__*/ core.$constructor("$ZodSuccess", (inst, def) => {
1523
- $ZodType.init(inst, def);
1524
- inst._zod.parse = (payload, ctx) => {
1525
- const result = def.innerType._zod.run(payload, ctx);
1526
- if (result instanceof Promise) {
1527
- return result.then((result) => {
1528
- payload.value = result.issues.length === 0;
1529
- return payload;
1530
- });
1531
- }
1532
- payload.value = result.issues.length === 0;
1533
- return payload;
1534
- };
1535
- });
1536
- const $ZodCatch = /*@__PURE__*/ core.$constructor("$ZodCatch", (inst, def) => {
1537
- $ZodType.init(inst, def);
1538
- inst._zod.optin = "optional";
1539
- util.defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
1540
- util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
1541
- inst._zod.parse = (payload, ctx) => {
1542
- const result = def.innerType._zod.run(payload, ctx);
1543
- if (result instanceof Promise) {
1544
- return result.then((result) => {
1545
- payload.value = result.value;
1546
- if (result.issues.length) {
1547
- payload.value = def.catchValue({
1548
- ...payload,
1549
- error: {
1550
- issues: result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
1551
- },
1552
- input: payload.value,
1553
- });
1554
- payload.issues = [];
1555
- }
1556
- return payload;
1557
- });
1558
- }
1559
- payload.value = result.value;
1560
- if (result.issues.length) {
1561
- payload.value = def.catchValue({
1562
- ...payload,
1563
- error: {
1564
- issues: result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
1565
- },
1566
- input: payload.value,
1567
- });
1568
- payload.issues = [];
1569
- }
1570
- return payload;
1571
- };
1572
- });
1573
- const $ZodNaN = /*@__PURE__*/ core.$constructor("$ZodNaN", (inst, def) => {
1574
- $ZodType.init(inst, def);
1575
- inst._zod.parse = (payload, _ctx) => {
1576
- if (typeof payload.value !== "number" || !Number.isNaN(payload.value)) {
1577
- payload.issues.push({
1578
- input: payload.value,
1579
- inst,
1580
- expected: "nan",
1581
- code: "invalid_type",
1582
- });
1583
- return payload;
1584
- }
1585
- return payload;
1586
- };
1587
- });
1588
- const $ZodPipe = /*@__PURE__*/ core.$constructor("$ZodPipe", (inst, def) => {
1589
- $ZodType.init(inst, def);
1590
- util.defineLazy(inst._zod, "values", () => def.in._zod.values);
1591
- util.defineLazy(inst._zod, "optin", () => def.in._zod.optin);
1592
- util.defineLazy(inst._zod, "optout", () => def.out._zod.optout);
1593
- inst._zod.parse = (payload, ctx) => {
1594
- const left = def.in._zod.run(payload, ctx);
1595
- if (left instanceof Promise) {
1596
- return left.then((left) => handlePipeResult(left, def, ctx));
1597
- }
1598
- return handlePipeResult(left, def, ctx);
1599
- };
1600
- });
1601
- function handlePipeResult(left, def, ctx) {
1602
- if (util.aborted(left)) {
1603
- return left;
1604
- }
1605
- return def.out._zod.run({ value: left.value, issues: left.issues }, ctx);
1606
- }
1607
- const $ZodReadonly = /*@__PURE__*/ core.$constructor("$ZodReadonly", (inst, def) => {
1608
- $ZodType.init(inst, def);
1609
- util.defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
1610
- util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
1611
- util.defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
1612
- util.defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
1613
- inst._zod.parse = (payload, ctx) => {
1614
- const result = def.innerType._zod.run(payload, ctx);
1615
- if (result instanceof Promise) {
1616
- return result.then(handleReadonlyResult);
1617
- }
1618
- return handleReadonlyResult(result);
1619
- };
1620
- });
1621
- function handleReadonlyResult(payload) {
1622
- payload.value = Object.freeze(payload.value);
1623
- return payload;
1624
- }
1625
- const $ZodTemplateLiteral = /*@__PURE__*/ core.$constructor("$ZodTemplateLiteral", (inst, def) => {
1626
- $ZodType.init(inst, def);
1627
- const regexParts = [];
1628
- for (const part of def.parts) {
1629
- if (part instanceof $ZodType) {
1630
- if (!part._zod.pattern) {
1631
- // if (!source)
1632
- throw new Error(`Invalid template literal part, no pattern found: ${[...part._zod.traits].shift()}`);
1633
- }
1634
- const source = part._zod.pattern instanceof RegExp ? part._zod.pattern.source : part._zod.pattern;
1635
- if (!source)
1636
- throw new Error(`Invalid template literal part: ${part._zod.traits}`);
1637
- const start = source.startsWith("^") ? 1 : 0;
1638
- const end = source.endsWith("$") ? source.length - 1 : source.length;
1639
- regexParts.push(source.slice(start, end));
1640
- }
1641
- else if (part === null || util.primitiveTypes.has(typeof part)) {
1642
- regexParts.push(util.escapeRegex(`${part}`));
1643
- }
1644
- else {
1645
- throw new Error(`Invalid template literal part: ${part}`);
1646
- }
1647
- }
1648
- inst._zod.pattern = new RegExp(`^${regexParts.join("")}$`);
1649
- inst._zod.parse = (payload, _ctx) => {
1650
- if (typeof payload.value !== "string") {
1651
- payload.issues.push({
1652
- input: payload.value,
1653
- inst,
1654
- expected: "template_literal",
1655
- code: "invalid_type",
1656
- });
1657
- return payload;
1658
- }
1659
- inst._zod.pattern.lastIndex = 0;
1660
- if (!inst._zod.pattern.test(payload.value)) {
1661
- payload.issues.push({
1662
- input: payload.value,
1663
- inst,
1664
- code: "invalid_format",
1665
- format: "template_literal",
1666
- pattern: inst._zod.pattern.source,
1667
- });
1668
- return payload;
1669
- }
1670
- return payload;
1671
- };
1672
- });
1673
- const $ZodPromise = /*@__PURE__*/ core.$constructor("$ZodPromise", (inst, def) => {
1674
- $ZodType.init(inst, def);
1675
- inst._zod.parse = (payload, ctx) => {
1676
- return Promise.resolve(payload.value).then((inner) => def.innerType._zod.run({ value: inner, issues: [] }, ctx));
1677
- };
1678
- });
1679
- const $ZodLazy = /*@__PURE__*/ core.$constructor("$ZodLazy", (inst, def) => {
1680
- $ZodType.init(inst, def);
1681
- util.defineLazy(inst._zod, "innerType", () => def.getter());
1682
- util.defineLazy(inst._zod, "pattern", () => inst._zod.innerType._zod.pattern);
1683
- util.defineLazy(inst._zod, "propValues", () => inst._zod.innerType._zod.propValues);
1684
- util.defineLazy(inst._zod, "optin", () => inst._zod.innerType._zod.optin);
1685
- util.defineLazy(inst._zod, "optout", () => inst._zod.innerType._zod.optout);
1686
- inst._zod.parse = (payload, ctx) => {
1687
- const inner = inst._zod.innerType;
1688
- return inner._zod.run(payload, ctx);
1689
- };
1690
- });
1691
- const $ZodCustom = /*@__PURE__*/ core.$constructor("$ZodCustom", (inst, def) => {
1692
- checks.$ZodCheck.init(inst, def);
1693
- $ZodType.init(inst, def);
1694
- inst._zod.parse = (payload, _) => {
1695
- return payload;
1696
- };
1697
- inst._zod.check = (payload) => {
1698
- const input = payload.value;
1699
- const r = def.fn(input);
1700
- if (r instanceof Promise) {
1701
- return r.then((r) => handleRefineResult(r, payload, input, inst));
1702
- }
1703
- handleRefineResult(r, payload, input, inst);
1704
- return;
1705
- };
1706
- });
1707
- function handleRefineResult(result, payload, input, inst) {
1708
- if (!result) {
1709
- const _iss = {
1710
- code: "custom",
1711
- input,
1712
- inst, // incorporates params.error into issue reporting
1713
- path: [...(inst._zod.def.path ?? [])], // incorporates params.error into issue reporting
1714
- continue: !inst._zod.def.abort,
1715
- // params: inst._zod.def.params,
1716
- };
1717
- if (inst._zod.def.params)
1718
- _iss.params = inst._zod.def.params;
1719
- payload.issues.push(util.issue(_iss));
1720
- }
1721
- }
1722
-
1723
- exports.clone = util.clone;
1724
- exports.$ZodAny = $ZodAny;
1725
- exports.$ZodArray = $ZodArray;
1726
- exports.$ZodBase64 = $ZodBase64;
1727
- exports.$ZodBase64URL = $ZodBase64URL;
1728
- exports.$ZodBigInt = $ZodBigInt;
1729
- exports.$ZodBigIntFormat = $ZodBigIntFormat;
1730
- exports.$ZodBoolean = $ZodBoolean;
1731
- exports.$ZodCIDRv4 = $ZodCIDRv4;
1732
- exports.$ZodCIDRv6 = $ZodCIDRv6;
1733
- exports.$ZodCUID = $ZodCUID;
1734
- exports.$ZodCUID2 = $ZodCUID2;
1735
- exports.$ZodCatch = $ZodCatch;
1736
- exports.$ZodCustom = $ZodCustom;
1737
- exports.$ZodCustomStringFormat = $ZodCustomStringFormat;
1738
- exports.$ZodDate = $ZodDate;
1739
- exports.$ZodDefault = $ZodDefault;
1740
- exports.$ZodDiscriminatedUnion = $ZodDiscriminatedUnion;
1741
- exports.$ZodE164 = $ZodE164;
1742
- exports.$ZodEmail = $ZodEmail;
1743
- exports.$ZodEmoji = $ZodEmoji;
1744
- exports.$ZodEnum = $ZodEnum;
1745
- exports.$ZodFile = $ZodFile;
1746
- exports.$ZodGUID = $ZodGUID;
1747
- exports.$ZodIPv4 = $ZodIPv4;
1748
- exports.$ZodIPv6 = $ZodIPv6;
1749
- exports.$ZodISODate = $ZodISODate;
1750
- exports.$ZodISODateTime = $ZodISODateTime;
1751
- exports.$ZodISODuration = $ZodISODuration;
1752
- exports.$ZodISOTime = $ZodISOTime;
1753
- exports.$ZodIntersection = $ZodIntersection;
1754
- exports.$ZodJWT = $ZodJWT;
1755
- exports.$ZodKSUID = $ZodKSUID;
1756
- exports.$ZodLazy = $ZodLazy;
1757
- exports.$ZodLiteral = $ZodLiteral;
1758
- exports.$ZodMap = $ZodMap;
1759
- exports.$ZodNaN = $ZodNaN;
1760
- exports.$ZodNanoID = $ZodNanoID;
1761
- exports.$ZodNever = $ZodNever;
1762
- exports.$ZodNonOptional = $ZodNonOptional;
1763
- exports.$ZodNull = $ZodNull;
1764
- exports.$ZodNullable = $ZodNullable;
1765
- exports.$ZodNumber = $ZodNumber;
1766
- exports.$ZodNumberFormat = $ZodNumberFormat;
1767
- exports.$ZodObject = $ZodObject;
1768
- exports.$ZodOptional = $ZodOptional;
1769
- exports.$ZodPipe = $ZodPipe;
1770
- exports.$ZodPrefault = $ZodPrefault;
1771
- exports.$ZodPromise = $ZodPromise;
1772
- exports.$ZodReadonly = $ZodReadonly;
1773
- exports.$ZodRecord = $ZodRecord;
1774
- exports.$ZodSet = $ZodSet;
1775
- exports.$ZodString = $ZodString;
1776
- exports.$ZodStringFormat = $ZodStringFormat;
1777
- exports.$ZodSuccess = $ZodSuccess;
1778
- exports.$ZodSymbol = $ZodSymbol;
1779
- exports.$ZodTemplateLiteral = $ZodTemplateLiteral;
1780
- exports.$ZodTransform = $ZodTransform;
1781
- exports.$ZodTuple = $ZodTuple;
1782
- exports.$ZodType = $ZodType;
1783
- exports.$ZodULID = $ZodULID;
1784
- exports.$ZodURL = $ZodURL;
1785
- exports.$ZodUUID = $ZodUUID;
1786
- exports.$ZodUndefined = $ZodUndefined;
1787
- exports.$ZodUnion = $ZodUnion;
1788
- exports.$ZodUnknown = $ZodUnknown;
1789
- exports.$ZodVoid = $ZodVoid;
1790
- exports.$ZodXID = $ZodXID;
1791
- exports.isValidBase64 = isValidBase64;
1792
- exports.isValidBase64URL = isValidBase64URL;
1793
- exports.isValidJWT = isValidJWT;