zod 4.5.3 → 4.6.0

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 (348) hide show
  1. package/compile.cjs +19 -0
  2. package/index.cjs +19 -0
  3. package/locales/index.cjs +19 -0
  4. package/mini/index.cjs +19 -0
  5. package/package.json +8 -7
  6. package/src/v3/helpers/errorUtil.ts +1 -1
  7. package/src/v4/classic/checks.ts +0 -1
  8. package/src/v4/classic/external.ts +2 -0
  9. package/src/v4/classic/from-json-schema.ts +248 -25
  10. package/src/v4/classic/schemas.ts +255 -164
  11. package/src/v4/classic/tests/assignability.test.ts +59 -9
  12. package/src/v4/classic/tests/bigint.test.ts +6 -0
  13. package/src/v4/classic/tests/continuability.test.ts +2 -2
  14. package/src/v4/classic/tests/cyclic-data.test.ts +316 -0
  15. package/src/v4/classic/tests/default.test.ts +46 -0
  16. package/src/v4/classic/tests/enum.test.ts +9 -0
  17. package/src/v4/classic/tests/error.test.ts +130 -1
  18. package/src/v4/classic/tests/firstparty.test.ts +4 -0
  19. package/src/v4/classic/tests/from-json-schema.test.ts +157 -0
  20. package/src/v4/classic/tests/iban.test.ts +81 -0
  21. package/src/v4/classic/tests/instance-footprint.test.ts +18 -2
  22. package/src/v4/classic/tests/instanceof.test.ts +27 -7
  23. package/src/v4/classic/tests/issue-schema.test.ts +88 -56
  24. package/src/v4/classic/tests/object.test.ts +56 -0
  25. package/src/v4/classic/tests/optin-ladder.test.ts +3 -2
  26. package/src/v4/classic/tests/properties.test.ts +225 -0
  27. package/src/v4/classic/tests/recursive-types.test.ts +1 -1
  28. package/src/v4/classic/tests/standard-schema.test.ts +19 -0
  29. package/src/v4/classic/tests/string.test.ts +25 -0
  30. package/src/v4/classic/tests/template-literal.test.ts +33 -1
  31. package/src/v4/classic/tests/to-json-schema.test.ts +147 -3
  32. package/src/v4/classic/tests/validate.test.ts +569 -0
  33. package/src/v4/core/api.ts +30 -6
  34. package/src/v4/core/checks.ts +1 -101
  35. package/src/v4/core/compile.ts +193 -81
  36. package/src/v4/core/doc.ts +6 -2
  37. package/src/v4/core/errors.ts +3 -6
  38. package/src/v4/core/json-schema-generator.ts +2 -2
  39. package/src/v4/core/json-schema-processors.ts +226 -68
  40. package/src/v4/core/memoizer.ts +162 -36
  41. package/src/v4/core/parse.ts +37 -16
  42. package/src/v4/core/regexes.ts +10 -4
  43. package/src/v4/core/schemas.ts +314 -83
  44. package/src/v4/core/tests/cached.test.ts +54 -0
  45. package/src/v4/core/tests/compile-generative.test.ts +445 -0
  46. package/src/v4/core/tests/compile.test.ts +222 -2
  47. package/src/v4/core/tests/email-regex.test.ts +140 -0
  48. package/src/v4/core/tests/polyfill-collision.test.ts +46 -0
  49. package/src/v4/core/to-json-schema.ts +10 -8
  50. package/src/v4/core/util.ts +222 -147
  51. package/src/v4/core/versions.ts +2 -2
  52. package/src/v4/core/visit.ts +11 -0
  53. package/src/v4/locales/ar.ts +1 -0
  54. package/src/v4/locales/az.ts +1 -0
  55. package/src/v4/locales/be.ts +1 -0
  56. package/src/v4/locales/bg.ts +1 -0
  57. package/src/v4/locales/bn.ts +1 -0
  58. package/src/v4/locales/ca.ts +1 -0
  59. package/src/v4/locales/ckb.ts +1 -0
  60. package/src/v4/locales/cs.ts +1 -0
  61. package/src/v4/locales/da.ts +1 -0
  62. package/src/v4/locales/de.ts +1 -0
  63. package/src/v4/locales/el.ts +1 -0
  64. package/src/v4/locales/en.ts +1 -0
  65. package/src/v4/locales/eo.ts +1 -0
  66. package/src/v4/locales/es.ts +1 -0
  67. package/src/v4/locales/fa.ts +1 -0
  68. package/src/v4/locales/fi.ts +1 -0
  69. package/src/v4/locales/fr-CA.ts +1 -0
  70. package/src/v4/locales/fr.ts +1 -0
  71. package/src/v4/locales/gu.ts +1 -0
  72. package/src/v4/locales/he.ts +1 -0
  73. package/src/v4/locales/hi.ts +1 -0
  74. package/src/v4/locales/hr.ts +1 -0
  75. package/src/v4/locales/hu.ts +1 -0
  76. package/src/v4/locales/hy.ts +1 -0
  77. package/src/v4/locales/id.ts +1 -0
  78. package/src/v4/locales/is.ts +1 -0
  79. package/src/v4/locales/it.ts +1 -0
  80. package/src/v4/locales/ja.ts +1 -0
  81. package/src/v4/locales/ka.ts +1 -0
  82. package/src/v4/locales/km.ts +1 -0
  83. package/src/v4/locales/kn.ts +1 -0
  84. package/src/v4/locales/ko.ts +1 -0
  85. package/src/v4/locales/lt.ts +1 -0
  86. package/src/v4/locales/mk.ts +1 -0
  87. package/src/v4/locales/ms.ts +1 -0
  88. package/src/v4/locales/ne.ts +1 -0
  89. package/src/v4/locales/nl.ts +1 -0
  90. package/src/v4/locales/nn.ts +1 -0
  91. package/src/v4/locales/no.ts +1 -0
  92. package/src/v4/locales/ota.ts +1 -0
  93. package/src/v4/locales/pl.ts +1 -0
  94. package/src/v4/locales/ps.ts +1 -0
  95. package/src/v4/locales/pt-BR.ts +1 -0
  96. package/src/v4/locales/pt.ts +1 -0
  97. package/src/v4/locales/ro.ts +1 -0
  98. package/src/v4/locales/ru.ts +1 -0
  99. package/src/v4/locales/sk.ts +1 -0
  100. package/src/v4/locales/sl.ts +1 -0
  101. package/src/v4/locales/sv.ts +1 -0
  102. package/src/v4/locales/ta.ts +1 -0
  103. package/src/v4/locales/th.ts +1 -0
  104. package/src/v4/locales/tk.ts +1 -0
  105. package/src/v4/locales/tr.ts +1 -0
  106. package/src/v4/locales/uk.ts +1 -0
  107. package/src/v4/locales/ur.ts +1 -0
  108. package/src/v4/locales/uz.ts +1 -0
  109. package/src/v4/locales/vi.ts +1 -0
  110. package/src/v4/locales/yo.ts +1 -0
  111. package/src/v4/locales/zh-CN.ts +1 -0
  112. package/src/v4/locales/zh-TW.ts +1 -0
  113. package/src/v4/mini/checks.ts +0 -1
  114. package/src/v4/mini/external.ts +2 -0
  115. package/src/v4/mini/schemas.ts +38 -2
  116. package/src/v4/mini/tests/checks.test.ts +1 -1
  117. package/src/v4/mini/tests/computed.test.ts +11 -17
  118. package/src/v4/mini/tests/index.test.ts +8 -0
  119. package/src/v4/mini/tests/string.test.ts +16 -0
  120. package/v3/ZodError.cjs +19 -0
  121. package/v3/errors.cjs +19 -0
  122. package/v3/external.cjs +19 -0
  123. package/v3/helpers/enumUtil.cjs +19 -0
  124. package/v3/helpers/errorUtil.cjs +20 -1
  125. package/v3/helpers/errorUtil.js +1 -1
  126. package/v3/helpers/parseUtil.cjs +19 -0
  127. package/v3/helpers/partialUtil.cjs +19 -0
  128. package/v3/helpers/typeAliases.cjs +19 -0
  129. package/v3/helpers/util.cjs +19 -0
  130. package/v3/index.cjs +19 -0
  131. package/v3/standard-schema.cjs +19 -0
  132. package/v3/types.cjs +19 -0
  133. package/v4/classic/checks.cjs +20 -2
  134. package/v4/classic/checks.d.cts +1 -1
  135. package/v4/classic/checks.d.ts +1 -1
  136. package/v4/classic/checks.js +1 -1
  137. package/v4/classic/coerce.cjs +19 -0
  138. package/v4/classic/compat.cjs +19 -0
  139. package/v4/classic/deep-partial.cjs +19 -0
  140. package/v4/classic/errors.cjs +19 -0
  141. package/v4/classic/external.cjs +22 -1
  142. package/v4/classic/external.d.cts +1 -1
  143. package/v4/classic/external.d.ts +1 -1
  144. package/v4/classic/external.js +1 -1
  145. package/v4/classic/from-json-schema.cjs +264 -24
  146. package/v4/classic/from-json-schema.js +245 -24
  147. package/v4/classic/in-out.cjs +19 -0
  148. package/v4/classic/index.cjs +19 -0
  149. package/v4/classic/iso.cjs +19 -0
  150. package/v4/classic/parse.cjs +19 -0
  151. package/v4/classic/schemas.cjs +100 -31
  152. package/v4/classic/schemas.d.cts +17 -1
  153. package/v4/classic/schemas.d.ts +17 -1
  154. package/v4/classic/schemas.js +77 -29
  155. package/v4/core/api.cjs +37 -2
  156. package/v4/core/api.d.cts +6 -4
  157. package/v4/core/api.d.ts +6 -4
  158. package/v4/core/api.js +17 -2
  159. package/v4/core/checks.cjs +19 -96
  160. package/v4/core/checks.d.cts +1 -1
  161. package/v4/core/checks.d.ts +1 -1
  162. package/v4/core/checks.js +0 -96
  163. package/v4/core/compile.cjs +164 -65
  164. package/v4/core/compile.d.cts +18 -4
  165. package/v4/core/compile.d.ts +18 -4
  166. package/v4/core/compile.js +145 -66
  167. package/v4/core/core.cjs +19 -0
  168. package/v4/core/doc.cjs +26 -2
  169. package/v4/core/doc.js +7 -2
  170. package/v4/core/errors.cjs +21 -5
  171. package/v4/core/errors.js +2 -5
  172. package/v4/core/index.cjs +19 -0
  173. package/v4/core/json-schema-generator.cjs +20 -1
  174. package/v4/core/json-schema-generator.js +2 -2
  175. package/v4/core/json-schema-processors.cjs +215 -63
  176. package/v4/core/json-schema-processors.d.cts +17 -0
  177. package/v4/core/json-schema-processors.d.ts +17 -0
  178. package/v4/core/json-schema-processors.js +195 -64
  179. package/v4/core/json-schema.cjs +19 -0
  180. package/v4/core/memoizer.cjs +204 -36
  181. package/v4/core/memoizer.js +162 -36
  182. package/v4/core/parse.cjs +56 -16
  183. package/v4/core/parse.js +37 -16
  184. package/v4/core/regexes.cjs +29 -6
  185. package/v4/core/regexes.d.cts +2 -0
  186. package/v4/core/regexes.d.ts +2 -0
  187. package/v4/core/regexes.js +8 -4
  188. package/v4/core/registries.cjs +19 -0
  189. package/v4/core/schemas.cjs +285 -66
  190. package/v4/core/schemas.d.cts +34 -3
  191. package/v4/core/schemas.d.ts +34 -3
  192. package/v4/core/schemas.js +264 -65
  193. package/v4/core/standard-schema.cjs +19 -0
  194. package/v4/core/to-json-schema.cjs +29 -7
  195. package/v4/core/to-json-schema.d.cts +7 -3
  196. package/v4/core/to-json-schema.d.ts +7 -3
  197. package/v4/core/to-json-schema.js +8 -7
  198. package/v4/core/util.cjs +181 -143
  199. package/v4/core/util.d.cts +25 -4
  200. package/v4/core/util.d.ts +25 -4
  201. package/v4/core/util.js +160 -143
  202. package/v4/core/versions.cjs +21 -2
  203. package/v4/core/versions.d.cts +1 -1
  204. package/v4/core/versions.d.ts +1 -1
  205. package/v4/core/versions.js +2 -2
  206. package/v4/core/visit.cjs +31 -0
  207. package/v4/core/visit.js +12 -0
  208. package/v4/index.cjs +19 -0
  209. package/v4/locales/ar.cjs +1 -0
  210. package/v4/locales/ar.js +1 -0
  211. package/v4/locales/az.cjs +1 -0
  212. package/v4/locales/az.js +1 -0
  213. package/v4/locales/be.cjs +1 -0
  214. package/v4/locales/be.js +1 -0
  215. package/v4/locales/bg.cjs +1 -0
  216. package/v4/locales/bg.js +1 -0
  217. package/v4/locales/bn.cjs +1 -0
  218. package/v4/locales/bn.js +1 -0
  219. package/v4/locales/ca.cjs +1 -0
  220. package/v4/locales/ca.js +1 -0
  221. package/v4/locales/ckb.cjs +1 -0
  222. package/v4/locales/ckb.js +1 -0
  223. package/v4/locales/cs.cjs +1 -0
  224. package/v4/locales/cs.js +1 -0
  225. package/v4/locales/da.cjs +1 -0
  226. package/v4/locales/da.js +1 -0
  227. package/v4/locales/de.cjs +1 -0
  228. package/v4/locales/de.js +1 -0
  229. package/v4/locales/el.cjs +1 -0
  230. package/v4/locales/el.js +1 -0
  231. package/v4/locales/en.cjs +1 -0
  232. package/v4/locales/en.js +1 -0
  233. package/v4/locales/eo.cjs +1 -0
  234. package/v4/locales/eo.js +1 -0
  235. package/v4/locales/es.cjs +1 -0
  236. package/v4/locales/es.js +1 -0
  237. package/v4/locales/fa.cjs +1 -0
  238. package/v4/locales/fa.js +1 -0
  239. package/v4/locales/fi.cjs +1 -0
  240. package/v4/locales/fi.js +1 -0
  241. package/v4/locales/fr-CA.cjs +1 -0
  242. package/v4/locales/fr-CA.js +1 -0
  243. package/v4/locales/fr.cjs +1 -0
  244. package/v4/locales/fr.js +1 -0
  245. package/v4/locales/gu.cjs +1 -0
  246. package/v4/locales/gu.js +1 -0
  247. package/v4/locales/he.cjs +1 -0
  248. package/v4/locales/he.js +1 -0
  249. package/v4/locales/hi.cjs +1 -0
  250. package/v4/locales/hi.js +1 -0
  251. package/v4/locales/hr.cjs +1 -0
  252. package/v4/locales/hr.js +1 -0
  253. package/v4/locales/hu.cjs +1 -0
  254. package/v4/locales/hu.js +1 -0
  255. package/v4/locales/hy.cjs +1 -0
  256. package/v4/locales/hy.js +1 -0
  257. package/v4/locales/id.cjs +1 -0
  258. package/v4/locales/id.js +1 -0
  259. package/v4/locales/index.cjs +19 -0
  260. package/v4/locales/is.cjs +1 -0
  261. package/v4/locales/is.js +1 -0
  262. package/v4/locales/it.cjs +1 -0
  263. package/v4/locales/it.js +1 -0
  264. package/v4/locales/ja.cjs +1 -0
  265. package/v4/locales/ja.js +1 -0
  266. package/v4/locales/ka.cjs +1 -0
  267. package/v4/locales/ka.js +1 -0
  268. package/v4/locales/km.cjs +1 -0
  269. package/v4/locales/km.js +1 -0
  270. package/v4/locales/kn.cjs +1 -0
  271. package/v4/locales/kn.js +1 -0
  272. package/v4/locales/ko.cjs +1 -0
  273. package/v4/locales/ko.js +1 -0
  274. package/v4/locales/lt.cjs +1 -0
  275. package/v4/locales/lt.js +1 -0
  276. package/v4/locales/mk.cjs +1 -0
  277. package/v4/locales/mk.js +1 -0
  278. package/v4/locales/ms.cjs +1 -0
  279. package/v4/locales/ms.js +1 -0
  280. package/v4/locales/ne.cjs +1 -0
  281. package/v4/locales/ne.js +1 -0
  282. package/v4/locales/nl.cjs +1 -0
  283. package/v4/locales/nl.js +1 -0
  284. package/v4/locales/nn.cjs +1 -0
  285. package/v4/locales/nn.js +1 -0
  286. package/v4/locales/no.cjs +1 -0
  287. package/v4/locales/no.js +1 -0
  288. package/v4/locales/ota.cjs +1 -0
  289. package/v4/locales/ota.js +1 -0
  290. package/v4/locales/pl.cjs +1 -0
  291. package/v4/locales/pl.js +1 -0
  292. package/v4/locales/ps.cjs +1 -0
  293. package/v4/locales/ps.js +1 -0
  294. package/v4/locales/pt-BR.cjs +1 -0
  295. package/v4/locales/pt-BR.js +1 -0
  296. package/v4/locales/pt.cjs +1 -0
  297. package/v4/locales/pt.js +1 -0
  298. package/v4/locales/ro.cjs +1 -0
  299. package/v4/locales/ro.js +1 -0
  300. package/v4/locales/ru.cjs +1 -0
  301. package/v4/locales/ru.js +1 -0
  302. package/v4/locales/sk.cjs +1 -0
  303. package/v4/locales/sk.js +1 -0
  304. package/v4/locales/sl.cjs +1 -0
  305. package/v4/locales/sl.js +1 -0
  306. package/v4/locales/sv.cjs +1 -0
  307. package/v4/locales/sv.js +1 -0
  308. package/v4/locales/ta.cjs +1 -0
  309. package/v4/locales/ta.js +1 -0
  310. package/v4/locales/th.cjs +1 -0
  311. package/v4/locales/th.js +1 -0
  312. package/v4/locales/tk.cjs +1 -0
  313. package/v4/locales/tk.js +1 -0
  314. package/v4/locales/tr.cjs +1 -0
  315. package/v4/locales/tr.js +1 -0
  316. package/v4/locales/uk.cjs +1 -0
  317. package/v4/locales/uk.js +1 -0
  318. package/v4/locales/ur.cjs +1 -0
  319. package/v4/locales/ur.js +1 -0
  320. package/v4/locales/uz.cjs +1 -0
  321. package/v4/locales/uz.js +1 -0
  322. package/v4/locales/vi.cjs +1 -0
  323. package/v4/locales/vi.js +1 -0
  324. package/v4/locales/yo.cjs +1 -0
  325. package/v4/locales/yo.js +1 -0
  326. package/v4/locales/zh-CN.cjs +1 -0
  327. package/v4/locales/zh-CN.js +1 -0
  328. package/v4/locales/zh-TW.cjs +1 -0
  329. package/v4/locales/zh-TW.js +1 -0
  330. package/v4/mini/checks.cjs +20 -2
  331. package/v4/mini/checks.d.cts +1 -1
  332. package/v4/mini/checks.d.ts +1 -1
  333. package/v4/mini/checks.js +1 -1
  334. package/v4/mini/coerce.cjs +19 -0
  335. package/v4/mini/deep-partial.cjs +19 -0
  336. package/v4/mini/external.cjs +22 -1
  337. package/v4/mini/external.d.cts +1 -1
  338. package/v4/mini/external.d.ts +1 -1
  339. package/v4/mini/external.js +1 -1
  340. package/v4/mini/in-out.cjs +19 -0
  341. package/v4/mini/index.cjs +19 -0
  342. package/v4/mini/iso.cjs +19 -0
  343. package/v4/mini/parse.cjs +19 -0
  344. package/v4/mini/schemas.cjs +42 -4
  345. package/v4/mini/schemas.d.cts +8 -0
  346. package/v4/mini/schemas.d.ts +8 -0
  347. package/v4/mini/schemas.js +19 -2
  348. package/v4-mini/index.cjs +19 -0
