zod 3.26.0-canary.20250703T011142 → 3.26.0-canary.20250703T025502

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 (269) hide show
  1. package/package.json +4 -4
  2. package/src/index.ts +4 -0
  3. package/src/v3/ZodError.ts +330 -0
  4. package/src/v3/benchmarks/datetime.ts +58 -0
  5. package/src/v3/benchmarks/discriminatedUnion.ts +80 -0
  6. package/src/v3/benchmarks/index.ts +59 -0
  7. package/src/v3/benchmarks/ipv4.ts +57 -0
  8. package/src/v3/benchmarks/object.ts +69 -0
  9. package/src/v3/benchmarks/primitives.ts +162 -0
  10. package/src/v3/benchmarks/realworld.ts +63 -0
  11. package/src/v3/benchmarks/string.ts +55 -0
  12. package/src/v3/benchmarks/union.ts +80 -0
  13. package/src/v3/errors.ts +13 -0
  14. package/src/v3/external.ts +6 -0
  15. package/src/v3/helpers/enumUtil.ts +17 -0
  16. package/src/v3/helpers/errorUtil.ts +8 -0
  17. package/src/v3/helpers/parseUtil.ts +176 -0
  18. package/src/v3/helpers/partialUtil.ts +34 -0
  19. package/src/v3/helpers/typeAliases.ts +2 -0
  20. package/src/v3/helpers/util.ts +224 -0
  21. package/src/v3/index.ts +4 -0
  22. package/src/v3/locales/en.ts +124 -0
  23. package/src/v3/standard-schema.ts +113 -0
  24. package/src/v3/tests/Mocker.ts +54 -0
  25. package/src/v3/tests/all-errors.test.ts +157 -0
  26. package/src/v3/tests/anyunknown.test.ts +28 -0
  27. package/src/v3/tests/array.test.ts +71 -0
  28. package/src/v3/tests/async-parsing.test.ts +388 -0
  29. package/src/v3/tests/async-refinements.test.ts +46 -0
  30. package/src/v3/tests/base.test.ts +29 -0
  31. package/src/v3/tests/bigint.test.ts +55 -0
  32. package/src/v3/tests/branded.test.ts +53 -0
  33. package/src/v3/tests/catch.test.ts +220 -0
  34. package/src/v3/tests/coerce.test.ts +133 -0
  35. package/src/v3/tests/complex.test.ts +56 -0
  36. package/src/v3/tests/custom.test.ts +31 -0
  37. package/src/v3/tests/date.test.ts +32 -0
  38. package/src/v3/tests/deepmasking.test.ts +186 -0
  39. package/src/v3/tests/default.test.ts +112 -0
  40. package/src/v3/tests/description.test.ts +33 -0
  41. package/src/v3/tests/discriminated-unions.test.ts +315 -0
  42. package/src/v3/tests/enum.test.ts +80 -0
  43. package/src/v3/tests/error.test.ts +551 -0
  44. package/src/v3/tests/firstparty.test.ts +87 -0
  45. package/src/v3/tests/firstpartyschematypes.test.ts +21 -0
  46. package/src/v3/tests/function.test.ts +257 -0
  47. package/src/v3/tests/generics.test.ts +48 -0
  48. package/src/v3/tests/instanceof.test.ts +37 -0
  49. package/src/v3/tests/intersection.test.ts +110 -0
  50. package/src/v3/tests/language-server.source.ts +76 -0
  51. package/src/v3/tests/language-server.test.ts +207 -0
  52. package/src/v3/tests/literal.test.ts +36 -0
  53. package/src/v3/tests/map.test.ts +110 -0
  54. package/src/v3/tests/masking.test.ts +4 -0
  55. package/src/v3/tests/mocker.test.ts +19 -0
  56. package/src/v3/tests/nan.test.ts +21 -0
  57. package/src/v3/tests/nativeEnum.test.ts +87 -0
  58. package/src/v3/tests/nullable.test.ts +42 -0
  59. package/src/v3/tests/number.test.ts +176 -0
  60. package/src/v3/tests/object-augmentation.test.ts +29 -0
  61. package/src/v3/tests/object-in-es5-env.test.ts +29 -0
  62. package/src/v3/tests/object.test.ts +434 -0
  63. package/src/v3/tests/optional.test.ts +42 -0
  64. package/src/v3/tests/parseUtil.test.ts +23 -0
  65. package/src/v3/tests/parser.test.ts +41 -0
  66. package/src/v3/tests/partials.test.ts +243 -0
  67. package/src/v3/tests/pickomit.test.ts +111 -0
  68. package/src/v3/tests/pipeline.test.ts +29 -0
  69. package/src/v3/tests/preprocess.test.ts +186 -0
  70. package/src/v3/tests/primitive.test.ts +440 -0
  71. package/src/v3/tests/promise.test.ts +90 -0
  72. package/src/v3/tests/readonly.test.ts +194 -0
  73. package/src/v3/tests/record.test.ts +171 -0
  74. package/src/v3/tests/recursive.test.ts +197 -0
  75. package/src/v3/tests/refine.test.ts +313 -0
  76. package/src/v3/tests/safeparse.test.ts +27 -0
  77. package/src/v3/tests/set.test.ts +142 -0
  78. package/src/v3/tests/standard-schema.test.ts +83 -0
  79. package/src/v3/tests/string.test.ts +916 -0
  80. package/src/v3/tests/transformer.test.ts +233 -0
  81. package/src/v3/tests/tuple.test.ts +90 -0
  82. package/src/v3/tests/unions.test.ts +57 -0
  83. package/src/v3/tests/validations.test.ts +133 -0
  84. package/src/v3/tests/void.test.ts +15 -0
  85. package/src/v3/types.ts +5136 -0
  86. package/src/v4/classic/checks.ts +30 -0
  87. package/src/v4/classic/coerce.ts +27 -0
  88. package/src/v4/classic/compat.ts +66 -0
  89. package/src/v4/classic/errors.ts +75 -0
  90. package/src/v4/classic/external.ts +50 -0
  91. package/src/v4/classic/index.ts +5 -0
  92. package/src/v4/classic/iso.ts +90 -0
  93. package/src/v4/classic/parse.ts +33 -0
  94. package/src/v4/classic/schemas.ts +2055 -0
  95. package/src/v4/classic/tests/anyunknown.test.ts +26 -0
  96. package/src/v4/classic/tests/array.test.ts +264 -0
  97. package/src/v4/classic/tests/assignability.test.ts +210 -0
  98. package/src/v4/classic/tests/async-parsing.test.ts +381 -0
  99. package/src/v4/classic/tests/async-refinements.test.ts +68 -0
  100. package/src/v4/classic/tests/base.test.ts +7 -0
  101. package/src/v4/classic/tests/bigint.test.ts +54 -0
  102. package/src/v4/classic/tests/brand.test.ts +65 -0
  103. package/src/v4/classic/tests/catch.test.ts +252 -0
  104. package/src/v4/classic/tests/coalesce.test.ts +20 -0
  105. package/src/v4/classic/tests/coerce.test.ts +160 -0
  106. package/src/v4/classic/tests/continuability.test.ts +352 -0
  107. package/src/v4/classic/tests/custom.test.ts +40 -0
  108. package/src/v4/classic/tests/date.test.ts +31 -0
  109. package/src/v4/classic/tests/datetime.test.ts +296 -0
  110. package/src/v4/classic/tests/default.test.ts +313 -0
  111. package/src/v4/classic/tests/description.test.ts +32 -0
  112. package/src/v4/classic/tests/discriminated-unions.test.ts +592 -0
  113. package/src/v4/classic/tests/enum.test.ts +285 -0
  114. package/src/v4/classic/tests/error-utils.test.ts +527 -0
  115. package/src/v4/classic/tests/error.test.ts +711 -0
  116. package/src/v4/classic/tests/file.test.ts +91 -0
  117. package/src/v4/classic/tests/firstparty.test.ts +175 -0
  118. package/src/v4/classic/tests/function.test.ts +268 -0
  119. package/src/v4/classic/tests/generics.test.ts +72 -0
  120. package/src/v4/classic/tests/index.test.ts +829 -0
  121. package/src/v4/classic/tests/instanceof.test.ts +34 -0
  122. package/src/v4/classic/tests/intersection.test.ts +171 -0
  123. package/src/v4/classic/tests/json.test.ts +108 -0
  124. package/src/v4/classic/tests/lazy.test.ts +227 -0
  125. package/src/v4/classic/tests/literal.test.ts +92 -0
  126. package/src/v4/classic/tests/map.test.ts +196 -0
  127. package/src/v4/classic/tests/nan.test.ts +21 -0
  128. package/src/v4/classic/tests/nested-refine.test.ts +168 -0
  129. package/src/v4/classic/tests/nonoptional.test.ts +86 -0
  130. package/src/v4/classic/tests/nullable.test.ts +22 -0
  131. package/src/v4/classic/tests/number.test.ts +247 -0
  132. package/src/v4/classic/tests/object.test.ts +553 -0
  133. package/src/v4/classic/tests/optional.test.ts +103 -0
  134. package/src/v4/classic/tests/partial.test.ts +147 -0
  135. package/src/v4/classic/tests/pickomit.test.ts +127 -0
  136. package/src/v4/classic/tests/pipe.test.ts +81 -0
  137. package/src/v4/classic/tests/prefault.test.ts +37 -0
  138. package/src/v4/classic/tests/preprocess.test.ts +298 -0
  139. package/src/v4/classic/tests/primitive.test.ts +175 -0
  140. package/src/v4/classic/tests/promise.test.ts +81 -0
  141. package/src/v4/classic/tests/prototypes.test.ts +23 -0
  142. package/src/v4/classic/tests/readonly.test.ts +252 -0
  143. package/src/v4/classic/tests/record.test.ts +332 -0
  144. package/src/v4/classic/tests/recursive-types.test.ts +325 -0
  145. package/src/v4/classic/tests/refine.test.ts +423 -0
  146. package/src/v4/classic/tests/registries.test.ts +195 -0
  147. package/src/v4/classic/tests/set.test.ts +179 -0
  148. package/src/v4/classic/tests/standard-schema.test.ts +57 -0
  149. package/src/v4/classic/tests/string-formats.test.ts +109 -0
  150. package/src/v4/classic/tests/string.test.ts +881 -0
  151. package/src/v4/classic/tests/stringbool.test.ts +66 -0
  152. package/src/v4/classic/tests/template-literal.test.ts +758 -0
  153. package/src/v4/classic/tests/to-json-schema.test.ts +2182 -0
  154. package/src/v4/classic/tests/transform.test.ts +250 -0
  155. package/src/v4/classic/tests/tuple.test.ts +163 -0
  156. package/src/v4/classic/tests/union.test.ts +94 -0
  157. package/src/v4/classic/tests/validations.test.ts +283 -0
  158. package/src/v4/classic/tests/void.test.ts +12 -0
  159. package/src/v4/core/api.ts +1592 -0
  160. package/src/v4/core/checks.ts +1285 -0
  161. package/src/v4/core/config.ts +15 -0
  162. package/src/v4/core/core.ts +134 -0
  163. package/src/v4/core/doc.ts +44 -0
  164. package/src/v4/core/errors.ts +420 -0
  165. package/src/v4/core/function.ts +176 -0
  166. package/src/v4/core/index.ts +15 -0
  167. package/src/v4/core/json-schema.ts +143 -0
  168. package/src/v4/core/parse.ts +94 -0
  169. package/src/v4/core/regexes.ts +135 -0
  170. package/src/v4/core/registries.ts +86 -0
  171. package/src/v4/core/schemas.ts +3781 -0
  172. package/src/v4/core/standard-schema.ts +64 -0
  173. package/src/v4/core/tests/index.test.ts +46 -0
  174. package/src/v4/core/tests/locales/be.test.ts +124 -0
  175. package/src/v4/core/tests/locales/en.test.ts +22 -0
  176. package/src/v4/core/tests/locales/ru.test.ts +128 -0
  177. package/src/v4/core/tests/locales/tr.test.ts +69 -0
  178. package/src/v4/core/to-json-schema.ts +944 -0
  179. package/src/v4/core/util.ts +775 -0
  180. package/src/v4/core/versions.ts +5 -0
  181. package/src/v4/core/zsf.ts +323 -0
  182. package/src/v4/index.ts +4 -0
  183. package/src/v4/locales/ar.ts +125 -0
  184. package/src/v4/locales/az.ts +121 -0
  185. package/src/v4/locales/be.ts +184 -0
  186. package/src/v4/locales/ca.ts +127 -0
  187. package/src/v4/locales/cs.ts +142 -0
  188. package/src/v4/locales/de.ts +124 -0
  189. package/src/v4/locales/en.ts +127 -0
  190. package/src/v4/locales/es.ts +125 -0
  191. package/src/v4/locales/fa.ts +134 -0
  192. package/src/v4/locales/fi.ts +131 -0
  193. package/src/v4/locales/fr-CA.ts +126 -0
  194. package/src/v4/locales/fr.ts +124 -0
  195. package/src/v4/locales/he.ts +125 -0
  196. package/src/v4/locales/hu.ts +126 -0
  197. package/src/v4/locales/id.ts +125 -0
  198. package/src/v4/locales/index.ts +38 -0
  199. package/src/v4/locales/it.ts +125 -0
  200. package/src/v4/locales/ja.ts +122 -0
  201. package/src/v4/locales/kh.ts +126 -0
  202. package/src/v4/locales/ko.ts +131 -0
  203. package/src/v4/locales/mk.ts +127 -0
  204. package/src/v4/locales/ms.ts +124 -0
  205. package/src/v4/locales/nl.ts +126 -0
  206. package/src/v4/locales/no.ts +124 -0
  207. package/src/v4/locales/ota.ts +125 -0
  208. package/src/v4/locales/pl.ts +126 -0
  209. package/src/v4/locales/ps.ts +133 -0
  210. package/src/v4/locales/pt.ts +123 -0
  211. package/src/v4/locales/ru.ts +184 -0
  212. package/src/v4/locales/sl.ts +126 -0
  213. package/src/v4/locales/sv.ts +127 -0
  214. package/src/v4/locales/ta.ts +125 -0
  215. package/src/v4/locales/th.ts +126 -0
  216. package/src/v4/locales/tr.ts +121 -0
  217. package/src/v4/locales/ua.ts +126 -0
  218. package/src/v4/locales/ur.ts +126 -0
  219. package/src/v4/locales/vi.ts +125 -0
  220. package/src/v4/locales/zh-CN.ts +123 -0
  221. package/src/v4/locales/zh-TW.ts +125 -0
  222. package/src/v4/mini/checks.ts +32 -0
  223. package/src/v4/mini/coerce.ts +22 -0
  224. package/src/v4/mini/external.ts +40 -0
  225. package/src/v4/mini/index.ts +3 -0
  226. package/src/v4/mini/iso.ts +62 -0
  227. package/src/v4/mini/parse.ts +1 -0
  228. package/src/v4/mini/schemas.ts +1579 -0
  229. package/src/v4/mini/tests/assignability.test.ts +129 -0
  230. package/src/v4/mini/tests/brand.test.ts +51 -0
  231. package/src/v4/mini/tests/checks.test.ts +144 -0
  232. package/src/v4/mini/tests/computed.test.ts +36 -0
  233. package/src/v4/mini/tests/error.test.ts +22 -0
  234. package/src/v4/mini/tests/functions.test.ts +43 -0
  235. package/src/v4/mini/tests/index.test.ts +871 -0
  236. package/src/v4/mini/tests/number.test.ts +95 -0
  237. package/src/v4/mini/tests/object.test.ts +185 -0
  238. package/src/v4/mini/tests/prototypes.test.ts +43 -0
  239. package/src/v4/mini/tests/recursive-types.test.ts +275 -0
  240. package/src/v4/mini/tests/string.test.ts +293 -0
  241. package/src/v4-mini/index.ts +1 -0
  242. package/v4/classic/compat.cjs +1 -7
  243. package/v4/classic/compat.d.cts +0 -2
  244. package/v4/classic/compat.d.ts +0 -2
  245. package/v4/classic/compat.js +0 -6
  246. package/v4/classic/external.cjs +2 -1
  247. package/v4/classic/external.d.cts +1 -1
  248. package/v4/classic/external.d.ts +1 -1
  249. package/v4/classic/external.js +1 -1
  250. package/v4/classic/schemas.d.cts +4 -4
  251. package/v4/classic/schemas.d.ts +4 -4
  252. package/v4/core/api.cjs +11 -10
  253. package/v4/core/api.js +11 -10
  254. package/v4/core/checks.cjs +6 -4
  255. package/v4/core/checks.js +6 -4
  256. package/v4/core/core.cjs +5 -1
  257. package/v4/core/core.d.cts +2 -0
  258. package/v4/core/core.d.ts +2 -0
  259. package/v4/core/core.js +4 -0
  260. package/v4/core/schemas.cjs +12 -13
  261. package/v4/core/schemas.js +12 -13
  262. package/v4/core/util.cjs +3 -0
  263. package/v4/core/util.d.cts +1 -1
  264. package/v4/core/util.d.ts +1 -1
  265. package/v4/core/util.js +3 -0
  266. package/v4/mini/external.cjs +2 -1
  267. package/v4/mini/external.d.cts +1 -1
  268. package/v4/mini/external.d.ts +1 -1
  269. package/v4/mini/external.js +1 -1
