lkd-web-kit 0.4.8 → 0.4.10

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