@@ -61,3 +61,22 @@ function output(schema) {
61
61
  prefault: (s, rewritten) => (rewritten ? s._zod.def.innerType : s),
62
62
  });
63
63
  }
64
+
65
+ // seal-cjs-exports
66
+ (function () {
67
+ var keys = Object.getOwnPropertyNames(exports);
68
+ for (var i = 0; i < keys.length; i++) {
69
+ var desc = Object.getOwnPropertyDescriptor(exports, keys[i]);
70
+ if (!desc || !desc.get || !desc.configurable) continue;
71
+ var value;
72
+ try {
73
+ value = desc.get();
74
+ } catch (e) {
75
+ continue;
76
+ }
77
+ // a circular require may not have settled this one yet, so leave it live
78
+ if (value === undefined) continue;
79
+ Object.defineProperty(exports, keys[i], { value: value, writable: false, enumerable: desc.enumerable, configurable: false });
80
+ }
81
+ Object.freeze(exports);
82
+ })();
@@ -31,3 +31,22 @@ const z = __importStar(require("./external.cjs"));
31
31
  exports.z = z;
32
32
  exports.default = z;
33
33
  __exportStar(require("./external.cjs"), exports);
34
+
35
+ // seal-cjs-exports
36
+ (function () {
37
+ var keys = Object.getOwnPropertyNames(exports);
38
+ for (var i = 0; i < keys.length; i++) {
39
+ var desc = Object.getOwnPropertyDescriptor(exports, keys[i]);
40
+ if (!desc || !desc.get || !desc.configurable) continue;
41
+ var value;
42
+ try {
43
+ value = desc.get();
44
+ } catch (e) {
45
+ continue;
46
+ }
47
+ // a circular require may not have settled this one yet, so leave it live
48
+ if (value === undefined) continue;
49
+ Object.defineProperty(exports, keys[i], { value: value, writable: false, enumerable: desc.enumerable, configurable: false });
50
+ }
51
+ Object.freeze(exports);
52
+ })();
@@ -47,3 +47,22 @@ function time(params) {
47
47
  function duration(params) {
48
48
  return core._isoDuration(schemas_js_1.ZodISODuration, params);
49
49
  }
50
+
51
+ // seal-cjs-exports
52
+ (function () {
53
+ var keys = Object.getOwnPropertyNames(exports);
54
+ for (var i = 0; i < keys.length; i++) {
55
+ var desc = Object.getOwnPropertyDescriptor(exports, keys[i]);
56
+ if (!desc || !desc.get || !desc.configurable) continue;
57
+ var value;
58
+ try {
59
+ value = desc.get();
60
+ } catch (e) {
61
+ continue;
62
+ }
63
+ // a circular require may not have settled this one yet, so leave it live
64
+ if (value === undefined) continue;
65
+ Object.defineProperty(exports, keys[i], { value: value, writable: false, enumerable: desc.enumerable, configurable: false });
66
+ }
67
+ Object.freeze(exports);
68
+ })();
@@ -42,3 +42,22 @@ exports.safeEncode = core._safeEncode(errors_js_1.ZodRealError);
42
42
  exports.safeDecode = core._safeDecode(errors_js_1.ZodRealError);
43
43
  exports.safeEncodeAsync = core._safeEncodeAsync(errors_js_1.ZodRealError);
44
44
  exports.safeDecodeAsync = core._safeDecodeAsync(errors_js_1.ZodRealError);
45
+
46
+ // seal-cjs-exports
47
+ (function () {
48
+ var keys = Object.getOwnPropertyNames(exports);
49
+ for (var i = 0; i < keys.length; i++) {
50
+ var desc = Object.getOwnPropertyDescriptor(exports, keys[i]);
51
+ if (!desc || !desc.get || !desc.configurable) continue;
52
+ var value;
53
+ try {
54
+ value = desc.get();
55
+ } catch (e) {
56
+ continue;
57
+ }
58
+ // a circular require may not have settled this one yet, so leave it live
59
+ if (value === undefined) continue;
60
+ Object.defineProperty(exports, keys[i], { value: value, writable: false, enumerable: desc.enumerable, configurable: false });
61
+ }
62
+ Object.freeze(exports);
63
+ })();
@@ -26,8 +26,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.ZodTuple = exports.ZodIntersection = exports.ZodDiscriminatedUnion = exports.ZodXor = exports.ZodUnion = exports.ZodObject = exports.ZodArray = exports.ZodDate = exports.ZodVoid = exports.ZodNever = exports.ZodUnknown = exports.ZodAny = exports.ZodNull = exports.ZodUndefined = exports.ZodSymbol = exports.ZodBigIntFormat = exports.ZodBigInt = exports.ZodBoolean = exports.ZodNumberFormat = exports.ZodNumber = exports.ZodCustomStringFormat = exports.ZodJWT = exports.ZodCreditCard = exports.ZodE164 = exports.ZodBase64URL = exports.ZodBase64 = exports.ZodCIDRv6 = exports.ZodCIDRv4 = exports.ZodIPv6 = exports.ZodMAC = exports.ZodIPv4 = exports.ZodKSUID = exports.ZodXID = exports.ZodULID = exports.ZodCUID2 = exports.ZodCUID = exports.ZodNanoID = exports.ZodEmoji = exports.ZodURL = exports.ZodUUID = exports.ZodGUID = exports.ZodEmail = exports.ZodISODuration = exports.ZodISOTime = exports.ZodISODate = exports.ZodISODateTime = exports.ZodStringFormat = exports.ZodString = exports._ZodString = exports.ZodType = void 0;
30
- exports.stringbool = exports.meta = exports.describe = exports.ZodCustom = exports.ZodFunction = exports.ZodPromise = exports.ZodLazy = exports.ZodTemplateLiteral = exports.ZodReadonly = exports.ZodPreprocess = exports.ZodCodec = exports.ZodPipe = exports.ZodNaN = exports.ZodCatch = exports.ZodSuccess = exports.ZodNonOptional = exports.ZodPrefault = exports.ZodDefault = exports.ZodNullable = exports.ZodExactOptional = exports.ZodOptional = exports.ZodTransform = exports.ZodFile = exports.ZodLiteral = exports.ZodEnum = exports.ZodSet = exports.ZodMap = exports.ZodRecord = void 0;
29
+ exports.ZodIntersection = exports.ZodDiscriminatedUnion = exports.ZodXor = exports.ZodUnion = exports.ZodObject = exports.ZodArray = exports.ZodDate = exports.ZodVoid = exports.ZodNever = exports.ZodUnknown = exports.ZodAny = exports.ZodNull = exports.ZodUndefined = exports.ZodSymbol = exports.ZodBigIntFormat = exports.ZodBigInt = exports.ZodBoolean = exports.ZodNumberFormat = exports.ZodNumber = exports.ZodCustomStringFormat = exports.ZodJWT = exports.ZodIBAN = exports.ZodCreditCard = exports.ZodE164 = exports.ZodBase64URL = exports.ZodBase64 = exports.ZodCIDRv6 = exports.ZodCIDRv4 = exports.ZodIPv6 = exports.ZodMAC = exports.ZodIPv4 = exports.ZodKSUID = exports.ZodXID = exports.ZodULID = exports.ZodCUID2 = exports.ZodCUID = exports.ZodNanoID = exports.ZodEmoji = exports.ZodURL = exports.ZodUUID = exports.ZodGUID = exports.ZodEmail = exports.ZodISODuration = exports.ZodISOTime = exports.ZodISODate = exports.ZodISODateTime = exports.ZodStringFormat = exports.ZodString = exports._ZodString = exports.ZodType = void 0;
30
+ exports.stringbool = exports.ZodInstanceOf = exports.meta = exports.describe = exports.ZodProperties = exports.ZodCustom = exports.ZodFunction = exports.ZodPromise = exports.ZodLazy = exports.ZodTemplateLiteral = exports.ZodReadonly = exports.ZodPreprocess = exports.ZodCodec = exports.ZodPipe = exports.ZodNaN = exports.ZodCatch = exports.ZodSuccess = exports.ZodNonOptional = exports.ZodPrefault = exports.ZodDefault = exports.ZodNullable = exports.ZodExactOptional = exports.ZodOptional = exports.ZodTransform = exports.ZodFile = exports.ZodLiteral = exports.ZodEnum = exports.ZodSet = exports.ZodMap = exports.ZodRecord = exports.ZodTuple = void 0;
31
31
  exports.string = string;
32
32
  exports.email = email;
33
33
  exports.guid = guid;
@@ -53,6 +53,7 @@ exports.base64 = base64;
53
53
  exports.base64url = base64url;
54
54
  exports.e164 = e164;
55
55
  exports.creditCard = creditCard;
56
+ exports.iban = iban;
56
57
  exports.jwt = jwt;
57
58
  exports.stringFormat = stringFormat;
58
59
  exports.hostname = hostname;
@@ -117,6 +118,7 @@ exports._function = _function;
117
118
  exports.function = _function;
118
119
  exports._function = _function;
119
120
  exports.function = _function;
121
+ exports.properties = properties;
120
122
  exports.check = check;
121
123
  exports.custom = custom;
122
124
  exports.refine = refine;
@@ -275,6 +277,12 @@ exports.ZodType = core.$constructor("ZodType", (inst, def) => {
275
277
  set spa(value) {
276
278
  index_js_1.util.own(this, "spa", value);
277
279
  },
280
+ validate(data, params) {
281
+ return parse.validate(this, data, params);
282
+ },
283
+ validateAsync(data, params) {
284
+ return parse.validateAsync(this, data, params);
285
+ },
278
286
  encode: function _encode(data, params) {
279
287
  return parse.encode(this, data, params, { callee: _encode });
280
288
  },
@@ -316,10 +324,11 @@ exports._ZodString = core.$constructor("_ZodString", (inst, def) => {
316
324
  core.$ZodString.init(inst, def);
317
325
  exports.ZodType.init(inst, def);
318
326
  inst._zod.processJSONSchema = (ctx, json, params) => processors.stringProcessor(inst, ctx, json, params);
319
- const bag = inst._zod.bag;
320
- inst.format = bag.format ?? null;
321
- inst.minLength = bag.minimum ?? null;
322
- inst.maxLength = bag.maximum ?? null;
327
+ },
328
+ /*@__PURE__*/ index_js_1.util.derived({
329
+ format: (inst) => processors.aggregateChecks(inst).format ?? null,
330
+ minLength: (inst) => processors.aggregateChecks(inst).minimum ?? null,
331
+ maxLength: (inst) => processors.aggregateChecks(inst).maximum ?? null,
323
332
  }, {
324
333
  regex(...args) {
325
334
  return this.check(checks.regex(...args));
@@ -366,7 +375,7 @@ exports._ZodString = core.$constructor("_ZodString", (inst, def) => {
366
375
  slugify() {
367
376
  return this.check(checks.slugify());
368
377
  },
369
- });
378
+ }));
370
379
  exports.ZodString = core.$constructor("ZodString", (inst, def) => {
371
380
  core.$ZodString.init(inst, def);
372
381
  exports._ZodString.init(inst, def);
@@ -660,6 +669,13 @@ exports.ZodCreditCard = core.$constructor("ZodCreditCard", (inst, def) => {
660
669
  function creditCard(params) {
661
670
  return core._creditCard(exports.ZodCreditCard, params);
662
671
  }
672
+ exports.ZodIBAN = core.$constructor("ZodIBAN", (inst, def) => {
673
+ core.$ZodIBAN.init(inst, def);
674
+ exports.ZodStringFormat.init(inst, def);
675
+ });
676
+ function iban(params) {
677
+ return core._iban(exports.ZodIBAN, params);
678
+ }
663
679
  exports.ZodJWT = core.$constructor("ZodJWT", (inst, def) => {
664
680
  // ZodStringFormat.init(inst, def);
665
681
  core.$ZodJWT.init(inst, def);
@@ -694,14 +710,22 @@ exports.ZodNumber = core.$constructor("ZodNumber", (inst, def) => {
694
710
  core.$ZodNumber.init(inst, def);
695
711
  exports.ZodType.init(inst, def);
696
712
  inst._zod.processJSONSchema = (ctx, json, params) => processors.numberProcessor(inst, ctx, json, params);
697
- const bag = inst._zod.bag;
698
- inst.minValue =
699
- Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;
700
- inst.maxValue =
701
- Math.min(bag.maximum ?? Number.POSITIVE_INFINITY, bag.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null;
702
- inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? 0.5);
703
713
  inst.isFinite = true;
704
- inst.format = bag.format ?? null;
714
+ },
715
+ /*@__PURE__*/ index_js_1.util.derived({
716
+ minValue: (inst) => {
717
+ const { minimum, exclusiveMinimum } = processors.aggregateChecks(inst);
718
+ return Math.max(minimum ?? Number.NEGATIVE_INFINITY, exclusiveMinimum ?? Number.NEGATIVE_INFINITY);
719
+ },
720
+ maxValue: (inst) => {
721
+ const { maximum, exclusiveMaximum } = processors.aggregateChecks(inst);
722
+ return Math.min(maximum ?? Number.POSITIVE_INFINITY, exclusiveMaximum ?? Number.POSITIVE_INFINITY);
723
+ },
724
+ isInt: (inst) => {
725
+ const { isInt, multipleOf } = processors.aggregateChecks(inst);
726
+ return !!isInt || !!multipleOf?.some(Number.isSafeInteger);
727
+ },
728
+ format: (inst) => processors.aggregateChecks(inst).format ?? null,
705
729
  }, {
706
730
  gt(value, params) {
707
731
  return this.check(checks.gt(value, params));
@@ -748,7 +772,7 @@ exports.ZodNumber = core.$constructor("ZodNumber", (inst, def) => {
748
772
  finite() {
749
773
  return this;
750
774
  },
751
- });
775
+ }));
752
776
  function number(params) {
753
777
  return core._number(exports.ZodNumber, params);
754
778
  }
@@ -783,10 +807,11 @@ exports.ZodBigInt = core.$constructor("ZodBigInt", (inst, def) => {
783
807
  core.$ZodBigInt.init(inst, def);
784
808
  exports.ZodType.init(inst, def);
785
809
  inst._zod.processJSONSchema = (ctx, json, params) => processors.bigintProcessor(inst, ctx, json, params);
786
- const bag = inst._zod.bag;
787
- inst.minValue = bag.minimum ?? null;
788
- inst.maxValue = bag.maximum ?? null;
789
- inst.format = bag.format ?? null;
810
+ },
811
+ /*@__PURE__*/ index_js_1.util.derived({
812
+ minValue: (inst) => processors.aggregateChecks(inst).minimum ?? null,
813
+ maxValue: (inst) => processors.aggregateChecks(inst).maximum ?? null,
814
+ format: (inst) => processors.aggregateChecks(inst).format ?? null,
790
815
  }, {
791
816
  gte(value, params) {
792
817
  return this.check(checks.gte(value, params));
@@ -821,7 +846,7 @@ exports.ZodBigInt = core.$constructor("ZodBigInt", (inst, def) => {
821
846
  multipleOf(value, params) {
822
847
  return this.check(checks.multipleOf(value, params));
823
848
  },
824
- });
849
+ }));
825
850
  function bigint(params) {
826
851
  return core._bigint(exports.ZodBigInt, params);
827
852
  }
@@ -897,10 +922,17 @@ exports.ZodDate = core.$constructor("ZodDate", (inst, def) => {
897
922
  inst._zod.processJSONSchema = (ctx, json, params) => processors.dateProcessor(inst, ctx, json, params);
898
923
  inst.min = (value, params) => inst.check(checks.gte(value, params));
899
924
  inst.max = (value, params) => inst.check(checks.lte(value, params));
900
- const c = inst._zod.bag;
901
- inst.minDate = c.minimum ? new Date(c.minimum) : null;
902
- inst.maxDate = c.maximum ? new Date(c.maximum) : null;
903
- });
925
+ },
926
+ /*@__PURE__*/ index_js_1.util.derived({
927
+ minDate: (inst) => {
928
+ const { minimum } = processors.aggregateChecks(inst);
929
+ return minimum ? new Date(minimum) : null;
930
+ },
931
+ maxDate: (inst) => {
932
+ const { maximum } = processors.aggregateChecks(inst);
933
+ return maximum ? new Date(maximum) : null;
934
+ },
935
+ }, {}));
904
936
  function date(params) {
905
937
  return core._date(exports.ZodDate, params);
906
938
  }
@@ -946,19 +978,20 @@ exports.ZodObject = core.$constructor("ZodObject", (inst, def) => {
946
978
  return _enum(Object.keys(this._zod.def.shape));
947
979
  },
948
980
  catchall(catchall) {
949
- return this.clone({ ...this._zod.def, catchall: catchall });
981
+ // `mergeDefs` rather than a spread: spreading reads `shape`, and resolving it can mint a whole fresh subtree
982
+ return this.clone(index_js_1.util.mergeDefs(this._zod.def, { catchall: catchall }));
950
983
  },
951
984
  passthrough() {
952
- return this.clone({ ...this._zod.def, catchall: unknown() });
985
+ return this.clone(index_js_1.util.mergeDefs(this._zod.def, { catchall: unknown() }));
953
986
  },
954
987
  loose() {
955
- return this.clone({ ...this._zod.def, catchall: unknown() });
988
+ return this.clone(index_js_1.util.mergeDefs(this._zod.def, { catchall: unknown() }));
956
989
  },
957
990
  strict() {
958
- return this.clone({ ...this._zod.def, catchall: never() });
991
+ return this.clone(index_js_1.util.mergeDefs(this._zod.def, { catchall: never() }));
959
992
  },
960
993
  strip() {
961
- return this.clone({ ...this._zod.def, catchall: undefined });
994
+ return this.clone(index_js_1.util.mergeDefs(this._zod.def, { catchall: undefined }));
962
995
  },
963
996
  extend(incoming) {
964
997
  return index_js_1.util.extend(this, incoming);
@@ -1186,7 +1219,8 @@ exports.ZodEnum = core.$constructor("ZodEnum", (inst, def) => {
1186
1219
  exports.ZodType.init(inst, def);
1187
1220
  inst._zod.processJSONSchema = (ctx, json, params) => processors.enumProcessor(inst, ctx, json, params);
1188
1221
  inst.enum = def.entries;
1189
- inst.options = Object.values(def.entries);
1222
+ // reuse the parsed value set so a numeric TS enum's reverse-mapping keys stay out
1223
+ inst.options = [...inst._zod.values];
1190
1224
  const keys = new Set(Object.keys(def.entries));
1191
1225
  inst.extract = (values, params) => {
1192
1226
  const newEntries = {};
@@ -1543,6 +1577,14 @@ exports.ZodCustom = core.$constructor("ZodCustom", (inst, def) => {
1543
1577
  exports.ZodType.init(inst, def);
1544
1578
  inst._zod.processJSONSchema = (ctx, json, params) => processors.customProcessor(inst, ctx, json, params);
1545
1579
  });
1580
+ exports.ZodProperties = core.$constructor("ZodProperties", (inst, def) => {
1581
+ _ensureDefaultMemoizer();
1582
+ core.$ZodProperties.init(inst, def);
1583
+ exports.ZodType.init(inst, def);
1584
+ });
1585
+ function properties(shape, params) {
1586
+ return core._properties(exports.ZodProperties, shape, params);
1587
+ }
1546
1588
  // custom checks
1547
1589
  function check(fn) {
1548
1590
  const ch = new core.$ZodCheck({
@@ -1565,8 +1607,16 @@ function superRefine(fn, params) {
1565
1607
  // Re-export describe and meta from core
1566
1608
  exports.describe = core.describe;
1567
1609
  exports.meta = core.meta;
1610
+ exports.ZodInstanceOf = core.$constructor("ZodInstanceOf", (inst, def) => {
1611
+ exports.ZodCustom.init(inst, def);
1612
+ }, {
1613
+ properties(shape, params) {
1614
+ // asserts in place, so the narrowed output type is truthful without a wrapper
1615
+ return this.check(properties(shape, params));
1616
+ },
1617
+ });
1568
1618
  function _instanceof(cls, params = {}) {
1569
- const inst = new exports.ZodCustom({
1619
+ const inst = new exports.ZodInstanceOf({
1570
1620
  type: "custom",
1571
1621
  check: "custom",
1572
1622
  fn: (data) => data instanceof cls,
@@ -1609,3 +1659,22 @@ function preprocess(fn, schema) {
1609
1659
  out: schema,
1610
1660
  });
1611
1661
  }
1662
+
1663
+ // seal-cjs-exports
1664
+ (function () {
1665
+ var keys = Object.getOwnPropertyNames(exports);
1666
+ for (var i = 0; i < keys.length; i++) {
1667
+ var desc = Object.getOwnPropertyDescriptor(exports, keys[i]);
1668
+ if (!desc || !desc.get || !desc.configurable) continue;
1669
+ var value;
1670
+ try {
1671
+ value = desc.get();
1672
+ } catch (e) {
1673
+ continue;
1674
+ }
1675
+ // a circular require may not have settled this one yet, so leave it live
1676
+ if (value === undefined) continue;
1677
+ Object.defineProperty(exports, keys[i], { value: value, writable: false, enumerable: desc.enumerable, configurable: false });
1678
+ }
1679
+ Object.freeze(exports);
1680
+ })();
@@ -28,6 +28,8 @@ export interface ZodType<out Output = unknown, out Input = unknown, out Internal
28
28
  parseAsync(data: unknown, params?: core.ParseContext<core.$ZodIssue>): Promise<core.output<this>>;
29
29
  safeParseAsync(data: unknown, params?: core.ParseContext<core.$ZodIssue>): Promise<parse.ZodSafeParseResult<core.output<this>>>;
30
30
  spa: (data: unknown, params?: core.ParseContext<core.$ZodIssue>) => Promise<parse.ZodSafeParseResult<core.output<this>>>;
31
+ validate(data: unknown, params?: core.ParseContext<core.$ZodIssue>): data is core.input<this>;
32
+ validateAsync(data: unknown, params?: core.ParseContext<core.$ZodIssue>): Promise<boolean>;
31
33
  encode(data: core.output<this>, params?: core.ParseContext<core.$ZodIssue>): core.input<this>;
32
34
  decode(data: core.input<this>, params?: core.ParseContext<core.$ZodIssue>): core.output<this>;
33
35
  encodeAsync(data: core.output<this>, params?: core.ParseContext<core.$ZodIssue>): Promise<core.input<this>>;
@@ -310,6 +312,11 @@ export interface ZodCreditCard extends ZodStringFormat<"credit_card"> {
310
312
  }
311
313
  export declare const ZodCreditCard: core.$constructor<ZodCreditCard>;
312
314
  export declare function creditCard(params?: string | core.$ZodCreditCardParams): ZodCreditCard;
315
+ export interface ZodIBAN extends ZodStringFormat<"iban"> {
316
+ _zod: core.$ZodIBANInternals;
317
+ }
318
+ export declare const ZodIBAN: core.$constructor<ZodIBAN>;
319
+ export declare function iban(params?: string | core.$ZodIBANParams): ZodIBAN;
313
320
  export interface ZodJWT extends ZodStringFormat<"jwt"> {
314
321
  _zod: core.$ZodJWTInternals;
315
322
  }
@@ -772,6 +779,11 @@ export interface ZodCustom<O = unknown, I = unknown> extends _ZodType<core.$ZodC
772
779
  "~standard": ZodStandardSchemaWithJSON<this>;
773
780
  }
774
781
  export declare const ZodCustom: core.$constructor<ZodCustom>;
782
+ export interface ZodProperties<Shape extends core.$ZodShape = core.$ZodShape> extends _ZodType<core.$ZodPropertiesInternals<Shape>>, core.$ZodProperties<Shape> {
783
+ "~standard": ZodStandardSchemaWithJSON<this>;
784
+ }
785
+ export declare const ZodProperties: core.$constructor<ZodProperties>;
786
+ export declare function properties<Shape extends core.$ZodShape>(shape: Shape, params?: string | core.$ZodPropertiesParams): ZodProperties<Shape>;
775
787
  export declare function check<O = unknown>(fn: core.CheckFn<O>): core.$ZodCheck<O>;
776
788
  export declare function custom<O>(fn?: (data: unknown) => unknown, _params?: string | core.$ZodCustomParams | undefined): ZodCustom<O, O>;
777
789
  export declare function refine<T>(fn: (arg: NoInfer<T>) => util.MaybeAsync<unknown>, _params?: string | core.$ZodCustomParams): core.$ZodCheck<T>;
@@ -779,7 +791,11 @@ export declare function superRefine<T>(fn: (arg: T, payload: core.$RefinementCtx
779
791
  export declare const describe: typeof core.describe;
780
792
  export declare const meta: typeof core.meta;
781
793
  type ZodInstanceOfParams = core.Params<ZodCustom, core.$ZodIssueCustom, "type" | "check" | "checks" | "fn" | "abort" | "error" | "params" | "path">;
782
- declare function _instanceof<T extends typeof util.Class>(cls: T, params?: ZodInstanceOfParams): ZodCustom<InstanceType<T>, InstanceType<T>>;
794
+ export interface ZodInstanceOf<T = unknown> extends ZodCustom<T, T> {
795
+ properties<Shape extends core.$ZodShape>(shape: Shape, params?: string | core.$ZodPropertiesParams): ZodInstanceOf<T & core.$InferObjectInput<Shape, {}>>;
796
+ }
797
+ export declare const ZodInstanceOf: core.$constructor<ZodInstanceOf>;
798
+ declare function _instanceof<T extends typeof util.Class>(cls: T, params?: ZodInstanceOfParams): ZodInstanceOf<InstanceType<T>>;
783
799
  export { _instanceof as instanceof };
784
800
  export declare const stringbool: (_params?: string | core.$ZodStringBoolParams) => ZodCodec<ZodString, ZodBoolean>;
785
801
  type _ZodJSONSchema = ZodUnion<[
@@ -28,6 +28,8 @@ export interface ZodType<out Output = unknown, out Input = unknown, out Internal
28
28
  parseAsync(data: unknown, params?: core.ParseContext<core.$ZodIssue>): Promise<core.output<this>>;
29
29
  safeParseAsync(data: unknown, params?: core.ParseContext<core.$ZodIssue>): Promise<parse.ZodSafeParseResult<core.output<this>>>;
30
30
  spa: (data: unknown, params?: core.ParseContext<core.$ZodIssue>) => Promise<parse.ZodSafeParseResult<core.output<this>>>;
31
+ validate(data: unknown, params?: core.ParseContext<core.$ZodIssue>): data is core.input<this>;
32
+ validateAsync(data: unknown, params?: core.ParseContext<core.$ZodIssue>): Promise<boolean>;
31
33
  encode(data: core.output<this>, params?: core.ParseContext<core.$ZodIssue>): core.input<this>;
32
34
  decode(data: core.input<this>, params?: core.ParseContext<core.$ZodIssue>): core.output<this>;
33
35
  encodeAsync(data: core.output<this>, params?: core.ParseContext<core.$ZodIssue>): Promise<core.input<this>>;
@@ -310,6 +312,11 @@ export interface ZodCreditCard extends ZodStringFormat<"credit_card"> {
310
312
  }
311
313
  export declare const ZodCreditCard: core.$constructor<ZodCreditCard>;
312
314
  export declare function creditCard(params?: string | core.$ZodCreditCardParams): ZodCreditCard;
315
+ export interface ZodIBAN extends ZodStringFormat<"iban"> {
316
+ _zod: core.$ZodIBANInternals;
317
+ }
318
+ export declare const ZodIBAN: core.$constructor<ZodIBAN>;
319
+ export declare function iban(params?: string | core.$ZodIBANParams): ZodIBAN;
313
320
  export interface ZodJWT extends ZodStringFormat<"jwt"> {
314
321
  _zod: core.$ZodJWTInternals;
315
322
  }
@@ -772,6 +779,11 @@ export interface ZodCustom<O = unknown, I = unknown> extends _ZodType<core.$ZodC
772
779
  "~standard": ZodStandardSchemaWithJSON<this>;
773
780
  }
774
781
  export declare const ZodCustom: core.$constructor<ZodCustom>;
782
+ export interface ZodProperties<Shape extends core.$ZodShape = core.$ZodShape> extends _ZodType<core.$ZodPropertiesInternals<Shape>>, core.$ZodProperties<Shape> {
783
+ "~standard": ZodStandardSchemaWithJSON<this>;
784
+ }
785
+ export declare const ZodProperties: core.$constructor<ZodProperties>;
786
+ export declare function properties<Shape extends core.$ZodShape>(shape: Shape, params?: string | core.$ZodPropertiesParams): ZodProperties<Shape>;
775
787
  export declare function check<O = unknown>(fn: core.CheckFn<O>): core.$ZodCheck<O>;
776
788
  export declare function custom<O>(fn?: (data: unknown) => unknown, _params?: string | core.$ZodCustomParams | undefined): ZodCustom<O, O>;
777
789
  export declare function refine<T>(fn: (arg: NoInfer<T>) => util.MaybeAsync<unknown>, _params?: string | core.$ZodCustomParams): core.$ZodCheck<T>;
@@ -779,7 +791,11 @@ export declare function superRefine<T>(fn: (arg: T, payload: core.$RefinementCtx
779
791
  export declare const describe: typeof core.describe;
780
792
  export declare const meta: typeof core.meta;
781
793
  type ZodInstanceOfParams = core.Params<ZodCustom, core.$ZodIssueCustom, "type" | "check" | "checks" | "fn" | "abort" | "error" | "params" | "path">;
782
- declare function _instanceof<T extends typeof util.Class>(cls: T, params?: ZodInstanceOfParams): ZodCustom<InstanceType<T>, InstanceType<T>>;
794
+ export interface ZodInstanceOf<T = unknown> extends ZodCustom<T, T> {
795
+ properties<Shape extends core.$ZodShape>(shape: Shape, params?: string | core.$ZodPropertiesParams): ZodInstanceOf<T & core.$InferObjectInput<Shape, {}>>;
796
+ }
797
+ export declare const ZodInstanceOf: core.$constructor<ZodInstanceOf>;
798
+ declare function _instanceof<T extends typeof util.Class>(cls: T, params?: ZodInstanceOfParams): ZodInstanceOf<InstanceType<T>>;
783
799
  export { _instanceof as instanceof };
784
800
  export declare const stringbool: (_params?: string | core.$ZodStringBoolParams) => ZodCodec<ZodString, ZodBoolean>;
785
801
  type _ZodJSONSchema = ZodUnion<[
@@ -149,6 +149,12 @@ export const ZodType = /*@__PURE__*/ core.$constructor("ZodType", (inst, def) =>
149
149
  set spa(value) {
150
150
  util.own(this, "spa", value);
151
151
  },
152
+ validate(data, params) {
153
+ return parse.validate(this, data, params);
154
+ },
155
+ validateAsync(data, params) {
156
+ return parse.validateAsync(this, data, params);
157
+ },
152
158
  encode: function _encode(data, params) {
153
159
  return parse.encode(this, data, params, { callee: _encode });
154
160
  },
@@ -190,10 +196,11 @@ export const _ZodString = /*@__PURE__*/ core.$constructor("_ZodString", (inst, d
190
196
  core.$ZodString.init(inst, def);
191
197
  ZodType.init(inst, def);
192
198
  inst._zod.processJSONSchema = (ctx, json, params) => processors.stringProcessor(inst, ctx, json, params);
193
- const bag = inst._zod.bag;
194
- inst.format = bag.format ?? null;
195
- inst.minLength = bag.minimum ?? null;
196
- inst.maxLength = bag.maximum ?? null;
199
+ },
200
+ /*@__PURE__*/ util.derived({
201
+ format: (inst) => processors.aggregateChecks(inst).format ?? null,
202
+ minLength: (inst) => processors.aggregateChecks(inst).minimum ?? null,
203
+ maxLength: (inst) => processors.aggregateChecks(inst).maximum ?? null,
197
204
  }, {
198
205
  regex(...args) {
199
206
  return this.check(checks.regex(...args));
@@ -240,7 +247,7 @@ export const _ZodString = /*@__PURE__*/ core.$constructor("_ZodString", (inst, d
240
247
  slugify() {
241
248
  return this.check(checks.slugify());
242
249
  },
243
- });
250
+ }));
244
251
  export const ZodString = /*@__PURE__*/ core.$constructor("ZodString", (inst, def) => {
245
252
  core.$ZodString.init(inst, def);
246
253
  _ZodString.init(inst, def);
@@ -534,6 +541,13 @@ export const ZodCreditCard = /*@__PURE__*/ core.$constructor("ZodCreditCard", (i
534
541
  export function creditCard(params) {
535
542
  return core._creditCard(ZodCreditCard, params);
536
543
  }
544
+ export const ZodIBAN = /*@__PURE__*/ core.$constructor("ZodIBAN", (inst, def) => {
545
+ core.$ZodIBAN.init(inst, def);
546
+ ZodStringFormat.init(inst, def);
547
+ });
548
+ export function iban(params) {
549
+ return core._iban(ZodIBAN, params);
550
+ }
537
551
  export const ZodJWT = /*@__PURE__*/ core.$constructor("ZodJWT", (inst, def) => {
538
552
  // ZodStringFormat.init(inst, def);
539
553
  core.$ZodJWT.init(inst, def);
@@ -568,14 +582,22 @@ export const ZodNumber = /*@__PURE__*/ core.$constructor("ZodNumber", (inst, def
568
582
  core.$ZodNumber.init(inst, def);
569
583
  ZodType.init(inst, def);
570
584
  inst._zod.processJSONSchema = (ctx, json, params) => processors.numberProcessor(inst, ctx, json, params);
571
- const bag = inst._zod.bag;
572
- inst.minValue =
573
- Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;
574
- inst.maxValue =
575
- Math.min(bag.maximum ?? Number.POSITIVE_INFINITY, bag.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null;
576
- inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? 0.5);
577
585
  inst.isFinite = true;
578
- inst.format = bag.format ?? null;
586
+ },
587
+ /*@__PURE__*/ util.derived({
588
+ minValue: (inst) => {
589
+ const { minimum, exclusiveMinimum } = processors.aggregateChecks(inst);
590
+ return Math.max(minimum ?? Number.NEGATIVE_INFINITY, exclusiveMinimum ?? Number.NEGATIVE_INFINITY);
591
+ },
592
+ maxValue: (inst) => {
593
+ const { maximum, exclusiveMaximum } = processors.aggregateChecks(inst);
594
+ return Math.min(maximum ?? Number.POSITIVE_INFINITY, exclusiveMaximum ?? Number.POSITIVE_INFINITY);
595
+ },
596
+ isInt: (inst) => {
597
+ const { isInt, multipleOf } = processors.aggregateChecks(inst);
598
+ return !!isInt || !!multipleOf?.some(Number.isSafeInteger);
599
+ },
600
+ format: (inst) => processors.aggregateChecks(inst).format ?? null,
579
601
  }, {
580
602
  gt(value, params) {
581
603
  return this.check(checks.gt(value, params));
@@ -622,7 +644,7 @@ export const ZodNumber = /*@__PURE__*/ core.$constructor("ZodNumber", (inst, def
622
644
  finite() {
623
645
  return this;
624
646
  },
625
- });
647
+ }));
626
648
  export function number(params) {
627
649
  return core._number(ZodNumber, params);
628
650
  }
@@ -657,10 +679,11 @@ export const ZodBigInt = /*@__PURE__*/ core.$constructor("ZodBigInt", (inst, def
657
679
  core.$ZodBigInt.init(inst, def);
658
680
  ZodType.init(inst, def);
659
681
  inst._zod.processJSONSchema = (ctx, json, params) => processors.bigintProcessor(inst, ctx, json, params);
660
- const bag = inst._zod.bag;
661
- inst.minValue = bag.minimum ?? null;
662
- inst.maxValue = bag.maximum ?? null;
663
- inst.format = bag.format ?? null;
682
+ },
683
+ /*@__PURE__*/ util.derived({
684
+ minValue: (inst) => processors.aggregateChecks(inst).minimum ?? null,
685
+ maxValue: (inst) => processors.aggregateChecks(inst).maximum ?? null,
686
+ format: (inst) => processors.aggregateChecks(inst).format ?? null,
664
687
  }, {
665
688
  gte(value, params) {
666
689
  return this.check(checks.gte(value, params));
@@ -695,7 +718,7 @@ export const ZodBigInt = /*@__PURE__*/ core.$constructor("ZodBigInt", (inst, def
695
718
  multipleOf(value, params) {
696
719
  return this.check(checks.multipleOf(value, params));
697
720
  },
698
- });
721
+ }));
699
722
  export function bigint(params) {
700
723
  return core._bigint(ZodBigInt, params);
701
724
  }
@@ -774,10 +797,17 @@ export const ZodDate = /*@__PURE__*/ core.$constructor("ZodDate", (inst, def) =>
774
797
  inst._zod.processJSONSchema = (ctx, json, params) => processors.dateProcessor(inst, ctx, json, params);
775
798
  inst.min = (value, params) => inst.check(checks.gte(value, params));
776
799
  inst.max = (value, params) => inst.check(checks.lte(value, params));
777
- const c = inst._zod.bag;
778
- inst.minDate = c.minimum ? new Date(c.minimum) : null;
779
- inst.maxDate = c.maximum ? new Date(c.maximum) : null;
780
- });
800
+ },
801
+ /*@__PURE__*/ util.derived({
802
+ minDate: (inst) => {
803
+ const { minimum } = processors.aggregateChecks(inst);
804
+ return minimum ? new Date(minimum) : null;
805
+ },
806
+ maxDate: (inst) => {
807
+ const { maximum } = processors.aggregateChecks(inst);
808
+ return maximum ? new Date(maximum) : null;
809
+ },
810
+ }, {}));
781
811
  export function date(params) {
782
812
  return core._date(ZodDate, params);
783
813
  }
@@ -823,19 +853,20 @@ export const ZodObject = /*@__PURE__*/ core.$constructor("ZodObject", (inst, def
823
853
  return _enum(Object.keys(this._zod.def.shape));
824
854
  },
825
855
  catchall(catchall) {
826
- return this.clone({ ...this._zod.def, catchall: catchall });
856
+ // `mergeDefs` rather than a spread: spreading reads `shape`, and resolving it can mint a whole fresh subtree
857
+ return this.clone(util.mergeDefs(this._zod.def, { catchall: catchall }));
827
858
  },
828
859
  passthrough() {
829
- return this.clone({ ...this._zod.def, catchall: unknown() });
860
+ return this.clone(util.mergeDefs(this._zod.def, { catchall: unknown() }));
830
861
  },
831
862
  loose() {
832
- return this.clone({ ...this._zod.def, catchall: unknown() });
863
+ return this.clone(util.mergeDefs(this._zod.def, { catchall: unknown() }));
833
864
  },
834
865
  strict() {
835
- return this.clone({ ...this._zod.def, catchall: never() });
866
+ return this.clone(util.mergeDefs(this._zod.def, { catchall: never() }));
836
867
  },
837
868
  strip() {
838
- return this.clone({ ...this._zod.def, catchall: undefined });
869
+ return this.clone(util.mergeDefs(this._zod.def, { catchall: undefined }));
839
870
  },
840
871
  extend(incoming) {
841
872
  return util.extend(this, incoming);
@@ -1063,7 +1094,8 @@ export const ZodEnum = /*@__PURE__*/ core.$constructor("ZodEnum", (inst, def) =>
1063
1094
  ZodType.init(inst, def);
1064
1095
  inst._zod.processJSONSchema = (ctx, json, params) => processors.enumProcessor(inst, ctx, json, params);
1065
1096
  inst.enum = def.entries;
1066
- inst.options = Object.values(def.entries);
1097
+ // reuse the parsed value set so a numeric TS enum's reverse-mapping keys stay out
1098
+ inst.options = [...inst._zod.values];
1067
1099
  const keys = new Set(Object.keys(def.entries));
1068
1100
  inst.extract = (values, params) => {
1069
1101
  const newEntries = {};
@@ -1423,6 +1455,14 @@ export const ZodCustom = /*@__PURE__*/ core.$constructor("ZodCustom", (inst, def
1423
1455
  ZodType.init(inst, def);
1424
1456
  inst._zod.processJSONSchema = (ctx, json, params) => processors.customProcessor(inst, ctx, json, params);
1425
1457
  });
1458
+ export const ZodProperties = /*@__PURE__*/ core.$constructor("ZodProperties", (inst, def) => {
1459
+ _ensureDefaultMemoizer();
1460
+ core.$ZodProperties.init(inst, def);
1461
+ ZodType.init(inst, def);
1462
+ });
1463
+ export function properties(shape, params) {
1464
+ return core._properties(ZodProperties, shape, params);
1465
+ }
1426
1466
  // custom checks
1427
1467
  export function check(fn) {
1428
1468
  const ch = new core.$ZodCheck({
@@ -1445,8 +1485,16 @@ export function superRefine(fn, params) {
1445
1485
  // Re-export describe and meta from core
1446
1486
  export const describe = core.describe;
1447
1487
  export const meta = core.meta;
1488
+ export const ZodInstanceOf = /*@__PURE__*/ core.$constructor("ZodInstanceOf", (inst, def) => {
1489
+ ZodCustom.init(inst, def);
1490
+ }, {
1491
+ properties(shape, params) {
1492
+ // asserts in place, so the narrowed output type is truthful without a wrapper
1493
+ return this.check(properties(shape, params));
1494
+ },
1495
+ });
1448
1496
  function _instanceof(cls, params = {}) {
1449
- const inst = new ZodCustom({
1497
+ const inst = new ZodInstanceOf({
1450
1498
  type: "custom",
1451
1499
  check: "custom",
1452
1500
  fn: (data) => data instanceof cls,