@@ -0,0 +1,1285 @@
1
+ // import { $ZodType } from "./schemas.js";
2
+
3
+ import * as core from "./core.js";
4
+ import type * as errors from "./errors.js";
5
+ import * as regexes from "./regexes.js";
6
+ import type * as schemas from "./schemas.js";
7
+ import * as util from "./util.js";
8
+
9
+ ////////////////////////////// CHECKS ///////////////////////////////////////
10
+
11
+ export interface $ZodCheckDef {
12
+ check: string;
13
+ error?: errors.$ZodErrorMap<never> | undefined;
14
+ /** If true, no later checks will be executed if this check fails. Default `false`. */
15
+ abort?: boolean | undefined;
16
+ }
17
+
18
+ export interface $ZodCheckInternals<T> {
19
+ def: $ZodCheckDef;
20
+ /** The set of issues this check might throw. */
21
+ issc?: errors.$ZodIssueBase;
22
+ // "_check"(input: $ZodResult<T>): util.MaybeAsync<void>;
23
+ check(payload: schemas.ParsePayload<T>): util.MaybeAsync<void>;
24
+ // _parseB(payload: ParsePayload<any>, ctx: ParseContext): util.MaybeAsync<ParsePayload>;
25
+ onattach: ((schema: schemas.$ZodType) => void)[];
26
+ // "_async": boolean;
27
+ when?: ((payload: schemas.ParsePayload) => boolean) | undefined;
28
+ }
29
+
30
+ export interface $ZodCheck<in T = never> {
31
+ _zod: $ZodCheckInternals<T>;
32
+ }
33
+
34
+ export const $ZodCheck: core.$constructor<$ZodCheck<any>> = /*@__PURE__*/ core.$constructor(
35
+ "$ZodCheck",
36
+ (inst, def) => {
37
+ inst._zod ??= {} as any;
38
+ inst._zod.def = def;
39
+ inst._zod.onattach ??= [];
40
+ }
41
+ );
42
+
43
+ ///////////////////////////////////////
44
+ ///// $ZodCheckLessThan /////
45
+ ///////////////////////////////////////
46
+ export interface $ZodCheckLessThanDef extends $ZodCheckDef {
47
+ check: "less_than";
48
+ value: util.Numeric;
49
+ inclusive: boolean;
50
+ }
51
+
52
+ export interface $ZodCheckLessThanInternals<T extends util.Numeric = util.Numeric> extends $ZodCheckInternals<T> {
53
+ def: $ZodCheckLessThanDef;
54
+ issc: errors.$ZodIssueTooBig<T>;
55
+ }
56
+
57
+ const numericOriginMap = {
58
+ number: "number",
59
+ bigint: "bigint",
60
+ object: "date",
61
+ } as const;
62
+ export interface $ZodCheckLessThan<T extends util.Numeric = util.Numeric> extends $ZodCheck<T> {
63
+ _zod: $ZodCheckLessThanInternals<T>;
64
+ }
65
+
66
+ export const $ZodCheckLessThan: core.$constructor<$ZodCheckLessThan> = /*@__PURE__*/ core.$constructor(
67
+ "$ZodCheckLessThan",
68
+ (inst, def) => {
69
+ $ZodCheck.init(inst, def);
70
+ const origin = numericOriginMap[typeof def.value as "number" | "bigint" | "object"];
71
+
72
+ inst._zod.onattach.push((inst) => {
73
+ const bag = inst._zod.bag;
74
+ const curr = (def.inclusive ? bag.maximum : bag.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;
75
+ if (def.value < curr) {
76
+ if (def.inclusive) bag.maximum = def.value;
77
+ else bag.exclusiveMaximum = def.value;
78
+ }
79
+ });
80
+
81
+ inst._zod.check = (payload) => {
82
+ if (def.inclusive ? payload.value <= def.value : payload.value < def.value) {
83
+ return;
84
+ }
85
+
86
+ payload.issues.push({
87
+ origin,
88
+ code: "too_big",
89
+ maximum: def.value as number,
90
+ input: payload.value,
91
+ inclusive: def.inclusive,
92
+ inst,
93
+ continue: !def.abort,
94
+ });
95
+ };
96
+ }
97
+ );
98
+
99
+ /////////////////////////////////////
100
+ ///// $ZodCheckGreaterThan /////
101
+ /////////////////////////////////////
102
+ export interface $ZodCheckGreaterThanDef extends $ZodCheckDef {
103
+ check: "greater_than";
104
+ value: util.Numeric;
105
+ inclusive: boolean;
106
+ }
107
+
108
+ export interface $ZodCheckGreaterThanInternals<T extends util.Numeric = util.Numeric> extends $ZodCheckInternals<T> {
109
+ def: $ZodCheckGreaterThanDef;
110
+ issc: errors.$ZodIssueTooSmall<T>;
111
+ }
112
+
113
+ export interface $ZodCheckGreaterThan<T extends util.Numeric = util.Numeric> extends $ZodCheck<T> {
114
+ _zod: $ZodCheckGreaterThanInternals<T>;
115
+ }
116
+
117
+ export const $ZodCheckGreaterThan: core.$constructor<$ZodCheckGreaterThan> = /*@__PURE__*/ core.$constructor(
118
+ "$ZodCheckGreaterThan",
119
+ (inst, def) => {
120
+ $ZodCheck.init(inst, def);
121
+ const origin = numericOriginMap[typeof def.value as "number" | "bigint" | "object"];
122
+
123
+ inst._zod.onattach.push((inst) => {
124
+ const bag = inst._zod.bag;
125
+ const curr = (def.inclusive ? bag.minimum : bag.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
126
+ if (def.value > curr) {
127
+ if (def.inclusive) bag.minimum = def.value;
128
+ else bag.exclusiveMinimum = def.value;
129
+ }
130
+ });
131
+
132
+ inst._zod.check = (payload) => {
133
+ if (def.inclusive ? payload.value >= def.value : payload.value > def.value) {
134
+ return;
135
+ }
136
+
137
+ payload.issues.push({
138
+ origin,
139
+ code: "too_small",
140
+ minimum: def.value as number,
141
+ input: payload.value,
142
+ inclusive: def.inclusive,
143
+ inst,
144
+ continue: !def.abort,
145
+ });
146
+ };
147
+ }
148
+ );
149
+
150
+ /////////////////////////////////////
151
+ ///// $ZodCheckMultipleOf /////
152
+ /////////////////////////////////////
153
+ // https://stackoverflow.com/questions/3966484/why-does-modulus-operator-return-fractional-number-in-javascript/31711034#31711034
154
+
155
+ export interface $ZodCheckMultipleOfDef<T extends number | bigint = number | bigint> extends $ZodCheckDef {
156
+ check: "multiple_of";
157
+ value: T;
158
+ }
159
+
160
+ export interface $ZodCheckMultipleOfInternals<T extends number | bigint = number | bigint>
161
+ extends $ZodCheckInternals<T> {
162
+ def: $ZodCheckMultipleOfDef<T>;
163
+ issc: errors.$ZodIssueNotMultipleOf;
164
+ }
165
+
166
+ export interface $ZodCheckMultipleOf<T extends number | bigint = number | bigint> extends $ZodCheck<T> {
167
+ _zod: $ZodCheckMultipleOfInternals<T>;
168
+ }
169
+
170
+ export const $ZodCheckMultipleOf: core.$constructor<$ZodCheckMultipleOf<number | bigint>> =
171
+ /*@__PURE__*/ core.$constructor("$ZodCheckMultipleOf", (inst, def) => {
172
+ $ZodCheck.init(inst, def);
173
+
174
+ inst._zod.onattach.push((inst) => {
175
+ inst._zod.bag.multipleOf ??= def.value;
176
+ });
177
+
178
+ inst._zod.check = (payload) => {
179
+ if (typeof payload.value !== typeof def.value)
180
+ throw new Error("Cannot mix number and bigint in multiple_of check.");
181
+ const isMultiple =
182
+ typeof payload.value === "bigint"
183
+ ? payload.value % (def.value as bigint) === BigInt(0)
184
+ : util.floatSafeRemainder(payload.value, def.value as number) === 0;
185
+
186
+ if (isMultiple) return;
187
+ payload.issues.push({
188
+ origin: typeof payload.value as "number",
189
+ code: "not_multiple_of",
190
+ divisor: def.value as number,
191
+ input: payload.value,
192
+ inst,
193
+ continue: !def.abort,
194
+ });
195
+ };
196
+ });
197
+
198
+ /////////////////////////////////////
199
+ ///// $ZodCheckFinite /////
200
+ /////////////////////////////////////
201
+ // interface $ZodCheckFiniteDef extends $ZodCheckDef {
202
+ // check: "finite";
203
+ // }
204
+
205
+ // export interface $ZodCheckFinite extends $ZodCheckInternals<number> {
206
+ // _def: $ZodCheckFiniteDef;
207
+ // _issc:
208
+ // | errors.$ZodIssueTooBig<"number", number>
209
+ // | errors.$ZodIssueTooSmall<"number", number>;
210
+ // }
211
+
212
+ // export const $ZodCheckFinite: core.$constructor<$ZodCheckFinite> =
213
+ // core.$constructor("$ZodCheckFinite", (inst, def) => {
214
+ // $ZodCheck.init(inst, def);
215
+
216
+ // inst._zod.onattach = (inst) => {
217
+ // inst["_bag"].finite = true;
218
+ // };
219
+
220
+ // inst._zod.check = (payload) => {
221
+ // if (Number.isFinite(payload.value)) return;
222
+ // payload.issues.push({
223
+ // origin: "number",
224
+ // ...(payload.value === Number.POSITIVE_INFINITY
225
+ // ? {
226
+ // code: "too_big",
227
+ // maximum: Number.POSITIVE_INFINITY,
228
+ // }
229
+ // : {
230
+ // code: "too_small",
231
+ // minimum: Number.NEGATIVE_INFINITY,
232
+ // }),
233
+ // // code: payload.value === Number.POSITIVE_INFINITY ? "too_big" : "too_big",
234
+ // // maximum: Number.POSITIVE_INFINITY,
235
+ // inclusive: false,
236
+ // input: payload.value,
237
+ // inst,
238
+ // });
239
+ // };
240
+ // });
241
+
242
+ ///////////////////////////////////////
243
+ ///// $ZodCheckNumberFormat /////
244
+ ///////////////////////////////////////
245
+
246
+ export type $ZodNumberFormats = "int32" | "uint32" | "float32" | "float64" | "safeint";
247
+
248
+ export interface $ZodCheckNumberFormatDef extends $ZodCheckDef {
249
+ check: "number_format";
250
+ format: $ZodNumberFormats;
251
+ // abort?: boolean;
252
+ }
253
+
254
+ export interface $ZodCheckNumberFormatInternals extends $ZodCheckInternals<number> {
255
+ def: $ZodCheckNumberFormatDef;
256
+ issc: errors.$ZodIssueInvalidType | errors.$ZodIssueTooBig<"number"> | errors.$ZodIssueTooSmall<"number">;
257
+ // bag: util.LoosePartial<{
258
+ // minimum?: number | undefined;
259
+ // }>;
260
+ }
261
+
262
+ export interface $ZodCheckNumberFormat extends $ZodCheck<number> {
263
+ _zod: $ZodCheckNumberFormatInternals;
264
+ }
265
+
266
+ export const $ZodCheckNumberFormat: core.$constructor<$ZodCheckNumberFormat> = /*@__PURE__*/ core.$constructor(
267
+ "$ZodCheckNumberFormat",
268
+ (inst, def) => {
269
+ $ZodCheck.init(inst, def); // no format checks
270
+ def.format = def.format || "float64";
271
+
272
+ const isInt = def.format?.includes("int");
273
+ const origin = isInt ? "int" : "number";
274
+ const [minimum, maximum] = util.NUMBER_FORMAT_RANGES[def.format];
275
+
276
+ inst._zod.onattach.push((inst) => {
277
+ const bag = inst._zod.bag;
278
+ bag.format = def.format;
279
+ bag.minimum = minimum;
280
+ bag.maximum = maximum;
281
+ if (isInt) bag.pattern = regexes.integer;
282
+ });
283
+
284
+ inst._zod.check = (payload) => {
285
+ const input = payload.value;
286
+
287
+ if (isInt) {
288
+ if (!Number.isInteger(input)) {
289
+ // invalid_format issue
290
+ // payload.issues.push({
291
+ // expected: def.format,
292
+ // format: def.format,
293
+ // code: "invalid_format",
294
+ // input,
295
+ // inst,
296
+ // });
297
+ // invalid_type issue
298
+ payload.issues.push({
299
+ expected: origin,
300
+ format: def.format,
301
+ code: "invalid_type",
302
+ input,
303
+ inst,
304
+ });
305
+
306
+ return;
307
+
308
+ // not_multiple_of issue
309
+ // payload.issues.push({
310
+ // code: "not_multiple_of",
311
+ // origin: "number",
312
+ // input,
313
+ // inst,
314
+ // divisor: 1,
315
+ // });
316
+ }
317
+ if (!Number.isSafeInteger(input)) {
318
+ if (input > 0) {
319
+ // too_big
320
+ payload.issues.push({
321
+ input,
322
+ code: "too_big",
323
+ maximum: Number.MAX_SAFE_INTEGER,
324
+ note: "Integers must be within the safe integer range.",
325
+ inst,
326
+ origin,
327
+ continue: !def.abort,
328
+ });
329
+ } else {
330
+ // too_small
331
+ payload.issues.push({
332
+ input,
333
+ code: "too_small",
334
+ minimum: Number.MIN_SAFE_INTEGER,
335
+ note: "Integers must be within the safe integer range.",
336
+ inst,
337
+ origin,
338
+ continue: !def.abort,
339
+ });
340
+ }
341
+
342
+ return;
343
+ }
344
+ }
345
+
346
+ if (input < minimum) {
347
+ payload.issues.push({
348
+ origin: "number",
349
+ input,
350
+ code: "too_small",
351
+ minimum,
352
+ inclusive: true,
353
+ inst,
354
+ continue: !def.abort,
355
+ });
356
+ }
357
+
358
+ if (input > maximum) {
359
+ payload.issues.push({
360
+ origin: "number",
361
+ input,
362
+ code: "too_big",
363
+ maximum,
364
+ inst,
365
+ } as any);
366
+ }
367
+ };
368
+ }
369
+ );
370
+
371
+ /////////////////////////////////////
372
+ ///// $ZodCheckBigIntFormat /////
373
+ /////////////////////////////////////
374
+
375
+ export type $ZodBigIntFormats = "int64" | "uint64";
376
+
377
+ export interface $ZodCheckBigIntFormatDef extends $ZodCheckDef {
378
+ check: "bigint_format";
379
+ format: $ZodBigIntFormats | undefined;
380
+ }
381
+
382
+ export interface $ZodCheckBigIntFormatInternals extends $ZodCheckInternals<bigint> {
383
+ def: $ZodCheckBigIntFormatDef;
384
+ issc: errors.$ZodIssueTooBig<"bigint"> | errors.$ZodIssueTooSmall<"bigint">;
385
+ }
386
+
387
+ export interface $ZodCheckBigIntFormat extends $ZodCheck<bigint> {
388
+ _zod: $ZodCheckBigIntFormatInternals;
389
+ }
390
+
391
+ export const $ZodCheckBigIntFormat: core.$constructor<$ZodCheckBigIntFormat> = /*@__PURE__*/ core.$constructor(
392
+ "$ZodCheckBigIntFormat",
393
+ (inst, def) => {
394
+ $ZodCheck.init(inst, def); // no format checks
395
+
396
+ const [minimum, maximum] = util.BIGINT_FORMAT_RANGES[def.format!];
397
+
398
+ inst._zod.onattach.push((inst) => {
399
+ const bag = inst._zod.bag;
400
+ bag.format = def.format;
401
+ bag.minimum = minimum;
402
+ bag.maximum = maximum;
403
+ });
404
+
405
+ inst._zod.check = (payload) => {
406
+ const input = payload.value;
407
+
408
+ if (input < minimum) {
409
+ payload.issues.push({
410
+ origin: "bigint",
411
+ input,
412
+ code: "too_small",
413
+ minimum: minimum as any,
414
+ inclusive: true,
415
+ inst,
416
+ continue: !def.abort,
417
+ });
418
+ }
419
+
420
+ if (input > maximum) {
421
+ payload.issues.push({
422
+ origin: "bigint",
423
+ input,
424
+ code: "too_big",
425
+ maximum,
426
+ inst,
427
+ } as any);
428
+ }
429
+ };
430
+ }
431
+ );
432
+
433
+ //////////////////////////////////
434
+ ///// $ZodCheckMaxSize /////
435
+ //////////////////////////////////
436
+ export interface $ZodCheckMaxSizeDef extends $ZodCheckDef {
437
+ check: "max_size";
438
+ maximum: number;
439
+ }
440
+
441
+ export interface $ZodCheckMaxSizeInternals<T extends util.HasSize = util.HasSize> extends $ZodCheckInternals<T> {
442
+ def: $ZodCheckMaxSizeDef;
443
+ issc: errors.$ZodIssueTooBig<T>;
444
+ }
445
+
446
+ export interface $ZodCheckMaxSize<T extends util.HasSize = util.HasSize> extends $ZodCheck<T> {
447
+ _zod: $ZodCheckMaxSizeInternals<T>;
448
+ }
449
+
450
+ export const $ZodCheckMaxSize: core.$constructor<$ZodCheckMaxSize> = /*@__PURE__*/ core.$constructor(
451
+ "$ZodCheckMaxSize",
452
+ (inst, def) => {
453
+ $ZodCheck.init(inst, def);
454
+
455
+ inst._zod.when = (payload) => {
456
+ const val = payload.value;
457
+ return !util.nullish(val) && (val as any).size !== undefined;
458
+ };
459
+
460
+ inst._zod.onattach.push((inst) => {
461
+ const curr = (inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY) as number;
462
+ if (def.maximum < curr) inst._zod.bag.maximum = def.maximum;
463
+ });
464
+
465
+ inst._zod.check = (payload) => {
466
+ const input = payload.value;
467
+ const size = input.size;
468
+
469
+ if (size <= def.maximum) return;
470
+ payload.issues.push({
471
+ origin: util.getSizableOrigin(input),
472
+ code: "too_big",
473
+ maximum: def.maximum,
474
+ input,
475
+ inst,
476
+ continue: !def.abort,
477
+ });
478
+ };
479
+ }
480
+ );
481
+
482
+ //////////////////////////////////
483
+ ///// $ZodCheckMinSize /////
484
+ //////////////////////////////////
485
+ export interface $ZodCheckMinSizeDef extends $ZodCheckDef {
486
+ check: "min_size";
487
+ minimum: number;
488
+ }
489
+
490
+ export interface $ZodCheckMinSizeInternals<T extends util.HasSize = util.HasSize> extends $ZodCheckInternals<T> {
491
+ def: $ZodCheckMinSizeDef;
492
+ issc: errors.$ZodIssueTooSmall<T>;
493
+ }
494
+
495
+ export interface $ZodCheckMinSize<T extends util.HasSize = util.HasSize> extends $ZodCheck<T> {
496
+ _zod: $ZodCheckMinSizeInternals<T>;
497
+ }
498
+
499
+ export const $ZodCheckMinSize: core.$constructor<$ZodCheckMinSize> = /*@__PURE__*/ core.$constructor(
500
+ "$ZodCheckMinSize",
501
+ (inst, def) => {
502
+ $ZodCheck.init(inst, def);
503
+
504
+ inst._zod.when = (payload) => {
505
+ const val = payload.value;
506
+ return !util.nullish(val) && (val as any).size !== undefined;
507
+ };
508
+
509
+ inst._zod.onattach.push((inst) => {
510
+ const curr = (inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY) as number;
511
+ if (def.minimum > curr) inst._zod.bag.minimum = def.minimum;
512
+ });
513
+
514
+ inst._zod.check = (payload) => {
515
+ const input = payload.value;
516
+ const size = input.size;
517
+
518
+ if (size >= def.minimum) return;
519
+ payload.issues.push({
520
+ origin: util.getSizableOrigin(input),
521
+ code: "too_small",
522
+ minimum: def.minimum,
523
+ input,
524
+ inst,
525
+ continue: !def.abort,
526
+ });
527
+ };
528
+ }
529
+ );
530
+
531
+ /////////////////////////////////////
532
+ ///// $ZodCheckSizeEquals /////
533
+ /////////////////////////////////////
534
+ export interface $ZodCheckSizeEqualsDef extends $ZodCheckDef {
535
+ check: "size_equals";
536
+ size: number;
537
+ }
538
+
539
+ export interface $ZodCheckSizeEqualsInternals<T extends util.HasSize = util.HasSize> extends $ZodCheckInternals<T> {
540
+ def: $ZodCheckSizeEqualsDef;
541
+ issc: errors.$ZodIssueTooBig<T> | errors.$ZodIssueTooSmall<T>;
542
+ }
543
+
544
+ export interface $ZodCheckSizeEquals<T extends util.HasSize = util.HasSize> extends $ZodCheck<T> {
545
+ _zod: $ZodCheckSizeEqualsInternals<T>;
546
+ }
547
+
548
+ export const $ZodCheckSizeEquals: core.$constructor<$ZodCheckSizeEquals> = /*@__PURE__*/ core.$constructor(
549
+ "$ZodCheckSizeEquals",
550
+ (inst, def) => {
551
+ $ZodCheck.init(inst, def);
552
+
553
+ inst._zod.when = (payload) => {
554
+ const val = payload.value;
555
+ return !util.nullish(val) && (val as any).size !== undefined;
556
+ };
557
+
558
+ inst._zod.onattach.push((inst) => {
559
+ const bag = inst._zod.bag;
560
+ bag.minimum = def.size;
561
+ bag.maximum = def.size;
562
+ bag.size = def.size;
563
+ });
564
+
565
+ inst._zod.check = (payload) => {
566
+ const input = payload.value;
567
+ const size = input.size;
568
+ if (size === def.size) return;
569
+
570
+ const tooBig = size > def.size;
571
+ payload.issues.push({
572
+ origin: util.getSizableOrigin(input),
573
+ ...(tooBig ? { code: "too_big", maximum: def.size } : { code: "too_small", minimum: def.size }),
574
+ inclusive: true,
575
+ exact: true,
576
+ input: payload.value,
577
+ inst,
578
+ continue: !def.abort,
579
+ });
580
+ };
581
+ }
582
+ );
583
+
584
+ //////////////////////////////////
585
+ ///// $ZodCheckMaxLength /////
586
+ //////////////////////////////////
587
+
588
+ export interface $ZodCheckMaxLengthDef extends $ZodCheckDef {
589
+ check: "max_length";
590
+ maximum: number;
591
+ }
592
+
593
+ export interface $ZodCheckMaxLengthInternals<T extends util.HasLength = util.HasLength> extends $ZodCheckInternals<T> {
594
+ def: $ZodCheckMaxLengthDef;
595
+ issc: errors.$ZodIssueTooBig<T>;
596
+ }
597
+
598
+ export interface $ZodCheckMaxLength<T extends util.HasLength = util.HasLength> extends $ZodCheck<T> {
599
+ _zod: $ZodCheckMaxLengthInternals<T>;
600
+ }
601
+
602
+ export const $ZodCheckMaxLength: core.$constructor<$ZodCheckMaxLength> = /*@__PURE__*/ core.$constructor(
603
+ "$ZodCheckMaxLength",
604
+ (inst, def) => {
605
+ $ZodCheck.init(inst, def);
606
+
607
+ inst._zod.when = (payload) => {
608
+ const val = payload.value;
609
+ return !util.nullish(val) && (val as any).length !== undefined;
610
+ };
611
+
612
+ inst._zod.onattach.push((inst) => {
613
+ const curr = (inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY) as number;
614
+ if (def.maximum < curr) inst._zod.bag.maximum = def.maximum;
615
+ });
616
+
617
+ inst._zod.check = (payload) => {
618
+ const input = payload.value;
619
+ const length = input.length;
620
+
621
+ if (length <= def.maximum) return;
622
+ const origin = util.getLengthableOrigin(input);
623
+ payload.issues.push({
624
+ origin,
625
+ code: "too_big",
626
+ maximum: def.maximum,
627
+ inclusive: true,
628
+ input,
629
+ inst,
630
+ continue: !def.abort,
631
+ });
632
+ };
633
+ }
634
+ );
635
+
636
+ //////////////////////////////////
637
+ ///// $ZodCheckMinLength /////
638
+ //////////////////////////////////
639
+ export interface $ZodCheckMinLengthDef extends $ZodCheckDef {
640
+ check: "min_length";
641
+ minimum: number;
642
+ }
643
+
644
+ export interface $ZodCheckMinLengthInternals<T extends util.HasLength = util.HasLength> extends $ZodCheckInternals<T> {
645
+ def: $ZodCheckMinLengthDef;
646
+ issc: errors.$ZodIssueTooSmall<T>;
647
+ }
648
+
649
+ export interface $ZodCheckMinLength<T extends util.HasLength = util.HasLength> extends $ZodCheck<T> {
650
+ _zod: $ZodCheckMinLengthInternals<T>;
651
+ }
652
+
653
+ export const $ZodCheckMinLength: core.$constructor<$ZodCheckMinLength> = /*@__PURE__*/ core.$constructor(
654
+ "$ZodCheckMinLength",
655
+ (inst, def) => {
656
+ $ZodCheck.init(inst, def);
657
+
658
+ inst._zod.when = (payload) => {
659
+ const val = payload.value;
660
+ return !util.nullish(val) && (val as any).length !== undefined;
661
+ };
662
+
663
+ inst._zod.onattach.push((inst) => {
664
+ const curr = (inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY) as number;
665
+ if (def.minimum > curr) inst._zod.bag.minimum = def.minimum;
666
+ });
667
+
668
+ inst._zod.check = (payload) => {
669
+ const input = payload.value;
670
+ const length = input.length;
671
+
672
+ if (length >= def.minimum) return;
673
+ const origin = util.getLengthableOrigin(input);
674
+ payload.issues.push({
675
+ origin,
676
+ code: "too_small",
677
+ minimum: def.minimum,
678
+ inclusive: true,
679
+ input,
680
+ inst,
681
+ continue: !def.abort,
682
+ });
683
+ };
684
+ }
685
+ );
686
+
687
+ /////////////////////////////////////
688
+ ///// $ZodCheckLengthEquals /////
689
+ /////////////////////////////////////
690
+ export interface $ZodCheckLengthEqualsDef extends $ZodCheckDef {
691
+ check: "length_equals";
692
+ length: number;
693
+ }
694
+
695
+ export interface $ZodCheckLengthEqualsInternals<T extends util.HasLength = util.HasLength>
696
+ extends $ZodCheckInternals<T> {
697
+ def: $ZodCheckLengthEqualsDef;
698
+ issc: errors.$ZodIssueTooBig<T> | errors.$ZodIssueTooSmall<T>;
699
+ }
700
+
701
+ export interface $ZodCheckLengthEquals<T extends util.HasLength = util.HasLength> extends $ZodCheck<T> {
702
+ _zod: $ZodCheckLengthEqualsInternals<T>;
703
+ }
704
+
705
+ export const $ZodCheckLengthEquals: core.$constructor<$ZodCheckLengthEquals> = /*@__PURE__*/ core.$constructor(
706
+ "$ZodCheckLengthEquals",
707
+ (inst, def) => {
708
+ $ZodCheck.init(inst, def);
709
+
710
+ inst._zod.when = (payload) => {
711
+ const val = payload.value;
712
+ return !util.nullish(val) && (val as any).length !== undefined;
713
+ };
714
+
715
+ inst._zod.onattach.push((inst) => {
716
+ const bag = inst._zod.bag;
717
+ bag.minimum = def.length;
718
+ bag.maximum = def.length;
719
+ bag.length = def.length;
720
+ });
721
+
722
+ inst._zod.check = (payload) => {
723
+ const input = payload.value;
724
+ const length = input.length;
725
+ if (length === def.length) return;
726
+ const origin = util.getLengthableOrigin(input);
727
+ const tooBig = length > def.length;
728
+ payload.issues.push({
729
+ origin,
730
+ ...(tooBig ? { code: "too_big", maximum: def.length } : { code: "too_small", minimum: def.length }),
731
+ inclusive: true,
732
+ exact: true,
733
+ input: payload.value,
734
+ inst,
735
+ continue: !def.abort,
736
+ });
737
+ };
738
+ }
739
+ );
740
+
741
+ /////////////////////////////////////////////
742
+ ///// $ZodCheckStringFormatRegex /////
743
+ /////////////////////////////////////////////
744
+ export type $ZodStringFormats =
745
+ | "email"
746
+ | "url"
747
+ | "emoji"
748
+ | "uuid"
749
+ | "guid"
750
+ | "nanoid"
751
+ | "cuid"
752
+ | "cuid2"
753
+ | "ulid"
754
+ | "xid"
755
+ | "ksuid"
756
+ | "datetime"
757
+ | "date"
758
+ | "time"
759
+ | "duration"
760
+ | "ipv4"
761
+ | "ipv6"
762
+ | "cidrv4"
763
+ | "cidrv6"
764
+ | "base64"
765
+ | "base64url"
766
+ | "json_string"
767
+ | "e164"
768
+ | "lowercase"
769
+ | "uppercase"
770
+ | "regex"
771
+ | "jwt"
772
+ | "starts_with"
773
+ | "ends_with"
774
+ | "includes";
775
+ export interface $ZodCheckStringFormatDef<Format extends string = string> extends $ZodCheckDef {
776
+ check: "string_format";
777
+ format: Format;
778
+ pattern?: RegExp | undefined;
779
+ }
780
+
781
+ export interface $ZodCheckStringFormatInternals extends $ZodCheckInternals<string> {
782
+ def: $ZodCheckStringFormatDef;
783
+ issc: errors.$ZodIssueInvalidStringFormat;
784
+ }
785
+
786
+ export interface $ZodCheckStringFormat extends $ZodCheck<string> {
787
+ _zod: $ZodCheckStringFormatInternals;
788
+ }
789
+
790
+ export const $ZodCheckStringFormat: core.$constructor<$ZodCheckStringFormat> = /*@__PURE__*/ core.$constructor(
791
+ "$ZodCheckStringFormat",
792
+ (inst, def) => {
793
+ $ZodCheck.init(inst, def);
794
+
795
+ inst._zod.onattach.push((inst) => {
796
+ const bag = inst._zod.bag as schemas.$ZodStringInternals<unknown>["bag"];
797
+ bag.format = def.format;
798
+ if (def.pattern) {
799
+ bag.patterns ??= new Set();
800
+ bag.patterns.add(def.pattern);
801
+ }
802
+ });
803
+
804
+ if (def.pattern)
805
+ inst._zod.check ??= (payload) => {
806
+ def.pattern!.lastIndex = 0;
807
+ if (def.pattern!.test(payload.value)) return;
808
+ payload.issues.push({
809
+ origin: "string",
810
+ code: "invalid_format",
811
+ format: def.format,
812
+ input: payload.value,
813
+ ...(def.pattern ? { pattern: def.pattern.toString() } : {}),
814
+ inst,
815
+ continue: !def.abort,
816
+ });
817
+ };
818
+ else inst._zod.check ??= () => {};
819
+ }
820
+ );
821
+
822
+ ////////////////////////////////
823
+ ///// $ZodCheckRegex /////
824
+ ////////////////////////////////
825
+ export interface $ZodCheckRegexDef extends $ZodCheckStringFormatDef {
826
+ format: "regex";
827
+ pattern: RegExp;
828
+ }
829
+
830
+ export interface $ZodCheckRegexInternals extends $ZodCheckInternals<string> {
831
+ def: $ZodCheckRegexDef;
832
+ issc: errors.$ZodIssueInvalidStringFormat;
833
+ }
834
+
835
+ export interface $ZodCheckRegex extends $ZodCheck<string> {
836
+ _zod: $ZodCheckRegexInternals;
837
+ }
838
+
839
+ export const $ZodCheckRegex: core.$constructor<$ZodCheckRegex> = /*@__PURE__*/ core.$constructor(
840
+ "$ZodCheckRegex",
841
+ (inst, def) => {
842
+ $ZodCheckStringFormat.init(inst, def);
843
+
844
+ inst._zod.check = (payload) => {
845
+ def.pattern.lastIndex = 0;
846
+ if (def.pattern.test(payload.value)) return;
847
+ payload.issues.push({
848
+ origin: "string",
849
+ code: "invalid_format",
850
+ format: "regex",
851
+ input: payload.value,
852
+ pattern: def.pattern.toString(),
853
+ inst,
854
+ continue: !def.abort,
855
+ });
856
+ };
857
+ }
858
+ );
859
+
860
+ ///////////////////////////////////
861
+ ///// $ZodCheckJSONString /////
862
+ ///////////////////////////////////
863
+ // interface $ZodCheckJSONStringDef extends $ZodCheckStringFormatDef<"json_string"> {
864
+ // // check: "string_format";
865
+ // // format: "json_string";
866
+ // // error?: errors.$ZodErrorMap<errors.$ZodIssueInvalidStringFormat> | undefined;
867
+ // }
868
+
869
+ // export interface $ZodCheckJSONString extends $ZodCheckStringFormat {
870
+ // _def: $ZodCheckJSONStringDef;
871
+ // }
872
+
873
+ // export const $ZodCheckJSONString: core.$constructor<$ZodCheckJSONString> = /*@__PURE__*/ core.$constructor(
874
+ // "$ZodCheckJSONString",
875
+ // (inst, def) => {
876
+ // $ZodCheck.init(inst, def);
877
+
878
+ // inst._zod.check = (payload) => {
879
+ // try {
880
+ // JSON.parse(payload.value);
881
+ // return;
882
+ // } catch (_) {
883
+ // payload.issues.push({
884
+ // origin: "string",
885
+ // code: "invalid_format",
886
+ // format: def.format,
887
+ // input: payload.value,
888
+ // inst,
889
+ // continue: !def.abort,
890
+ // });
891
+ // }
892
+ // };
893
+ // }
894
+ // );
895
+
896
+ //////////////////////////////////////
897
+ ///// $ZodCheckLowerCase /////
898
+ //////////////////////////////////////
899
+ export interface $ZodCheckLowerCaseDef extends $ZodCheckStringFormatDef<"lowercase"> {}
900
+
901
+ export interface $ZodCheckLowerCaseInternals extends $ZodCheckInternals<string> {
902
+ def: $ZodCheckLowerCaseDef;
903
+ issc: errors.$ZodIssueInvalidStringFormat;
904
+ }
905
+
906
+ export interface $ZodCheckLowerCase extends $ZodCheck<string> {
907
+ _zod: $ZodCheckLowerCaseInternals;
908
+ }
909
+
910
+ export const $ZodCheckLowerCase: core.$constructor<$ZodCheckLowerCase> = /*@__PURE__*/ core.$constructor(
911
+ "$ZodCheckLowerCase",
912
+ (inst, def) => {
913
+ def.pattern ??= regexes.lowercase;
914
+ $ZodCheckStringFormat.init(inst, def);
915
+ }
916
+ );
917
+
918
+ //////////////////////////////////////
919
+ ///// $ZodCheckUpperCase /////
920
+ //////////////////////////////////////
921
+ export interface $ZodCheckUpperCaseDef extends $ZodCheckStringFormatDef<"uppercase"> {}
922
+
923
+ export interface $ZodCheckUpperCaseInternals extends $ZodCheckInternals<string> {
924
+ def: $ZodCheckUpperCaseDef;
925
+ issc: errors.$ZodIssueInvalidStringFormat;
926
+ }
927
+
928
+ export interface $ZodCheckUpperCase extends $ZodCheck<string> {
929
+ _zod: $ZodCheckUpperCaseInternals;
930
+ }
931
+
932
+ export const $ZodCheckUpperCase: core.$constructor<$ZodCheckUpperCase> = /*@__PURE__*/ core.$constructor(
933
+ "$ZodCheckUpperCase",
934
+ (inst, def) => {
935
+ def.pattern ??= regexes.uppercase;
936
+ $ZodCheckStringFormat.init(inst, def);
937
+ }
938
+ );
939
+
940
+ ///////////////////////////////////
941
+ ///// $ZodCheckIncludes /////
942
+ ///////////////////////////////////
943
+ export interface $ZodCheckIncludesDef extends $ZodCheckStringFormatDef<"includes"> {
944
+ includes: string;
945
+ position?: number | undefined;
946
+ }
947
+
948
+ export interface $ZodCheckIncludesInternals extends $ZodCheckInternals<string> {
949
+ def: $ZodCheckIncludesDef;
950
+ issc: errors.$ZodIssueInvalidStringFormat;
951
+ }
952
+
953
+ export interface $ZodCheckIncludes extends $ZodCheck<string> {
954
+ _zod: $ZodCheckIncludesInternals;
955
+ }
956
+
957
+ export const $ZodCheckIncludes: core.$constructor<$ZodCheckIncludes> = /*@__PURE__*/ core.$constructor(
958
+ "$ZodCheckIncludes",
959
+ (inst, def) => {
960
+ $ZodCheck.init(inst, def);
961
+
962
+ const escapedRegex = util.escapeRegex(def.includes);
963
+ const pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position}}${escapedRegex}` : escapedRegex);
964
+ def.pattern = pattern;
965
+ inst._zod.onattach.push((inst) => {
966
+ const bag = inst._zod.bag as schemas.$ZodStringInternals<unknown>["bag"];
967
+ bag.patterns ??= new Set();
968
+ bag.patterns.add(pattern);
969
+ });
970
+
971
+ inst._zod.check = (payload) => {
972
+ if (payload.value.includes(def.includes, def.position)) return;
973
+ payload.issues.push({
974
+ origin: "string",
975
+ code: "invalid_format",
976
+ format: "includes",
977
+ includes: def.includes,
978
+ input: payload.value,
979
+ inst,
980
+ continue: !def.abort,
981
+ });
982
+ };
983
+ }
984
+ );
985
+
986
+ /////////////////////////////////////
987
+ ///// $ZodCheckStartsWith /////
988
+ /////////////////////////////////////
989
+ export interface $ZodCheckStartsWithDef extends $ZodCheckStringFormatDef<"starts_with"> {
990
+ prefix: string;
991
+ }
992
+
993
+ export interface $ZodCheckStartsWithInternals extends $ZodCheckInternals<string> {
994
+ def: $ZodCheckStartsWithDef;
995
+ issc: errors.$ZodIssueInvalidStringFormat;
996
+ }
997
+
998
+ export interface $ZodCheckStartsWith extends $ZodCheck<string> {
999
+ _zod: $ZodCheckStartsWithInternals;
1000
+ }
1001
+
1002
+ export const $ZodCheckStartsWith: core.$constructor<$ZodCheckStartsWith> = /*@__PURE__*/ core.$constructor(
1003
+ "$ZodCheckStartsWith",
1004
+ (inst, def) => {
1005
+ $ZodCheck.init(inst, def);
1006
+
1007
+ const pattern = new RegExp(`^${util.escapeRegex(def.prefix)}.*`);
1008
+ def.pattern ??= pattern;
1009
+ inst._zod.onattach.push((inst) => {
1010
+ const bag = inst._zod.bag as schemas.$ZodStringInternals<unknown>["bag"];
1011
+ bag.patterns ??= new Set();
1012
+ bag.patterns.add(pattern);
1013
+ });
1014
+
1015
+ inst._zod.check = (payload) => {
1016
+ if (payload.value.startsWith(def.prefix)) return;
1017
+ payload.issues.push({
1018
+ origin: "string",
1019
+ code: "invalid_format",
1020
+ format: "starts_with",
1021
+ prefix: def.prefix,
1022
+ input: payload.value,
1023
+ inst,
1024
+ continue: !def.abort,
1025
+ });
1026
+ };
1027
+ }
1028
+ );
1029
+
1030
+ //////////////////////////////////
1031
+ ///// $ZodCheckEndsWith /////
1032
+ //////////////////////////////////
1033
+ export interface $ZodCheckEndsWithDef extends $ZodCheckStringFormatDef<"ends_with"> {
1034
+ suffix: string;
1035
+ }
1036
+
1037
+ export interface $ZodCheckEndsWithInternals extends $ZodCheckInternals<string> {
1038
+ def: $ZodCheckEndsWithDef;
1039
+ issc: errors.$ZodIssueInvalidStringFormat;
1040
+ }
1041
+
1042
+ export interface $ZodCheckEndsWith extends $ZodCheckInternals<string> {
1043
+ _zod: $ZodCheckEndsWithInternals;
1044
+ }
1045
+
1046
+ export const $ZodCheckEndsWith: core.$constructor<$ZodCheckEndsWith> = /*@__PURE__*/ core.$constructor(
1047
+ "$ZodCheckEndsWith",
1048
+ (inst, def) => {
1049
+ $ZodCheck.init(inst, def);
1050
+
1051
+ const pattern = new RegExp(`.*${util.escapeRegex(def.suffix)}$`);
1052
+ def.pattern ??= pattern;
1053
+ inst._zod.onattach.push((inst) => {
1054
+ const bag = inst._zod.bag as schemas.$ZodStringInternals<unknown>["bag"];
1055
+ bag.patterns ??= new Set();
1056
+ bag.patterns.add(pattern);
1057
+ });
1058
+
1059
+ inst._zod.check = (payload) => {
1060
+ if (payload.value.endsWith(def.suffix)) return;
1061
+ payload.issues.push({
1062
+ origin: "string",
1063
+ code: "invalid_format",
1064
+ format: "ends_with",
1065
+ suffix: def.suffix,
1066
+ input: payload.value,
1067
+ inst,
1068
+ continue: !def.abort,
1069
+ });
1070
+ };
1071
+ }
1072
+ );
1073
+
1074
+ ///////////////////////////////////
1075
+ ///// $ZodCheckProperty /////
1076
+ ///////////////////////////////////
1077
+ function handleCheckPropertyResult(
1078
+ result: schemas.ParsePayload<unknown>,
1079
+ payload: schemas.ParsePayload<unknown>,
1080
+ property: string
1081
+ ) {
1082
+ if (result.issues.length) {
1083
+ payload.issues.push(...util.prefixIssues(property, result.issues));
1084
+ }
1085
+ }
1086
+ export interface $ZodCheckPropertyDef extends $ZodCheckDef {
1087
+ check: "property";
1088
+ property: string;
1089
+ schema: schemas.$ZodType;
1090
+ }
1091
+
1092
+ export interface $ZodCheckPropertyInternals<T extends object = object> extends $ZodCheckInternals<T> {
1093
+ def: $ZodCheckPropertyDef;
1094
+ issc: errors.$ZodIssue;
1095
+ }
1096
+
1097
+ export interface $ZodCheckProperty<T extends object = object> extends $ZodCheck<T> {
1098
+ _zod: $ZodCheckPropertyInternals<T>;
1099
+ }
1100
+
1101
+ export const $ZodCheckProperty: core.$constructor<$ZodCheckProperty> = /*@__PURE__*/ core.$constructor(
1102
+ "$ZodCheckProperty",
1103
+ (inst, def) => {
1104
+ $ZodCheck.init(inst, def);
1105
+
1106
+ inst._zod.check = (payload) => {
1107
+ const result = def.schema._zod.run(
1108
+ {
1109
+ value: (payload.value as any)[def.property],
1110
+ issues: [],
1111
+ },
1112
+ {}
1113
+ );
1114
+
1115
+ if (result instanceof Promise) {
1116
+ return result.then((result) => handleCheckPropertyResult(result, payload, def.property));
1117
+ }
1118
+
1119
+ handleCheckPropertyResult(result, payload, def.property);
1120
+ return;
1121
+ };
1122
+ }
1123
+ );
1124
+
1125
+ ///////////////////////////////////
1126
+ ///// $ZodCheckMimeType /////
1127
+ ///////////////////////////////////
1128
+ export interface $ZodCheckMimeTypeDef extends $ZodCheckDef {
1129
+ check: "mime_type";
1130
+ mime: util.MimeTypes[];
1131
+ }
1132
+
1133
+ export interface $ZodCheckMimeTypeInternals<T extends File = File> extends $ZodCheckInternals<T> {
1134
+ def: $ZodCheckMimeTypeDef;
1135
+ issc: errors.$ZodIssueInvalidValue;
1136
+ }
1137
+
1138
+ export interface $ZodCheckMimeType<T extends File = File> extends $ZodCheck<T> {
1139
+ _zod: $ZodCheckMimeTypeInternals<T>;
1140
+ }
1141
+
1142
+ export const $ZodCheckMimeType: core.$constructor<$ZodCheckMimeType> = /*@__PURE__*/ core.$constructor(
1143
+ "$ZodCheckMimeType",
1144
+ (inst, def) => {
1145
+ $ZodCheck.init(inst, def);
1146
+ const mimeSet = new Set(def.mime);
1147
+ inst._zod.onattach.push((inst) => {
1148
+ inst._zod.bag.mime = def.mime;
1149
+ });
1150
+ inst._zod.check = (payload) => {
1151
+ if (mimeSet.has(payload.value.type)) return;
1152
+ payload.issues.push({
1153
+ code: "invalid_value",
1154
+ values: def.mime,
1155
+ input: payload.value.type,
1156
+ inst,
1157
+ });
1158
+ };
1159
+ }
1160
+ );
1161
+
1162
+ ///////////////////////////////////
1163
+ ///// $ZodCheckFileName /////
1164
+ ///////////////////////////////////
1165
+ // interface $ZodCheckFileNameDef extends $ZodCheckDef {
1166
+ // check: "file_name";
1167
+ // fileName: string;
1168
+ // error?: errors.$ZodErrorMap<errors.$ZodIssueInvalidType> | undefined;
1169
+ // }
1170
+ // export interface $ZodCheckFileName<T extends File = File>
1171
+ // extends $ZodCheckInternals<T> {
1172
+ // _def: $ZodCheckFileNameDef;
1173
+ // }
1174
+
1175
+ // export const $ZodCheckFileName: core.$constructor<$ZodCheckFileName> =
1176
+ // core.$constructor("$ZodCheckFileName", (inst, def) => {
1177
+ // $ZodCheck.init(inst, def);
1178
+
1179
+ // inst._zod.check = (payload) => {
1180
+ // if (def.fileName === payload.value.name) return;
1181
+ // payload.issues.push({
1182
+ // origin: "file",
1183
+ // code: "invalid_value",
1184
+ // options: [def.fileName],
1185
+ // input: payload.value,
1186
+ // path: ["name"],
1187
+ // inst,
1188
+ // });
1189
+ // };
1190
+ // });
1191
+
1192
+ ///////////////////////////////////
1193
+ ///// $ZodCheckOverwrite /////
1194
+ ///////////////////////////////////
1195
+ export interface $ZodCheckOverwriteDef<T = unknown> extends $ZodCheckDef {
1196
+ check: "overwrite";
1197
+ tx(value: T): T;
1198
+ }
1199
+
1200
+ export interface $ZodCheckOverwriteInternals<T = unknown> extends $ZodCheckInternals<T> {
1201
+ def: $ZodCheckOverwriteDef<T>;
1202
+ issc: never;
1203
+ }
1204
+
1205
+ export interface $ZodCheckOverwrite<T = unknown> extends $ZodCheck<T> {
1206
+ _zod: $ZodCheckOverwriteInternals<T>;
1207
+ }
1208
+
1209
+ export const $ZodCheckOverwrite: core.$constructor<$ZodCheckOverwrite> = /*@__PURE__*/ core.$constructor(
1210
+ "$ZodCheckOverwrite",
1211
+ (inst, def) => {
1212
+ $ZodCheck.init(inst, def);
1213
+
1214
+ inst._zod.check = (payload) => {
1215
+ payload.value = def.tx(payload.value);
1216
+ };
1217
+ }
1218
+ );
1219
+
1220
+ // ///////////////////////////////
1221
+ // ///// $ZodCheckTrim /////
1222
+ // ///////////////////////////////
1223
+ // export interface $ZodCheckTrimDef extends $ZodCheckDef {
1224
+ // check: "trim";
1225
+ // error?: errors.$ZodErrorMap<never> | undefined;
1226
+ // }
1227
+ // export interface $ZodCheckTrim extends $ZodCheckInternals<string> {
1228
+ // _def: $ZodCheckTrimDef;
1229
+ // }
1230
+
1231
+ // export const $ZodCheckTrim: core.$constructor<$ZodCheckTrim> =
1232
+ // core.$constructor("$ZodCheckTrim", (inst, def) => {
1233
+ // $ZodCheck.init(inst, def);
1234
+
1235
+ // inst._zod.check = (payload) => {
1236
+ // payload.value = payload.value.trim();
1237
+ // };
1238
+ // });
1239
+
1240
+ // //////////////////////////////////////
1241
+ // ///// $ZodCheckNormalize /////
1242
+ // //////////////////////////////////////
1243
+ // interface $ZodCheckNormalizeDef extends $ZodCheckDef {
1244
+ // check: "normalize";
1245
+ // error?: errors.$ZodErrorMap<never> | undefined;
1246
+ // }
1247
+
1248
+ // export interface $ZodCheckNormalize extends $ZodCheckInternals<string> {
1249
+ // _def: $ZodCheckNormalizeDef;
1250
+ // }
1251
+
1252
+ // export const $ZodCheckNormalize: core.$constructor<$ZodCheckNormalize> =
1253
+ // core.$constructor("$ZodCheckNormalize", (inst, def) => {
1254
+ // $ZodCheck.init(inst, def);
1255
+
1256
+ // inst._zod.check = (payload) => {
1257
+ // payload.value = payload.value.normalize();
1258
+ // };
1259
+ // });
1260
+
1261
+ export type $ZodChecks =
1262
+ | $ZodCheckLessThan
1263
+ | $ZodCheckGreaterThan
1264
+ | $ZodCheckMultipleOf
1265
+ | $ZodCheckNumberFormat
1266
+ | $ZodCheckBigIntFormat
1267
+ | $ZodCheckMaxSize
1268
+ | $ZodCheckMinSize
1269
+ | $ZodCheckSizeEquals
1270
+ | $ZodCheckMaxLength
1271
+ | $ZodCheckMinLength
1272
+ | $ZodCheckLengthEquals
1273
+ | $ZodCheckStringFormat
1274
+ | $ZodCheckProperty
1275
+ | $ZodCheckMimeType
1276
+ | $ZodCheckOverwrite;
1277
+
1278
+ export type $ZodStringFormatChecks =
1279
+ | $ZodCheckRegex
1280
+ | $ZodCheckLowerCase
1281
+ | $ZodCheckUpperCase
1282
+ | $ZodCheckIncludes
1283
+ | $ZodCheckStartsWith
1284
+ | $ZodCheckEndsWith
1285
+ | schemas.$ZodStringFormatTypes; // union of string format schema types