zod 4.0.0-beta.20250505T195954 → 4.0.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 (618) hide show
  1. package/README.md +208 -0
  2. package/index.cjs +33 -0
  3. package/index.d.cts +4 -0
  4. package/index.d.ts +4 -0
  5. package/index.js +4 -0
  6. package/locales/index.cjs +17 -0
  7. package/locales/index.d.cts +1 -0
  8. package/locales/index.d.ts +1 -0
  9. package/locales/index.js +1 -0
  10. package/mini/index.cjs +17 -0
  11. package/mini/index.d.cts +1 -0
  12. package/mini/index.d.ts +1 -0
  13. package/mini/index.js +1 -0
  14. package/package.json +87 -40
  15. package/src/index.ts +2 -3
  16. package/src/locales/index.ts +1 -0
  17. package/src/mini/index.ts +1 -0
  18. package/src/v3/ZodError.ts +330 -0
  19. package/src/v3/benchmarks/datetime.ts +58 -0
  20. package/src/v3/benchmarks/discriminatedUnion.ts +80 -0
  21. package/src/v3/benchmarks/index.ts +59 -0
  22. package/src/v3/benchmarks/ipv4.ts +57 -0
  23. package/src/v3/benchmarks/object.ts +69 -0
  24. package/src/v3/benchmarks/primitives.ts +162 -0
  25. package/src/v3/benchmarks/realworld.ts +63 -0
  26. package/src/v3/benchmarks/string.ts +55 -0
  27. package/src/v3/benchmarks/union.ts +80 -0
  28. package/src/v3/errors.ts +13 -0
  29. package/src/v3/external.ts +6 -0
  30. package/src/v3/helpers/enumUtil.ts +17 -0
  31. package/src/v3/helpers/errorUtil.ts +8 -0
  32. package/src/v3/helpers/parseUtil.ts +176 -0
  33. package/src/v3/helpers/partialUtil.ts +34 -0
  34. package/src/v3/helpers/typeAliases.ts +2 -0
  35. package/src/v3/helpers/util.ts +224 -0
  36. package/src/v3/index.ts +4 -0
  37. package/src/v3/locales/en.ts +124 -0
  38. package/src/v3/standard-schema.ts +113 -0
  39. package/src/v3/tests/Mocker.ts +54 -0
  40. package/src/v3/tests/all-errors.test.ts +157 -0
  41. package/src/v3/tests/anyunknown.test.ts +28 -0
  42. package/src/v3/tests/array.test.ts +71 -0
  43. package/src/v3/tests/async-parsing.test.ts +388 -0
  44. package/src/v3/tests/async-refinements.test.ts +46 -0
  45. package/src/v3/tests/base.test.ts +29 -0
  46. package/src/v3/tests/bigint.test.ts +55 -0
  47. package/src/v3/tests/branded.test.ts +53 -0
  48. package/src/v3/tests/catch.test.ts +220 -0
  49. package/src/v3/tests/coerce.test.ts +133 -0
  50. package/src/v3/tests/complex.test.ts +56 -0
  51. package/src/v3/tests/custom.test.ts +31 -0
  52. package/src/v3/tests/date.test.ts +32 -0
  53. package/src/v3/tests/deepmasking.test.ts +186 -0
  54. package/src/v3/tests/default.test.ts +112 -0
  55. package/src/v3/tests/description.test.ts +33 -0
  56. package/src/v3/tests/discriminated-unions.test.ts +315 -0
  57. package/src/v3/tests/enum.test.ts +80 -0
  58. package/src/v3/tests/error.test.ts +551 -0
  59. package/src/v3/tests/firstparty.test.ts +87 -0
  60. package/src/v3/tests/firstpartyschematypes.test.ts +21 -0
  61. package/src/v3/tests/function.test.ts +257 -0
  62. package/src/v3/tests/generics.test.ts +48 -0
  63. package/src/v3/tests/instanceof.test.ts +37 -0
  64. package/src/v3/tests/intersection.test.ts +110 -0
  65. package/src/v3/tests/language-server.source.ts +76 -0
  66. package/src/v3/tests/language-server.test.ts +207 -0
  67. package/src/v3/tests/literal.test.ts +36 -0
  68. package/src/v3/tests/map.test.ts +110 -0
  69. package/src/v3/tests/masking.test.ts +4 -0
  70. package/src/v3/tests/mocker.test.ts +19 -0
  71. package/src/v3/tests/nan.test.ts +21 -0
  72. package/src/v3/tests/nativeEnum.test.ts +87 -0
  73. package/src/v3/tests/nullable.test.ts +42 -0
  74. package/src/v3/tests/number.test.ts +176 -0
  75. package/src/v3/tests/object-augmentation.test.ts +29 -0
  76. package/src/v3/tests/object-in-es5-env.test.ts +29 -0
  77. package/src/v3/tests/object.test.ts +434 -0
  78. package/src/v3/tests/optional.test.ts +42 -0
  79. package/src/v3/tests/parseUtil.test.ts +23 -0
  80. package/src/v3/tests/parser.test.ts +41 -0
  81. package/src/v3/tests/partials.test.ts +243 -0
  82. package/src/v3/tests/pickomit.test.ts +111 -0
  83. package/src/v3/tests/pipeline.test.ts +29 -0
  84. package/src/v3/tests/preprocess.test.ts +186 -0
  85. package/src/v3/tests/primitive.test.ts +440 -0
  86. package/src/v3/tests/promise.test.ts +90 -0
  87. package/src/v3/tests/readonly.test.ts +194 -0
  88. package/src/v3/tests/record.test.ts +171 -0
  89. package/src/v3/tests/recursive.test.ts +197 -0
  90. package/src/v3/tests/refine.test.ts +313 -0
  91. package/src/v3/tests/safeparse.test.ts +27 -0
  92. package/src/v3/tests/set.test.ts +142 -0
  93. package/src/v3/tests/standard-schema.test.ts +83 -0
  94. package/src/v3/tests/string.test.ts +916 -0
  95. package/src/v3/tests/transformer.test.ts +233 -0
  96. package/src/v3/tests/tuple.test.ts +90 -0
  97. package/src/v3/tests/unions.test.ts +57 -0
  98. package/src/v3/tests/validations.test.ts +133 -0
  99. package/src/v3/tests/void.test.ts +15 -0
  100. package/src/v3/types.ts +5136 -0
  101. package/src/{checks.ts → v4/classic/checks.ts} +1 -1
  102. package/src/v4/classic/coerce.ts +27 -0
  103. package/src/{compat.ts → v4/classic/compat.ts} +3 -13
  104. package/src/v4/classic/errors.ts +75 -0
  105. package/src/v4/classic/external.ts +50 -0
  106. package/src/v4/classic/index.ts +5 -0
  107. package/src/{iso.ts → v4/classic/iso.ts} +1 -1
  108. package/src/{parse.ts → v4/classic/parse.ts} +13 -12
  109. package/src/{schemas.ts → v4/classic/schemas.ts} +430 -417
  110. package/src/v4/classic/tests/anyunknown.test.ts +26 -0
  111. package/src/v4/classic/tests/array.test.ts +264 -0
  112. package/src/v4/classic/tests/assignability.test.ts +210 -0
  113. package/src/v4/classic/tests/async-parsing.test.ts +381 -0
  114. package/src/v4/classic/tests/async-refinements.test.ts +68 -0
  115. package/src/v4/classic/tests/base.test.ts +7 -0
  116. package/src/v4/classic/tests/bigint.test.ts +54 -0
  117. package/src/v4/classic/tests/brand.test.ts +63 -0
  118. package/src/v4/classic/tests/catch.test.ts +252 -0
  119. package/src/v4/classic/tests/coalesce.test.ts +20 -0
  120. package/src/v4/classic/tests/coerce.test.ts +160 -0
  121. package/src/v4/classic/tests/continuability.test.ts +352 -0
  122. package/src/v4/classic/tests/custom.test.ts +40 -0
  123. package/src/v4/classic/tests/date.test.ts +31 -0
  124. package/src/v4/classic/tests/datetime.test.ts +296 -0
  125. package/src/v4/classic/tests/default.test.ts +313 -0
  126. package/src/v4/classic/tests/description.test.ts +32 -0
  127. package/src/v4/classic/tests/discriminated-unions.test.ts +619 -0
  128. package/src/v4/classic/tests/enum.test.ts +285 -0
  129. package/src/v4/classic/tests/error-utils.test.ts +552 -0
  130. package/src/v4/classic/tests/error.test.ts +711 -0
  131. package/src/v4/classic/tests/file.test.ts +91 -0
  132. package/src/v4/classic/tests/firstparty.test.ts +175 -0
  133. package/src/v4/classic/tests/function.test.ts +268 -0
  134. package/src/v4/classic/tests/generics.test.ts +72 -0
  135. package/src/v4/classic/tests/index.test.ts +829 -0
  136. package/src/v4/classic/tests/instanceof.test.ts +34 -0
  137. package/src/v4/classic/tests/intersection.test.ts +171 -0
  138. package/src/v4/classic/tests/json.test.ts +108 -0
  139. package/src/v4/classic/tests/lazy.test.ts +227 -0
  140. package/src/v4/classic/tests/literal.test.ts +92 -0
  141. package/src/v4/classic/tests/map.test.ts +196 -0
  142. package/src/v4/classic/tests/nan.test.ts +21 -0
  143. package/src/v4/classic/tests/nested-refine.test.ts +168 -0
  144. package/src/v4/classic/tests/nonoptional.test.ts +86 -0
  145. package/src/v4/classic/tests/nullable.test.ts +22 -0
  146. package/src/v4/classic/tests/number.test.ts +247 -0
  147. package/src/v4/classic/tests/object.test.ts +563 -0
  148. package/src/v4/classic/tests/optional.test.ts +123 -0
  149. package/src/v4/classic/tests/partial.test.ts +147 -0
  150. package/src/v4/classic/tests/pickomit.test.ts +127 -0
  151. package/src/v4/classic/tests/pipe.test.ts +81 -0
  152. package/src/v4/classic/tests/prefault.test.ts +37 -0
  153. package/src/v4/classic/tests/preprocess.test.ts +298 -0
  154. package/src/v4/classic/tests/primitive.test.ts +175 -0
  155. package/src/v4/classic/tests/promise.test.ts +81 -0
  156. package/src/v4/classic/tests/prototypes.test.ts +23 -0
  157. package/src/v4/classic/tests/readonly.test.ts +252 -0
  158. package/src/v4/classic/tests/record.test.ts +342 -0
  159. package/src/v4/classic/tests/recursive-types.test.ts +356 -0
  160. package/src/v4/classic/tests/refine.test.ts +532 -0
  161. package/src/v4/classic/tests/registries.test.ts +204 -0
  162. package/src/v4/classic/tests/set.test.ts +179 -0
  163. package/src/v4/classic/tests/standard-schema.test.ts +57 -0
  164. package/src/v4/classic/tests/string-formats.test.ts +109 -0
  165. package/src/v4/classic/tests/string.test.ts +881 -0
  166. package/src/v4/classic/tests/stringbool.test.ts +66 -0
  167. package/src/v4/classic/tests/template-literal.test.ts +758 -0
  168. package/src/v4/classic/tests/to-json-schema.test.ts +2314 -0
  169. package/src/v4/classic/tests/transform.test.ts +250 -0
  170. package/src/v4/classic/tests/tuple.test.ts +163 -0
  171. package/src/v4/classic/tests/union.test.ts +94 -0
  172. package/src/v4/classic/tests/validations.test.ts +283 -0
  173. package/src/v4/classic/tests/void.test.ts +12 -0
  174. package/src/v4/core/api.ts +1594 -0
  175. package/src/v4/core/checks.ts +1283 -0
  176. package/src/v4/core/config.ts +15 -0
  177. package/src/v4/core/core.ts +134 -0
  178. package/src/v4/core/doc.ts +44 -0
  179. package/src/v4/core/errors.ts +426 -0
  180. package/src/v4/core/function.ts +176 -0
  181. package/src/v4/core/index.ts +15 -0
  182. package/src/v4/core/json-schema.ts +143 -0
  183. package/src/v4/core/parse.ts +94 -0
  184. package/src/v4/core/regexes.ts +135 -0
  185. package/src/v4/core/registries.ts +96 -0
  186. package/src/v4/core/schemas.ts +3842 -0
  187. package/src/v4/core/standard-schema.ts +64 -0
  188. package/src/v4/core/tests/index.test.ts +46 -0
  189. package/src/v4/core/tests/locales/be.test.ts +124 -0
  190. package/src/v4/core/tests/locales/en.test.ts +22 -0
  191. package/src/v4/core/tests/locales/ru.test.ts +128 -0
  192. package/src/v4/core/tests/locales/tr.test.ts +69 -0
  193. package/src/v4/core/to-json-schema.ts +977 -0
  194. package/src/v4/core/util.ts +775 -0
  195. package/src/v4/core/versions.ts +5 -0
  196. package/src/v4/core/zsf.ts +323 -0
  197. package/src/v4/index.ts +4 -0
  198. package/src/v4/locales/ar.ts +125 -0
  199. package/src/v4/locales/az.ts +121 -0
  200. package/src/v4/locales/be.ts +184 -0
  201. package/src/v4/locales/ca.ts +127 -0
  202. package/src/v4/locales/cs.ts +142 -0
  203. package/src/v4/locales/de.ts +124 -0
  204. package/src/v4/locales/en.ts +127 -0
  205. package/src/v4/locales/eo.ts +125 -0
  206. package/src/v4/locales/es.ts +125 -0
  207. package/src/v4/locales/fa.ts +134 -0
  208. package/src/v4/locales/fi.ts +131 -0
  209. package/src/v4/locales/fr-CA.ts +126 -0
  210. package/src/v4/locales/fr.ts +124 -0
  211. package/src/v4/locales/he.ts +125 -0
  212. package/src/v4/locales/hu.ts +126 -0
  213. package/src/v4/locales/id.ts +125 -0
  214. package/src/v4/locales/index.ts +39 -0
  215. package/src/v4/locales/it.ts +125 -0
  216. package/src/v4/locales/ja.ts +122 -0
  217. package/src/v4/locales/kh.ts +126 -0
  218. package/src/v4/locales/ko.ts +131 -0
  219. package/src/v4/locales/mk.ts +127 -0
  220. package/src/v4/locales/ms.ts +124 -0
  221. package/src/v4/locales/nl.ts +126 -0
  222. package/src/v4/locales/no.ts +124 -0
  223. package/src/v4/locales/ota.ts +125 -0
  224. package/src/v4/locales/pl.ts +126 -0
  225. package/src/v4/locales/ps.ts +133 -0
  226. package/src/v4/locales/pt.ts +123 -0
  227. package/src/v4/locales/ru.ts +184 -0
  228. package/src/v4/locales/sl.ts +126 -0
  229. package/src/v4/locales/sv.ts +127 -0
  230. package/src/v4/locales/ta.ts +125 -0
  231. package/src/v4/locales/th.ts +126 -0
  232. package/src/v4/locales/tr.ts +121 -0
  233. package/src/v4/locales/ua.ts +126 -0
  234. package/src/v4/locales/ur.ts +126 -0
  235. package/src/v4/locales/vi.ts +125 -0
  236. package/src/v4/locales/zh-CN.ts +123 -0
  237. package/src/v4/locales/zh-TW.ts +125 -0
  238. package/src/v4/mini/checks.ts +32 -0
  239. package/src/v4/mini/coerce.ts +22 -0
  240. package/src/v4/mini/external.ts +40 -0
  241. package/src/v4/mini/index.ts +3 -0
  242. package/src/v4/mini/iso.ts +62 -0
  243. package/src/v4/mini/parse.ts +1 -0
  244. package/src/v4/mini/schemas.ts +1579 -0
  245. package/src/v4/mini/tests/assignability.test.ts +129 -0
  246. package/src/v4/mini/tests/brand.test.ts +51 -0
  247. package/src/v4/mini/tests/checks.test.ts +144 -0
  248. package/src/v4/mini/tests/computed.test.ts +36 -0
  249. package/src/v4/mini/tests/error.test.ts +22 -0
  250. package/src/v4/mini/tests/functions.test.ts +43 -0
  251. package/src/v4/mini/tests/index.test.ts +871 -0
  252. package/src/v4/mini/tests/number.test.ts +95 -0
  253. package/src/v4/mini/tests/object.test.ts +185 -0
  254. package/src/v4/mini/tests/prototypes.test.ts +43 -0
  255. package/src/v4/mini/tests/recursive-types.test.ts +275 -0
  256. package/src/v4/mini/tests/string.test.ts +299 -0
  257. package/src/v4-mini/index.ts +1 -0
  258. package/v3/ZodError.cjs +138 -0
  259. package/v3/ZodError.d.cts +164 -0
  260. package/v3/ZodError.d.ts +164 -0
  261. package/v3/ZodError.js +133 -0
  262. package/v3/errors.cjs +17 -0
  263. package/v3/errors.d.cts +5 -0
  264. package/v3/errors.d.ts +5 -0
  265. package/v3/errors.js +9 -0
  266. package/v3/external.cjs +22 -0
  267. package/v3/external.d.cts +6 -0
  268. package/v3/external.d.ts +6 -0
  269. package/v3/external.js +6 -0
  270. package/v3/helpers/enumUtil.cjs +2 -0
  271. package/v3/helpers/enumUtil.d.cts +8 -0
  272. package/v3/helpers/enumUtil.d.ts +8 -0
  273. package/v3/helpers/enumUtil.js +1 -0
  274. package/v3/helpers/errorUtil.cjs +9 -0
  275. package/v3/helpers/errorUtil.d.cts +9 -0
  276. package/v3/helpers/errorUtil.d.ts +9 -0
  277. package/v3/helpers/errorUtil.js +6 -0
  278. package/v3/helpers/parseUtil.cjs +124 -0
  279. package/v3/helpers/parseUtil.d.cts +78 -0
  280. package/v3/helpers/parseUtil.d.ts +78 -0
  281. package/v3/helpers/parseUtil.js +109 -0
  282. package/v3/helpers/partialUtil.cjs +2 -0
  283. package/v3/helpers/partialUtil.d.cts +8 -0
  284. package/v3/helpers/partialUtil.d.ts +8 -0
  285. package/v3/helpers/partialUtil.js +1 -0
  286. package/v3/helpers/typeAliases.cjs +2 -0
  287. package/v3/helpers/typeAliases.d.cts +2 -0
  288. package/v3/helpers/typeAliases.d.ts +2 -0
  289. package/v3/helpers/typeAliases.js +1 -0
  290. package/v3/helpers/util.cjs +137 -0
  291. package/v3/helpers/util.d.cts +85 -0
  292. package/v3/helpers/util.d.ts +85 -0
  293. package/v3/helpers/util.js +133 -0
  294. package/{dist/commonjs/index.js → v3/index.cjs} +2 -2
  295. package/v3/index.d.cts +4 -0
  296. package/v3/index.js +4 -0
  297. package/v3/locales/en.cjs +111 -0
  298. package/v3/locales/en.d.cts +3 -0
  299. package/v3/locales/en.d.ts +3 -0
  300. package/v3/locales/en.js +109 -0
  301. package/v3/standard-schema.cjs +2 -0
  302. package/v3/standard-schema.d.cts +102 -0
  303. package/v3/standard-schema.d.ts +102 -0
  304. package/v3/standard-schema.js +1 -0
  305. package/v3/types.cjs +3775 -0
  306. package/v3/types.d.cts +1031 -0
  307. package/v3/types.d.ts +1031 -0
  308. package/v3/types.js +3693 -0
  309. package/{dist/commonjs/checks.js → v4/classic/checks.cjs} +29 -29
  310. package/{dist/esm/checks.d.ts → v4/classic/checks.d.cts} +1 -1
  311. package/{dist/commonjs → v4/classic}/checks.d.ts +1 -1
  312. package/{dist/esm → v4/classic}/checks.js +1 -1
  313. package/{dist/commonjs/coerce.js → v4/classic/coerce.cjs} +2 -2
  314. package/v4/classic/coerce.d.cts +17 -0
  315. package/v4/classic/coerce.d.ts +17 -0
  316. package/{dist/esm → v4/classic}/coerce.js +1 -1
  317. package/{dist/commonjs/compat.js → v4/classic/compat.cjs} +5 -11
  318. package/{dist/esm/compat.d.ts → v4/classic/compat.d.cts} +4 -6
  319. package/{dist/commonjs → v4/classic}/compat.d.ts +3 -5
  320. package/{dist/esm → v4/classic}/compat.js +2 -8
  321. package/v4/classic/errors.cjs +67 -0
  322. package/{dist/commonjs/errors.d.ts → v4/classic/errors.d.cts} +8 -7
  323. package/{dist/esm → v4/classic}/errors.d.ts +8 -7
  324. package/v4/classic/errors.js +41 -0
  325. package/v4/classic/external.cjs +70 -0
  326. package/v4/classic/external.d.cts +13 -0
  327. package/v4/classic/external.d.ts +13 -0
  328. package/v4/classic/external.js +18 -0
  329. package/v4/classic/index.cjs +33 -0
  330. package/v4/classic/index.d.cts +4 -0
  331. package/{dist/commonjs/iso.js → v4/classic/iso.cjs} +2 -2
  332. package/{dist/esm/iso.d.ts → v4/classic/iso.d.cts} +2 -2
  333. package/{dist/commonjs → v4/classic}/iso.d.ts +1 -1
  334. package/{dist/esm → v4/classic}/iso.js +1 -1
  335. package/{dist/commonjs/parse.js → v4/classic/parse.cjs} +7 -9
  336. package/{dist/commonjs/parse.d.ts → v4/classic/parse.d.cts} +10 -4
  337. package/{dist/esm → v4/classic}/parse.d.ts +10 -4
  338. package/v4/classic/parse.js +6 -0
  339. package/{dist/commonjs/schemas.js → v4/classic/schemas.cjs} +167 -138
  340. package/{dist/esm/schemas.d.ts → v4/classic/schemas.d.cts} +176 -196
  341. package/{dist/commonjs → v4/classic}/schemas.d.ts +175 -195
  342. package/{dist/esm → v4/classic}/schemas.js +128 -102
  343. package/v4/core/api.cjs +1039 -0
  344. package/v4/core/api.d.cts +284 -0
  345. package/v4/core/api.d.ts +284 -0
  346. package/v4/core/api.js +906 -0
  347. package/v4/core/checks.cjs +591 -0
  348. package/v4/core/checks.d.cts +278 -0
  349. package/v4/core/checks.d.ts +278 -0
  350. package/v4/core/checks.js +565 -0
  351. package/v4/core/core.cjs +67 -0
  352. package/v4/core/core.d.cts +49 -0
  353. package/v4/core/core.d.ts +49 -0
  354. package/v4/core/core.js +61 -0
  355. package/v4/core/doc.cjs +39 -0
  356. package/v4/core/doc.d.cts +14 -0
  357. package/v4/core/doc.d.ts +14 -0
  358. package/v4/core/doc.js +35 -0
  359. package/v4/core/errors.cjs +226 -0
  360. package/v4/core/errors.d.cts +210 -0
  361. package/v4/core/errors.d.ts +210 -0
  362. package/v4/core/errors.js +195 -0
  363. package/v4/core/function.cjs +102 -0
  364. package/v4/core/function.d.cts +52 -0
  365. package/v4/core/function.d.ts +52 -0
  366. package/v4/core/function.js +75 -0
  367. package/v4/core/index.cjs +44 -0
  368. package/v4/core/index.d.cts +15 -0
  369. package/v4/core/index.d.ts +15 -0
  370. package/v4/core/index.js +15 -0
  371. package/v4/core/json-schema.cjs +2 -0
  372. package/v4/core/json-schema.d.cts +87 -0
  373. package/v4/core/json-schema.d.ts +87 -0
  374. package/v4/core/json-schema.js +1 -0
  375. package/v4/core/parse.cjs +87 -0
  376. package/v4/core/parse.d.cts +25 -0
  377. package/v4/core/parse.d.ts +25 -0
  378. package/v4/core/parse.js +57 -0
  379. package/v4/core/regexes.cjs +103 -0
  380. package/v4/core/regexes.d.cts +61 -0
  381. package/v4/core/regexes.d.ts +61 -0
  382. package/v4/core/regexes.js +95 -0
  383. package/v4/core/registries.cjs +56 -0
  384. package/v4/core/registries.d.cts +35 -0
  385. package/v4/core/registries.d.ts +35 -0
  386. package/v4/core/registries.js +51 -0
  387. package/v4/core/schemas.cjs +1748 -0
  388. package/v4/core/schemas.d.cts +1041 -0
  389. package/v4/core/schemas.d.ts +1041 -0
  390. package/v4/core/schemas.js +1717 -0
  391. package/v4/core/standard-schema.cjs +2 -0
  392. package/v4/core/standard-schema.d.cts +55 -0
  393. package/v4/core/standard-schema.d.ts +55 -0
  394. package/v4/core/standard-schema.js +1 -0
  395. package/v4/core/to-json-schema.cjs +854 -0
  396. package/v4/core/to-json-schema.d.cts +88 -0
  397. package/v4/core/to-json-schema.d.ts +88 -0
  398. package/v4/core/to-json-schema.js +849 -0
  399. package/v4/core/util.cjs +539 -0
  400. package/v4/core/util.d.cts +183 -0
  401. package/v4/core/util.d.ts +183 -0
  402. package/v4/core/util.js +493 -0
  403. package/v4/core/versions.cjs +8 -0
  404. package/v4/core/versions.d.cts +5 -0
  405. package/v4/core/versions.d.ts +5 -0
  406. package/v4/core/versions.js +5 -0
  407. package/v4/index.cjs +22 -0
  408. package/v4/index.d.cts +3 -0
  409. package/v4/index.d.ts +3 -0
  410. package/v4/index.js +3 -0
  411. package/v4/locales/ar.cjs +142 -0
  412. package/v4/locales/ar.d.cts +4 -0
  413. package/v4/locales/ar.d.ts +4 -0
  414. package/v4/locales/ar.js +116 -0
  415. package/v4/locales/az.cjs +141 -0
  416. package/v4/locales/az.d.cts +4 -0
  417. package/v4/locales/az.d.ts +4 -0
  418. package/v4/locales/az.js +115 -0
  419. package/v4/locales/be.cjs +190 -0
  420. package/v4/locales/be.d.cts +4 -0
  421. package/v4/locales/be.d.ts +4 -0
  422. package/v4/locales/be.js +164 -0
  423. package/v4/locales/ca.cjs +144 -0
  424. package/v4/locales/ca.d.cts +4 -0
  425. package/v4/locales/ca.d.ts +4 -0
  426. package/v4/locales/ca.js +118 -0
  427. package/v4/locales/cs.cjs +161 -0
  428. package/v4/locales/cs.d.cts +4 -0
  429. package/v4/locales/cs.d.ts +4 -0
  430. package/v4/locales/cs.js +135 -0
  431. package/v4/locales/de.cjs +142 -0
  432. package/v4/locales/de.d.cts +4 -0
  433. package/v4/locales/de.d.ts +4 -0
  434. package/v4/locales/de.js +116 -0
  435. package/v4/locales/en.cjs +145 -0
  436. package/v4/locales/en.d.cts +5 -0
  437. package/v4/locales/en.d.ts +5 -0
  438. package/v4/locales/en.js +117 -0
  439. package/v4/locales/eo.cjs +144 -0
  440. package/v4/locales/eo.d.cts +5 -0
  441. package/v4/locales/eo.d.ts +5 -0
  442. package/v4/locales/eo.js +116 -0
  443. package/v4/locales/es.cjs +143 -0
  444. package/v4/locales/es.d.cts +4 -0
  445. package/v4/locales/es.d.ts +4 -0
  446. package/v4/locales/es.js +117 -0
  447. package/v4/locales/fa.cjs +148 -0
  448. package/v4/locales/fa.d.cts +4 -0
  449. package/v4/locales/fa.d.ts +4 -0
  450. package/v4/locales/fa.js +122 -0
  451. package/v4/locales/fi.cjs +148 -0
  452. package/v4/locales/fi.d.cts +4 -0
  453. package/v4/locales/fi.d.ts +4 -0
  454. package/v4/locales/fi.js +122 -0
  455. package/v4/locales/fr-CA.cjs +143 -0
  456. package/v4/locales/fr-CA.d.cts +4 -0
  457. package/v4/locales/fr-CA.d.ts +4 -0
  458. package/v4/locales/fr-CA.js +117 -0
  459. package/v4/locales/fr.cjs +142 -0
  460. package/v4/locales/fr.d.cts +4 -0
  461. package/v4/locales/fr.d.ts +4 -0
  462. package/v4/locales/fr.js +116 -0
  463. package/v4/locales/he.cjs +143 -0
  464. package/v4/locales/he.d.cts +4 -0
  465. package/v4/locales/he.d.ts +4 -0
  466. package/v4/locales/he.js +117 -0
  467. package/v4/locales/hu.cjs +143 -0
  468. package/v4/locales/hu.d.cts +4 -0
  469. package/v4/locales/hu.d.ts +4 -0
  470. package/v4/locales/hu.js +117 -0
  471. package/v4/locales/id.cjs +142 -0
  472. package/v4/locales/id.d.cts +4 -0
  473. package/v4/locales/id.d.ts +4 -0
  474. package/v4/locales/id.js +116 -0
  475. package/v4/locales/index.cjs +84 -0
  476. package/v4/locales/index.d.cts +39 -0
  477. package/v4/locales/index.d.ts +39 -0
  478. package/v4/locales/index.js +39 -0
  479. package/v4/locales/it.cjs +143 -0
  480. package/v4/locales/it.d.cts +4 -0
  481. package/v4/locales/it.d.ts +4 -0
  482. package/v4/locales/it.js +117 -0
  483. package/v4/locales/ja.cjs +141 -0
  484. package/v4/locales/ja.d.cts +4 -0
  485. package/v4/locales/ja.d.ts +4 -0
  486. package/v4/locales/ja.js +115 -0
  487. package/v4/locales/kh.cjs +143 -0
  488. package/v4/locales/kh.d.cts +4 -0
  489. package/v4/locales/kh.d.ts +4 -0
  490. package/v4/locales/kh.js +117 -0
  491. package/v4/locales/ko.cjs +147 -0
  492. package/v4/locales/ko.d.cts +4 -0
  493. package/v4/locales/ko.d.ts +4 -0
  494. package/v4/locales/ko.js +121 -0
  495. package/v4/locales/mk.cjs +144 -0
  496. package/v4/locales/mk.d.cts +4 -0
  497. package/v4/locales/mk.d.ts +4 -0
  498. package/v4/locales/mk.js +118 -0
  499. package/v4/locales/ms.cjs +142 -0
  500. package/v4/locales/ms.d.cts +4 -0
  501. package/v4/locales/ms.d.ts +4 -0
  502. package/v4/locales/ms.js +116 -0
  503. package/v4/locales/nl.cjs +143 -0
  504. package/v4/locales/nl.d.cts +4 -0
  505. package/v4/locales/nl.d.ts +4 -0
  506. package/v4/locales/nl.js +117 -0
  507. package/v4/locales/no.cjs +142 -0
  508. package/v4/locales/no.d.cts +4 -0
  509. package/v4/locales/no.d.ts +4 -0
  510. package/v4/locales/no.js +116 -0
  511. package/v4/locales/ota.cjs +143 -0
  512. package/v4/locales/ota.d.cts +4 -0
  513. package/v4/locales/ota.d.ts +4 -0
  514. package/v4/locales/ota.js +117 -0
  515. package/v4/locales/pl.cjs +143 -0
  516. package/v4/locales/pl.d.cts +4 -0
  517. package/v4/locales/pl.d.ts +4 -0
  518. package/v4/locales/pl.js +117 -0
  519. package/v4/locales/ps.cjs +148 -0
  520. package/v4/locales/ps.d.cts +4 -0
  521. package/v4/locales/ps.d.ts +4 -0
  522. package/v4/locales/ps.js +122 -0
  523. package/v4/locales/pt.cjs +142 -0
  524. package/v4/locales/pt.d.cts +4 -0
  525. package/v4/locales/pt.d.ts +4 -0
  526. package/v4/locales/pt.js +116 -0
  527. package/v4/locales/ru.cjs +190 -0
  528. package/v4/locales/ru.d.cts +4 -0
  529. package/v4/locales/ru.d.ts +4 -0
  530. package/v4/locales/ru.js +164 -0
  531. package/v4/locales/sl.cjs +143 -0
  532. package/v4/locales/sl.d.cts +4 -0
  533. package/v4/locales/sl.d.ts +4 -0
  534. package/v4/locales/sl.js +117 -0
  535. package/v4/locales/sv.cjs +144 -0
  536. package/v4/locales/sv.d.cts +4 -0
  537. package/v4/locales/sv.d.ts +4 -0
  538. package/v4/locales/sv.js +118 -0
  539. package/v4/locales/ta.cjs +143 -0
  540. package/v4/locales/ta.d.cts +4 -0
  541. package/v4/locales/ta.d.ts +4 -0
  542. package/v4/locales/ta.js +117 -0
  543. package/v4/locales/th.cjs +143 -0
  544. package/v4/locales/th.d.cts +4 -0
  545. package/v4/locales/th.d.ts +4 -0
  546. package/v4/locales/th.js +117 -0
  547. package/v4/locales/tr.cjs +143 -0
  548. package/v4/locales/tr.d.cts +5 -0
  549. package/v4/locales/tr.d.ts +5 -0
  550. package/v4/locales/tr.js +115 -0
  551. package/v4/locales/ua.cjs +143 -0
  552. package/v4/locales/ua.d.cts +4 -0
  553. package/v4/locales/ua.d.ts +4 -0
  554. package/v4/locales/ua.js +117 -0
  555. package/v4/locales/ur.cjs +143 -0
  556. package/v4/locales/ur.d.cts +4 -0
  557. package/v4/locales/ur.d.ts +4 -0
  558. package/v4/locales/ur.js +117 -0
  559. package/v4/locales/vi.cjs +142 -0
  560. package/v4/locales/vi.d.cts +4 -0
  561. package/v4/locales/vi.d.ts +4 -0
  562. package/v4/locales/vi.js +116 -0
  563. package/v4/locales/zh-CN.cjs +142 -0
  564. package/v4/locales/zh-CN.d.cts +4 -0
  565. package/v4/locales/zh-CN.d.ts +4 -0
  566. package/v4/locales/zh-CN.js +116 -0
  567. package/v4/locales/zh-TW.cjs +143 -0
  568. package/v4/locales/zh-TW.d.cts +4 -0
  569. package/v4/locales/zh-TW.d.ts +4 -0
  570. package/v4/locales/zh-TW.js +117 -0
  571. package/v4/mini/checks.cjs +34 -0
  572. package/v4/mini/checks.d.cts +1 -0
  573. package/v4/mini/checks.d.ts +1 -0
  574. package/v4/mini/checks.js +1 -0
  575. package/{dist/commonjs/errors.js → v4/mini/coerce.cjs} +21 -25
  576. package/v4/mini/coerce.d.cts +7 -0
  577. package/v4/mini/coerce.d.ts +7 -0
  578. package/v4/mini/coerce.js +17 -0
  579. package/v4/mini/external.cjs +62 -0
  580. package/v4/mini/external.d.cts +11 -0
  581. package/v4/mini/external.d.ts +11 -0
  582. package/v4/mini/external.js +13 -0
  583. package/v4/mini/index.cjs +32 -0
  584. package/v4/mini/index.d.cts +3 -0
  585. package/v4/mini/index.d.ts +3 -0
  586. package/v4/mini/index.js +3 -0
  587. package/v4/mini/iso.cjs +60 -0
  588. package/v4/mini/iso.d.cts +22 -0
  589. package/v4/mini/iso.d.ts +22 -0
  590. package/v4/mini/iso.js +30 -0
  591. package/v4/mini/parse.cjs +8 -0
  592. package/v4/mini/parse.d.cts +1 -0
  593. package/v4/mini/parse.d.ts +1 -0
  594. package/v4/mini/parse.js +1 -0
  595. package/v4/mini/schemas.cjs +839 -0
  596. package/v4/mini/schemas.d.cts +356 -0
  597. package/v4/mini/schemas.d.ts +356 -0
  598. package/v4/mini/schemas.js +732 -0
  599. package/v4-mini/index.cjs +17 -0
  600. package/v4-mini/index.d.cts +1 -0
  601. package/v4-mini/index.d.ts +1 -0
  602. package/v4-mini/index.js +1 -0
  603. package/dist/commonjs/coerce.d.ts +0 -17
  604. package/dist/commonjs/external.d.ts +0 -8
  605. package/dist/commonjs/external.js +0 -58
  606. package/dist/commonjs/package.json +0 -3
  607. package/dist/esm/coerce.d.ts +0 -17
  608. package/dist/esm/errors.js +0 -24
  609. package/dist/esm/external.d.ts +0 -8
  610. package/dist/esm/external.js +0 -14
  611. package/dist/esm/package.json +0 -3
  612. package/dist/esm/parse.js +0 -8
  613. package/src/coerce.ts +0 -27
  614. package/src/errors.ts +0 -50
  615. package/src/external.ts +0 -30
  616. package/{dist/esm → v3}/index.d.ts +1 -1
  617. /package/{dist/commonjs → v4/classic}/index.d.ts +0 -0
  618. /package/{dist/esm → v4/classic}/index.js +0 -0
@@ -1,21 +1,24 @@
1
- import * as core from "@zod/core";
2
- import { util } from "@zod/core";
3
- import * as parse from "./parse.js";
4
- export * as iso from "./iso.js";
5
- export * as coerce from "./coerce.js";
1
+ import * as core from "../core/index.cjs";
2
+ import { util } from "../core/index.cjs";
3
+ import * as parse from "./parse.cjs";
6
4
  export interface RefinementCtx<T = unknown> extends core.ParsePayload<T> {
7
5
  addIssue(arg: string | core.$ZodRawIssue | Partial<core.$ZodIssueCustom>): void;
8
6
  }
9
- export interface ZodType<out Output = unknown, out Input = unknown> extends core.$ZodType<Output, Input> {
10
- def: this["_zod"]["def"];
7
+ export interface ZodType<out Output = unknown, out Input = unknown, out Internals extends core.$ZodTypeInternals<Output, Input> = core.$ZodTypeInternals<Output, Input>> extends core.$ZodType<Output, Input, Internals> {
8
+ def: Internals["def"];
9
+ type: Internals["def"]["type"];
11
10
  /** @deprecated Use `.def` instead. */
12
- _def: this["_zod"]["def"];
13
- _output: core.output<this>;
14
- _input: core.input<this>;
11
+ _def: Internals["def"];
12
+ /** @deprecated Use `z.output<typeof schema>` instead. */
13
+ _output: Internals["output"];
14
+ /** @deprecated Use `z.input<typeof schema>` instead. */
15
+ _input: Internals["input"];
15
16
  check(...checks: (core.CheckFn<core.output<this>> | core.$ZodCheck<core.output<this>>)[]): this;
16
- clone(def?: this["_zod"]["def"]): this;
17
- register<R extends core.$ZodRegistry>(registry: R, ...meta: this extends R["_schema"] ? undefined extends R["_meta"] ? [core.$ZodRegistry<R["_meta"], this>["_meta"]?] : [core.$ZodRegistry<R["_meta"], this>["_meta"]] : ["Incompatible schema"]): this;
18
- brand<T extends PropertyKey = PropertyKey>(value?: T): PropertyKey extends T ? this : this & Record<"_zod", Record<"~output", core.output<this> & core.$brand<T>>>;
17
+ clone(def?: Internals["def"], params?: {
18
+ parent: boolean;
19
+ }): this;
20
+ register<R extends core.$ZodRegistry>(registry: R, ...meta: this extends R["_schema"] ? undefined extends R["_meta"] ? [core.$replace<R["_meta"], this>?] : [core.$replace<R["_meta"], this>] : ["Incompatible schema"]): this;
21
+ brand<T extends PropertyKey = PropertyKey>(value?: T): PropertyKey extends T ? this : core.$ZodBranded<this, T>;
19
22
  parse(data: unknown, params?: core.ParseContext<core.$ZodIssue>): core.output<this>;
20
23
  safeParse(data: unknown, params?: core.ParseContext<core.$ZodIssue>): parse.ZodSafeParseResult<core.output<this>>;
21
24
  parseAsync(data: unknown, params?: core.ParseContext<core.$ZodIssue>): Promise<core.output<this>>;
@@ -23,21 +26,23 @@ export interface ZodType<out Output = unknown, out Input = unknown> extends core
23
26
  spa: (data: unknown, params?: core.ParseContext<core.$ZodIssue>) => Promise<parse.ZodSafeParseResult<core.output<this>>>;
24
27
  refine(check: (arg: core.output<this>) => unknown | Promise<unknown>, params?: string | core.$ZodCustomParams): this;
25
28
  /** @deprecated Use `.check()` instead. */
26
- superRefine(refinement: (arg: core.output<this>, ctx: RefinementCtx<this["_zod"]["output"]>) => void | Promise<void>): this;
29
+ superRefine(refinement: (arg: core.output<this>, ctx: RefinementCtx<core.output<this>>) => void | Promise<void>): this;
27
30
  overwrite(fn: (x: core.output<this>) => core.output<this>): this;
28
- optional(params?: string | core.$ZodOptionalParams): ZodOptional<this>;
31
+ optional(): ZodOptional<this>;
29
32
  nonoptional(params?: string | core.$ZodNonOptionalParams): ZodNonOptional<this>;
30
- nullable(params?: string | core.$ZodNullableParams): ZodNullable<this>;
33
+ nullable(): ZodNullable<this>;
31
34
  nullish(): ZodOptional<ZodNullable<this>>;
32
- default(def: util.NoUndefined<core.output<this>>, params?: string | core.$ZodDefaultParams): ZodDefault<this>;
33
- default(def: () => util.NoUndefined<core.output<this>>, params?: string | core.$ZodDefaultParams): ZodDefault<this>;
35
+ default(def: core.output<this>): ZodDefault<this>;
36
+ default(def: () => util.NoUndefined<core.output<this>>): ZodDefault<this>;
37
+ prefault(def: () => core.input<this>): ZodPrefault<this>;
38
+ prefault(def: core.input<this>): ZodPrefault<this>;
34
39
  array(): ZodArray<this>;
35
- or<T extends core.$ZodType>(option: T): ZodUnion<[this, T]>;
36
- and<T extends core.$ZodType>(incoming: T): ZodIntersection<this, T>;
40
+ or<T extends core.SomeType>(option: T): ZodUnion<[this, T]>;
41
+ and<T extends core.SomeType>(incoming: T): ZodIntersection<this, T>;
37
42
  transform<NewOut>(transform: (arg: core.output<this>, ctx: RefinementCtx<core.output<this>>) => NewOut | Promise<NewOut>): ZodPipe<this, ZodTransform<Awaited<NewOut>, core.output<this>>>;
38
43
  catch(def: core.output<this>): ZodCatch<this>;
39
44
  catch(def: (ctx: core.$ZodCatchCtx) => core.output<this>): ZodCatch<this>;
40
- pipe<T extends core.$ZodType<any, this["_zod"]["output"]>>(target: T | core.$ZodType<any, this["_zod"]["output"]>): ZodPipe<this, T>;
45
+ pipe<T extends core.$ZodType<any, core.output<this>>>(target: T | core.$ZodType<any, core.output<this>>): ZodPipe<this, T>;
41
46
  readonly(): ZodReadonly<this>;
42
47
  /** Returns a new instance that has been registered in `z.globalRegistry` with the specified description */
43
48
  describe(description: string): this;
@@ -46,20 +51,33 @@ export interface ZodType<out Output = unknown, out Input = unknown> extends core
46
51
  meta(): core.$replace<core.GlobalMeta, this> | undefined;
47
52
  /** Returns a new instance that has been registered in `z.globalRegistry` with the specified metadata */
48
53
  meta(data: core.$replace<core.GlobalMeta, this>): this;
54
+ /** @deprecated Try safe-parsing `undefined` (this is what `isOptional` does internally):
55
+ *
56
+ * ```ts
57
+ * const schema = z.string().optional();
58
+ * const isOptional = schema.safeParse(undefined).success; // true
59
+ * ```
60
+ */
49
61
  isOptional(): boolean;
62
+ /**
63
+ * @deprecated Try safe-parsing `null` (this is what `isNullable` does internally):
64
+ *
65
+ * ```ts
66
+ * const schema = z.string().nullable();
67
+ * const isNullable = schema.safeParse(null).success; // true
68
+ * ```
69
+ */
50
70
  isNullable(): boolean;
51
71
  }
72
+ export interface _ZodType<out Internals extends core.$ZodTypeInternals = core.$ZodTypeInternals> extends ZodType<any, any, Internals> {
73
+ }
52
74
  export declare const ZodType: core.$constructor<ZodType>;
53
- export interface _ZodString<Input = unknown> extends ZodType {
54
- _zod: core.$ZodStringInternals<Input>;
75
+ export interface _ZodString<T extends core.$ZodStringInternals<unknown> = core.$ZodStringInternals<unknown>> extends _ZodType<T> {
55
76
  format: string | null;
56
77
  minLength: number | null;
57
78
  maxLength: number | null;
58
79
  regex(regex: RegExp, params?: string | core.$ZodCheckRegexParams): this;
59
- includes(value: string, params?: {
60
- message?: string;
61
- position?: number;
62
- }): this;
80
+ includes(value: string, params?: core.$ZodCheckIncludesParams): this;
63
81
  startsWith(value: string, params?: string | core.$ZodCheckStartsWithParams): this;
64
82
  endsWith(value: string, params?: string | core.$ZodCheckEndsWithParams): this;
65
83
  min(minLength: number, params?: string | core.$ZodCheckMinLengthParams): this;
@@ -73,8 +91,9 @@ export interface _ZodString<Input = unknown> extends ZodType {
73
91
  toLowerCase(): this;
74
92
  toUpperCase(): this;
75
93
  }
94
+ /** @internal */
76
95
  export declare const _ZodString: core.$constructor<_ZodString>;
77
- export interface ZodString extends _ZodString<string> {
96
+ export interface ZodString extends _ZodString<core.$ZodStringInternals<string>> {
78
97
  /** @deprecated Use `z.email()` instead. */
79
98
  email(params?: string | core.$ZodCheckEmailParams): this;
80
99
  /** @deprecated Use `z.url()` instead. */
@@ -132,8 +151,8 @@ export interface ZodString extends _ZodString<string> {
132
151
  }
133
152
  export declare const ZodString: core.$constructor<ZodString>;
134
153
  export declare function string(params?: string | core.$ZodStringParams): ZodString;
135
- export interface ZodStringFormat<Format extends core.$ZodStringFormats = core.$ZodStringFormats> extends _ZodString {
136
- _zod: core.$ZodStringFormatInternals<Format>;
154
+ export declare function string<T extends string>(params?: string | core.$ZodStringParams): core.$ZodType<T, T>;
155
+ export interface ZodStringFormat<Format extends string = string> extends _ZodString<core.$ZodStringFormatInternals<Format>> {
137
156
  }
138
157
  export declare const ZodStringFormat: core.$constructor<ZodStringFormat>;
139
158
  export interface ZodEmail extends ZodStringFormat<"email"> {
@@ -234,8 +253,12 @@ export interface ZodJWT extends ZodStringFormat<"jwt"> {
234
253
  }
235
254
  export declare const ZodJWT: core.$constructor<ZodJWT>;
236
255
  export declare function jwt(params?: string | core.$ZodJWTParams): ZodJWT;
237
- export interface _ZodNumber<Input = unknown> extends ZodType {
238
- _zod: core.$ZodNumberInternals<Input>;
256
+ export interface ZodCustomStringFormat<Format extends string = string> extends ZodStringFormat<Format>, core.$ZodCustomStringFormat<Format> {
257
+ _zod: core.$ZodCustomStringFormatInternals<Format>;
258
+ }
259
+ export declare const ZodCustomStringFormat: core.$constructor<ZodCustomStringFormat>;
260
+ export declare function stringFormat<Format extends string>(format: Format, fnOrRegex: ((arg: string) => util.MaybeAsync<unknown>) | RegExp, _params?: string | core.$ZodStringFormatParams): ZodCustomStringFormat<Format>;
261
+ export interface _ZodNumber<Internals extends core.$ZodNumberInternals = core.$ZodNumberInternals> extends _ZodType<Internals> {
239
262
  gt(value: number, params?: string | core.$ZodCheckGreaterThanParams): this;
240
263
  /** Identical to .min() */
241
264
  gte(value: number, params?: string | core.$ZodCheckGreaterThanParams): this;
@@ -256,7 +279,7 @@ export interface _ZodNumber<Input = unknown> extends ZodType {
256
279
  /** @deprecated Use `.multipleOf()` instead. */
257
280
  step(value: number, params?: string | core.$ZodCheckMultipleOfParams): this;
258
281
  /** @deprecated In v4 and later, z.number() does not allow infinite values by default. This is a no-op. */
259
- finite(params?: any): this;
282
+ finite(params?: unknown): this;
260
283
  minValue: number | null;
261
284
  maxValue: number | null;
262
285
  /** @deprecated Check the `format` property instead. */
@@ -265,7 +288,7 @@ export interface _ZodNumber<Input = unknown> extends ZodType {
265
288
  isFinite: boolean;
266
289
  format: string | null;
267
290
  }
268
- export interface ZodNumber extends _ZodNumber<number> {
291
+ export interface ZodNumber extends _ZodNumber<core.$ZodNumberInternals<number>> {
269
292
  }
270
293
  export declare const ZodNumber: core.$constructor<ZodNumber>;
271
294
  export declare function number(params?: string | core.$ZodNumberParams): ZodNumber;
@@ -288,15 +311,13 @@ export declare function int32(params?: string | core.$ZodCheckNumberFormatParams
288
311
  export interface ZodUInt32 extends ZodNumberFormat {
289
312
  }
290
313
  export declare function uint32(params?: string | core.$ZodCheckNumberFormatParams): ZodUInt32;
291
- export interface _ZodBoolean<T = unknown> extends ZodType {
292
- _zod: core.$ZodBooleanInternals<T>;
314
+ export interface _ZodBoolean<T extends core.$ZodBooleanInternals = core.$ZodBooleanInternals> extends _ZodType<T> {
293
315
  }
294
- export interface ZodBoolean extends _ZodBoolean<boolean> {
316
+ export interface ZodBoolean extends _ZodBoolean<core.$ZodBooleanInternals<boolean>> {
295
317
  }
296
318
  export declare const ZodBoolean: core.$constructor<ZodBoolean>;
297
319
  export declare function boolean(params?: string | core.$ZodBooleanParams): ZodBoolean;
298
- export interface _ZodBigInt<T = unknown> extends ZodType {
299
- _zod: core.$ZodBigIntInternals<T>;
320
+ export interface _ZodBigInt<T extends core.$ZodBigIntInternals = core.$ZodBigIntInternals> extends _ZodType<T> {
300
321
  gte(value: bigint, params?: string | core.$ZodCheckGreaterThanParams): this;
301
322
  /** Alias of `.gte()` */
302
323
  min(value: bigint, params?: string | core.$ZodCheckGreaterThanParams): this;
@@ -314,7 +335,7 @@ export interface _ZodBigInt<T = unknown> extends ZodType {
314
335
  maxValue: bigint | null;
315
336
  format: string | null;
316
337
  }
317
- export interface ZodBigInt extends _ZodBigInt<bigint> {
338
+ export interface ZodBigInt extends _ZodBigInt<core.$ZodBigIntInternals<bigint>> {
318
339
  }
319
340
  export declare const ZodBigInt: core.$constructor<ZodBigInt>;
320
341
  export declare function bigint(params?: string | core.$ZodBigIntParams): ZodBigInt;
@@ -324,46 +345,38 @@ export interface ZodBigIntFormat extends ZodBigInt {
324
345
  export declare const ZodBigIntFormat: core.$constructor<ZodBigIntFormat>;
325
346
  export declare function int64(params?: string | core.$ZodBigIntFormatParams): ZodBigIntFormat;
326
347
  export declare function uint64(params?: string | core.$ZodBigIntFormatParams): ZodBigIntFormat;
327
- export interface ZodSymbol extends ZodType {
328
- _zod: core.$ZodSymbolInternals;
348
+ export interface ZodSymbol extends _ZodType<core.$ZodSymbolInternals> {
329
349
  }
330
350
  export declare const ZodSymbol: core.$constructor<ZodSymbol>;
331
351
  export declare function symbol(params?: string | core.$ZodSymbolParams): ZodSymbol;
332
- export interface ZodUndefined extends ZodType {
333
- _zod: core.$ZodUndefinedInternals;
352
+ export interface ZodUndefined extends _ZodType<core.$ZodUndefinedInternals> {
334
353
  }
335
354
  export declare const ZodUndefined: core.$constructor<ZodUndefined>;
336
355
  declare function _undefined(params?: string | core.$ZodUndefinedParams): ZodUndefined;
337
356
  export { _undefined as undefined };
338
- export interface ZodNull extends ZodType {
339
- _zod: core.$ZodNullInternals;
357
+ export interface ZodNull extends _ZodType<core.$ZodNullInternals> {
340
358
  }
341
359
  export declare const ZodNull: core.$constructor<ZodNull>;
342
360
  declare function _null(params?: string | core.$ZodNullParams): ZodNull;
343
361
  export { _null as null };
344
- export interface ZodAny extends ZodType {
345
- _zod: core.$ZodAnyInternals;
362
+ export interface ZodAny extends _ZodType<core.$ZodAnyInternals> {
346
363
  }
347
364
  export declare const ZodAny: core.$constructor<ZodAny>;
348
- export declare function any(params?: string | core.$ZodAnyParams): ZodAny;
349
- export interface ZodUnknown extends ZodType {
350
- _zod: core.$ZodUnknownInternals;
365
+ export declare function any(): ZodAny;
366
+ export interface ZodUnknown extends _ZodType<core.$ZodUnknownInternals> {
351
367
  }
352
368
  export declare const ZodUnknown: core.$constructor<ZodUnknown>;
353
- export declare function unknown(params?: string | core.$ZodUnknownParams): ZodUnknown;
354
- export interface ZodNever extends ZodType {
355
- _zod: core.$ZodNeverInternals;
369
+ export declare function unknown(): ZodUnknown;
370
+ export interface ZodNever extends _ZodType<core.$ZodNeverInternals> {
356
371
  }
357
372
  export declare const ZodNever: core.$constructor<ZodNever>;
358
373
  export declare function never(params?: string | core.$ZodNeverParams): ZodNever;
359
- export interface ZodVoid extends ZodType {
360
- _zod: core.$ZodVoidInternals;
374
+ export interface ZodVoid extends _ZodType<core.$ZodVoidInternals> {
361
375
  }
362
376
  export declare const ZodVoid: core.$constructor<ZodVoid>;
363
377
  declare function _void(params?: string | core.$ZodVoidParams): ZodVoid;
364
378
  export { _void as void };
365
- export interface _ZodDate<T = unknown> extends ZodType {
366
- _zod: core.$ZodDateInternals<T>;
379
+ export interface _ZodDate<T extends core.$ZodDateInternals = core.$ZodDateInternals> extends _ZodType<T> {
367
380
  min(value: number | Date, params?: string | core.$ZodCheckGreaterThanParams): this;
368
381
  max(value: number | Date, params?: string | core.$ZodCheckLessThanParams): this;
369
382
  /** @deprecated Not recommended. */
@@ -371,128 +384,105 @@ export interface _ZodDate<T = unknown> extends ZodType {
371
384
  /** @deprecated Not recommended. */
372
385
  maxDate: Date | null;
373
386
  }
374
- export interface ZodDate extends _ZodDate<Date> {
387
+ export interface ZodDate extends _ZodDate<core.$ZodDateInternals<Date>> {
375
388
  }
376
389
  export declare const ZodDate: core.$constructor<ZodDate>;
377
390
  export declare function date(params?: string | core.$ZodDateParams): ZodDate;
378
- export interface ZodArray<T extends core.$ZodType = core.$ZodType> extends ZodType {
379
- _zod: core.$ZodArrayInternals<T>;
391
+ export interface ZodArray<T extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodArrayInternals<T>>, core.$ZodArray<T> {
380
392
  element: T;
381
393
  min(minLength: number, params?: string | core.$ZodCheckMinLengthParams): this;
382
394
  nonempty(params?: string | core.$ZodCheckMinLengthParams): this;
383
395
  max(maxLength: number, params?: string | core.$ZodCheckMaxLengthParams): this;
384
396
  length(len: number, params?: string | core.$ZodCheckLengthEqualsParams): this;
397
+ unwrap(): T;
385
398
  }
386
399
  export declare const ZodArray: core.$constructor<ZodArray>;
387
- export declare function array<T extends core.$ZodType>(element: T, params?: string | core.$ZodArrayParams): ZodArray<T>;
388
- export declare function keyof<T extends ZodObject>(schema: T): ZodLiteral<keyof T["_zod"]["output"]>;
389
- export interface ZodObject<out Shape extends core.$ZodShape = core.$ZodLooseShape, OutExtra extends Record<string, unknown> = Record<string, unknown>, InExtra extends Record<string, unknown> = Record<string, unknown>> extends ZodType {
390
- _zod: core.$ZodObjectInternals<Shape, OutExtra, InExtra>;
400
+ export declare function array<T extends core.SomeType>(element: T, params?: string | core.$ZodArrayParams): ZodArray<T>;
401
+ export declare function keyof<T extends ZodObject>(schema: T): ZodLiteral<Exclude<keyof T["_zod"]["output"], symbol>>;
402
+ export interface ZodObject<
403
+ /** @ts-ignore Cast variance */
404
+ out Shape extends core.$ZodShape = core.$ZodLooseShape, out Config extends core.$ZodObjectConfig = core.$strip> extends _ZodType<core.$ZodObjectInternals<Shape, Config>>, core.$ZodObject<Shape, Config> {
391
405
  shape: Shape;
392
406
  keyof(): ZodEnum<util.ToEnum<keyof Shape & string>>;
393
407
  /** Define a schema to validate all unrecognized keys. This overrides the existing strict/loose behavior. */
394
- catchall<T extends core.$ZodType>(schema: T): ZodObject<Shape, Record<string, T["_zod"]["output"]>>;
408
+ catchall<T extends core.SomeType>(schema: T): ZodObject<Shape, core.$catchall<T>>;
395
409
  /** @deprecated Use `z.looseObject()` or `.loose()` instead. */
396
- passthrough(): ZodObject<Shape, Record<string, unknown>>;
410
+ passthrough(): ZodObject<Shape, core.$loose>;
397
411
  /** Consider `z.looseObject(A.shape)` instead */
398
- loose(): ZodObject<Shape, Record<string, unknown>>;
412
+ loose(): ZodObject<Shape, core.$loose>;
399
413
  /** Consider `z.strictObject(A.shape)` instead */
400
- strict(): ZodObject<Shape, {}>;
414
+ strict(): ZodObject<Shape, core.$strict>;
401
415
  /** This is the default behavior. This method call is likely unnecessary. */
402
- strip(): ZodObject<Shape, {}>;
403
- extend<U extends core.$ZodLooseShape>(shape: U): ZodObject<util.Extend<Shape, U>, OutExtra, InExtra>;
416
+ strip(): ZodObject<Shape, core.$strip>;
417
+ extend<U extends core.$ZodLooseShape & Partial<Record<keyof Shape, core.SomeType>>>(shape: U): ZodObject<util.Extend<Shape, U>, Config>;
404
418
  /**
405
- * @deprecated Use destructuring to merge the shapes:
419
+ * @deprecated Use spread syntax and the `.shape` property to combine two object schemas:
406
420
  *
407
421
  * ```ts
408
- * z.object({
409
- * ...A.shape,
410
- * ...B.shape
411
- * });
412
- * ```
413
- */
414
- merge<U extends ZodObject>(other: U): ZodObject<util.Extend<Shape, U["shape"]>, U["_zod"]["outextra"], U["_zod"]["inextra"]>;
415
- /**
416
- * @deprecated Use destructuring to merge the shapes:
422
+ * const A = z.object({ a: z.string() });
423
+ * const B = z.object({ b: z.number() });
417
424
  *
418
- * ```ts
419
- * z.object({
425
+ * const C = z.object({
420
426
  * ...A.shape,
421
427
  * ...B.shape
422
428
  * });
423
429
  * ```
424
430
  */
425
- pick<M extends util.Exactly<util.Mask<string & keyof Shape>, M>>(mask: M): ZodObject<util.Flatten<Pick<Shape, Extract<keyof Shape, keyof M>>>, OutExtra, InExtra>;
426
- omit<M extends util.Exactly<util.Mask<string & keyof Shape>, M>>(mask: M): ZodObject<util.Flatten<Omit<Shape, Extract<keyof Shape, keyof M>>>, OutExtra, InExtra>;
431
+ merge<U extends ZodObject>(other: U): ZodObject<util.Extend<Shape, U["shape"]>, U["_zod"]["config"]>;
432
+ pick<M extends util.Mask<keyof Shape>>(mask: M): ZodObject<util.Flatten<Pick<Shape, Extract<keyof Shape, keyof M>>>, Config>;
433
+ omit<M extends util.Mask<keyof Shape>>(mask: M): ZodObject<util.Flatten<Omit<Shape, Extract<keyof Shape, keyof M>>>, Config>;
427
434
  partial(): ZodObject<{
428
435
  [k in keyof Shape]: ZodOptional<Shape[k]>;
429
- }, OutExtra, InExtra>;
430
- partial<M extends util.Exactly<util.Mask<string & keyof Shape>, M>>(mask: M): ZodObject<{
436
+ }, Config>;
437
+ partial<M extends util.Mask<keyof Shape>>(mask: M): ZodObject<{
431
438
  [k in keyof Shape]: k extends keyof M ? ZodOptional<Shape[k]> : Shape[k];
432
- }, OutExtra, InExtra>;
439
+ }, Config>;
433
440
  required(): ZodObject<{
434
441
  [k in keyof Shape]: ZodNonOptional<Shape[k]>;
435
- }, OutExtra, InExtra>;
436
- required<M extends util.Exactly<util.Mask<string & keyof Shape>, M>>(mask: M): ZodObject<{
442
+ }, Config>;
443
+ required<M extends util.Mask<keyof Shape>>(mask: M): ZodObject<{
437
444
  [k in keyof Shape]: k extends keyof M ? ZodNonOptional<Shape[k]> : Shape[k];
438
- }, OutExtra, InExtra>;
445
+ }, Config>;
439
446
  }
440
447
  export declare const ZodObject: core.$constructor<ZodObject>;
441
- export declare function object<T extends core.$ZodLooseShape = Record<never, core.$ZodType>>(shape?: T, params?: string | core.$ZodObjectParams): ZodObject<util.Writeable<T> & {}, {}, {}>;
442
- export declare function strictObject<T extends core.$ZodLooseShape>(shape: T, params?: string | core.$ZodObjectParams): ZodObject<T, {}, {}>;
443
- export declare function looseObject<T extends core.$ZodLooseShape>(shape: T, params?: string | core.$ZodObjectParams): ZodObject<T, {
444
- [k: string]: unknown;
445
- }, {
446
- [k: string]: unknown;
447
- }>;
448
- export interface ZodUnion<T extends readonly core.$ZodType[] = readonly core.$ZodType[]> extends ZodType {
449
- _zod: core.$ZodUnionInternals<T>;
448
+ export declare function object<T extends core.$ZodLooseShape = Partial<Record<never, core.SomeType>>>(shape?: T, params?: string | core.$ZodObjectParams): ZodObject<util.Writeable<T>, core.$strip>;
449
+ export declare function strictObject<T extends core.$ZodLooseShape>(shape: T, params?: string | core.$ZodObjectParams): ZodObject<T, core.$strict>;
450
+ export declare function looseObject<T extends core.$ZodLooseShape>(shape: T, params?: string | core.$ZodObjectParams): ZodObject<T, core.$loose>;
451
+ export interface ZodUnion<T extends readonly core.SomeType[] = readonly core.$ZodType[]> extends _ZodType<core.$ZodUnionInternals<T>>, core.$ZodUnion<T> {
450
452
  options: T;
451
453
  }
452
454
  export declare const ZodUnion: core.$constructor<ZodUnion>;
453
- export declare function union<const T extends readonly core.$ZodType[]>(options: T, params?: string | core.$ZodUnionParams): ZodUnion<T>;
454
- export interface ZodDiscriminatedUnion<Options extends readonly core.$ZodType[] = readonly core.$ZodType[]> extends ZodUnion<Options> {
455
+ export declare function union<const T extends readonly core.SomeType[]>(options: T, params?: string | core.$ZodUnionParams): ZodUnion<T>;
456
+ export interface ZodDiscriminatedUnion<Options extends readonly core.SomeType[] = readonly core.$ZodType[]> extends ZodUnion<Options>, core.$ZodDiscriminatedUnion<Options> {
455
457
  _zod: core.$ZodDiscriminatedUnionInternals<Options>;
456
458
  }
457
459
  export declare const ZodDiscriminatedUnion: core.$constructor<ZodDiscriminatedUnion>;
458
- export interface $ZodTypeDiscriminableInternals extends core.$ZodTypeInternals {
459
- disc: util.DiscriminatorMap;
460
- }
461
- export interface $ZodTypeDiscriminable extends ZodType {
462
- _zod: $ZodTypeDiscriminableInternals;
463
- }
464
- export declare function discriminatedUnion<Types extends [$ZodTypeDiscriminable, ...$ZodTypeDiscriminable[]]>(disc: string, options: Types, params?: string | core.$ZodDiscriminatedUnionParams): ZodDiscriminatedUnion<Types>;
465
- export declare function discriminatedUnion<Types extends [$ZodTypeDiscriminable, ...$ZodTypeDiscriminable[]]>(options: Types, params?: string | core.$ZodDiscriminatedUnionParams): ZodDiscriminatedUnion<Types>;
466
- export interface ZodIntersection<A extends core.$ZodType = core.$ZodType, B extends core.$ZodType = core.$ZodType> extends ZodType {
467
- _zod: core.$ZodIntersectionInternals<A, B>;
460
+ export declare function discriminatedUnion<Types extends readonly [core.$ZodTypeDiscriminable, ...core.$ZodTypeDiscriminable[]]>(discriminator: string, options: Types, params?: string | core.$ZodDiscriminatedUnionParams): ZodDiscriminatedUnion<Types>;
461
+ export interface ZodIntersection<A extends core.SomeType = core.$ZodType, B extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodIntersectionInternals<A, B>>, core.$ZodIntersection<A, B> {
468
462
  }
469
463
  export declare const ZodIntersection: core.$constructor<ZodIntersection>;
470
- export declare function intersection<T extends core.$ZodType, U extends core.$ZodType>(left: T, right: U, params?: string | core.$ZodIntersectionParams): ZodIntersection<T, U>;
471
- export interface ZodTuple<T extends util.TupleItems = util.TupleItems, Rest extends core.$ZodType | null = core.$ZodType | null> extends ZodType {
472
- _zod: core.$ZodTupleInternals<T, Rest>;
473
- rest<Rest extends core.$ZodType>(rest: Rest): ZodTuple<T, Rest>;
464
+ export declare function intersection<T extends core.SomeType, U extends core.SomeType>(left: T, right: U): ZodIntersection<T, U>;
465
+ export interface ZodTuple<T extends util.TupleItems = readonly core.$ZodType[], Rest extends core.SomeType | null = core.$ZodType | null> extends _ZodType<core.$ZodTupleInternals<T, Rest>>, core.$ZodTuple<T, Rest> {
466
+ rest<Rest extends core.SomeType = core.$ZodType>(rest: Rest): ZodTuple<T, Rest>;
474
467
  }
475
468
  export declare const ZodTuple: core.$constructor<ZodTuple>;
476
- export declare function tuple<T extends readonly [core.$ZodType, ...core.$ZodType[]]>(items: T, params?: string | core.$ZodTupleParams): ZodTuple<T, null>;
477
- export declare function tuple<T extends readonly [core.$ZodType, ...core.$ZodType[]], Rest extends core.$ZodType>(items: T, rest: Rest, params?: string | core.$ZodTupleParams): ZodTuple<T, Rest>;
469
+ export declare function tuple<T extends readonly [core.SomeType, ...core.SomeType[]]>(items: T, params?: string | core.$ZodTupleParams): ZodTuple<T, null>;
470
+ export declare function tuple<T extends readonly [core.SomeType, ...core.SomeType[]], Rest extends core.SomeType>(items: T, rest: Rest, params?: string | core.$ZodTupleParams): ZodTuple<T, Rest>;
478
471
  export declare function tuple(items: [], params?: string | core.$ZodTupleParams): ZodTuple<[], null>;
479
- export interface ZodRecord<Key extends core.$ZodRecordKey = core.$ZodRecordKey, Value extends core.$ZodType = core.$ZodType> extends ZodType {
480
- _zod: core.$ZodRecordInternals<Key, Value>;
472
+ export interface ZodRecord<Key extends core.$ZodRecordKey = core.$ZodRecordKey, Value extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodRecordInternals<Key, Value>>, core.$ZodRecord<Key, Value> {
481
473
  keyType: Key;
482
474
  valueType: Value;
483
475
  }
484
476
  export declare const ZodRecord: core.$constructor<ZodRecord>;
485
- export declare function record<Key extends core.$ZodRecordKey, Value extends core.$ZodType>(keyType: Key, valueType: Value, params?: string | core.$ZodRecordParams): ZodRecord<Key, Value>;
486
- export declare function partialRecord<Key extends core.$ZodRecordKey, Value extends core.$ZodType>(keyType: Key, valueType: Value, params?: string | core.$ZodRecordParams): ZodRecord<ZodUnion<[Key, ZodNever]>, Value>;
487
- export interface ZodMap<Key extends core.$ZodType = core.$ZodType, Value extends core.$ZodType = core.$ZodType> extends ZodType {
488
- _zod: core.$ZodMapInternals<Key, Value>;
477
+ export declare function record<Key extends core.$ZodRecordKey, Value extends core.SomeType>(keyType: Key, valueType: Value, params?: string | core.$ZodRecordParams): ZodRecord<Key, Value>;
478
+ export declare function partialRecord<Key extends core.$ZodRecordKey, Value extends core.SomeType>(keyType: Key, valueType: Value, params?: string | core.$ZodRecordParams): ZodRecord<Key & core.$partial, Value>;
479
+ export interface ZodMap<Key extends core.SomeType = core.$ZodType, Value extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodMapInternals<Key, Value>>, core.$ZodMap<Key, Value> {
489
480
  keyType: Key;
490
481
  valueType: Value;
491
482
  }
492
483
  export declare const ZodMap: core.$constructor<ZodMap>;
493
- export declare function map<Key extends core.$ZodType, Value extends core.$ZodType>(keyType: Key, valueType: Value, params?: string | core.$ZodMapParams): ZodMap<Key, Value>;
494
- export interface ZodSet<T extends core.$ZodType = core.$ZodType> extends ZodType {
495
- _zod: core.$ZodSetInternals<T>;
484
+ export declare function map<Key extends core.SomeType, Value extends core.SomeType>(keyType: Key, valueType: Value, params?: string | core.$ZodMapParams): ZodMap<Key, Value>;
485
+ export interface ZodSet<T extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodSetInternals<T>>, core.$ZodSet<T> {
496
486
  min(minSize: number, params?: string | core.$ZodCheckMinSizeParams): this;
497
487
  /** */
498
488
  nonempty(params?: string | core.$ZodCheckMinSizeParams): this;
@@ -500,9 +490,10 @@ export interface ZodSet<T extends core.$ZodType = core.$ZodType> extends ZodType
500
490
  size(size: number, params?: string | core.$ZodCheckSizeEqualsParams): this;
501
491
  }
502
492
  export declare const ZodSet: core.$constructor<ZodSet>;
503
- export declare function set<Value extends core.$ZodType>(valueType: Value, params?: string | core.$ZodSetParams): ZodSet<Value>;
504
- export interface ZodEnum<T extends util.EnumLike = util.EnumLike> extends ZodType {
505
- _zod: core.$ZodEnumInternals<T>;
493
+ export declare function set<Value extends core.SomeType>(valueType: Value, params?: string | core.$ZodSetParams): ZodSet<Value>;
494
+ export interface ZodEnum<
495
+ /** @ts-ignore Cast variance */
496
+ out T extends util.EnumLike = util.EnumLike> extends _ZodType<core.$ZodEnumInternals<T>>, core.$ZodEnum<T> {
506
497
  enum: T;
507
498
  options: Array<T[keyof T]>;
508
499
  extract<const U extends readonly (keyof T)[]>(values: U, params?: string | core.$ZodEnumParams): ZodEnum<util.Flatten<Pick<T, U[number]>>>;
@@ -520,131 +511,120 @@ export { _enum as enum };
520
511
  * ```
521
512
  */
522
513
  export declare function nativeEnum<T extends util.EnumLike>(entries: T, params?: string | core.$ZodEnumParams): ZodEnum<T>;
523
- export interface ZodLiteral<T extends util.Primitive = util.Primitive> extends ZodType {
524
- _zod: core.$ZodLiteralInternals<T>;
514
+ export interface ZodLiteral<T extends util.Literal = util.Literal> extends _ZodType<core.$ZodLiteralInternals<T>>, core.$ZodLiteral<T> {
525
515
  values: Set<T>;
516
+ /** @legacy Use `.values` instead. Accessing this property will throw an error if the literal accepts multiple values. */
517
+ value: T;
526
518
  }
527
519
  export declare const ZodLiteral: core.$constructor<ZodLiteral>;
528
- export declare function literal<const T extends Array<util.Literal>>(value: T, params?: string | core.$ZodLiteralParams): ZodLiteral<T[number]>;
520
+ export declare function literal<const T extends ReadonlyArray<util.Literal>>(value: T, params?: string | core.$ZodLiteralParams): ZodLiteral<T[number]>;
529
521
  export declare function literal<const T extends util.Literal>(value: T, params?: string | core.$ZodLiteralParams): ZodLiteral<T>;
530
- export interface ZodFile extends ZodType {
531
- _zod: core.$ZodFileInternals;
522
+ export interface ZodFile extends _ZodType<core.$ZodFileInternals>, core.$ZodFile {
532
523
  min(size: number, params?: string | core.$ZodCheckMinSizeParams): this;
533
524
  max(size: number, params?: string | core.$ZodCheckMaxSizeParams): this;
534
- mime(types: Array<util.MimeTypes>, params?: string | core.$ZodCheckMimeTypeParams): this;
525
+ mime(types: util.MimeTypes | Array<util.MimeTypes>, params?: string | core.$ZodCheckMimeTypeParams): this;
535
526
  }
536
527
  export declare const ZodFile: core.$constructor<ZodFile>;
537
528
  export declare function file(params?: string | core.$ZodFileParams): ZodFile;
538
- export interface ZodTransform<O = unknown, I = unknown> extends ZodType {
539
- _zod: core.$ZodTransformInternals<O, I>;
529
+ export interface ZodTransform<O = unknown, I = unknown> extends _ZodType<core.$ZodTransformInternals<O, I>>, core.$ZodTransform<O, I> {
540
530
  }
541
531
  export declare const ZodTransform: core.$constructor<ZodTransform>;
542
- export declare function transform<I = unknown, O = I>(fn: (input: I, ctx: core.ParsePayload) => O, params?: string | core.$ZodTransformParams): ZodTransform<Awaited<O>, I>;
543
- export interface ZodOptional<T extends core.$ZodType = core.$ZodType> extends ZodType {
544
- _zod: core.$ZodOptionalInternals<T>;
532
+ export declare function transform<I = unknown, O = I>(fn: (input: I, ctx: core.ParsePayload) => O): ZodTransform<Awaited<O>, I>;
533
+ export interface ZodOptional<T extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodOptionalInternals<T>>, core.$ZodOptional<T> {
545
534
  unwrap(): T;
546
535
  }
547
536
  export declare const ZodOptional: core.$constructor<ZodOptional>;
548
- export declare function optional<T extends core.$ZodType>(innerType: T, params?: string | core.$ZodOptionalParams): ZodOptional<T>;
549
- export interface ZodNullable<T extends core.$ZodType = core.$ZodType> extends ZodType {
550
- _zod: core.$ZodNullableInternals<T>;
537
+ export declare function optional<T extends core.SomeType>(innerType: T): ZodOptional<T>;
538
+ export interface ZodNullable<T extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodNullableInternals<T>>, core.$ZodNullable<T> {
551
539
  unwrap(): T;
552
540
  }
553
541
  export declare const ZodNullable: core.$constructor<ZodNullable>;
554
- export declare function nullable<T extends core.$ZodType>(innerType: T, params?: string | core.$ZodNullableParams): ZodNullable<T>;
555
- export declare function nullish<T extends core.$ZodType>(innerType: T): ZodOptional<ZodNullable<T>>;
556
- export interface ZodDefault<T extends core.$ZodType = core.$ZodType> extends ZodType {
557
- _zod: core.$ZodDefaultInternals<T>;
542
+ export declare function nullable<T extends core.SomeType>(innerType: T): ZodNullable<T>;
543
+ export declare function nullish<T extends core.SomeType>(innerType: T): ZodOptional<ZodNullable<T>>;
544
+ export interface ZodDefault<T extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodDefaultInternals<T>>, core.$ZodDefault<T> {
558
545
  unwrap(): T;
559
546
  /** @deprecated Use `.unwrap()` instead. */
560
547
  removeDefault(): T;
561
548
  }
562
549
  export declare const ZodDefault: core.$constructor<ZodDefault>;
563
- export declare function _default<T extends core.$ZodType>(innerType: T, defaultValue: util.NoUndefined<core.output<T>> | (() => util.NoUndefined<core.output<T>>), params?: string | core.$ZodDefaultParams): ZodDefault<T>;
564
- export interface ZodNonOptional<T extends core.$ZodType = core.$ZodType> extends ZodType {
565
- _zod: core.$ZodNonOptionalInternals<T>;
550
+ export declare function _default<T extends core.SomeType>(innerType: T, defaultValue: util.NoUndefined<core.output<T>> | (() => util.NoUndefined<core.output<T>>)): ZodDefault<T>;
551
+ export interface ZodPrefault<T extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodPrefaultInternals<T>>, core.$ZodPrefault<T> {
552
+ unwrap(): T;
553
+ }
554
+ export declare const ZodPrefault: core.$constructor<ZodPrefault>;
555
+ export declare function prefault<T extends core.SomeType>(innerType: T, defaultValue: core.input<T> | (() => core.input<T>)): ZodPrefault<T>;
556
+ export interface ZodNonOptional<T extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodNonOptionalInternals<T>>, core.$ZodNonOptional<T> {
566
557
  unwrap(): T;
567
558
  }
568
559
  export declare const ZodNonOptional: core.$constructor<ZodNonOptional>;
569
- export declare function nonoptional<T extends core.$ZodType>(innerType: T, params?: string | core.$ZodNonOptionalParams): ZodNonOptional<T>;
570
- export interface ZodSuccess<T extends core.$ZodType = core.$ZodType> extends ZodType {
571
- _zod: core.$ZodSuccessInternals<T>;
560
+ export declare function nonoptional<T extends core.SomeType>(innerType: T, params?: string | core.$ZodNonOptionalParams): ZodNonOptional<T>;
561
+ export interface ZodSuccess<T extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodSuccessInternals<T>>, core.$ZodSuccess<T> {
572
562
  unwrap(): T;
573
563
  }
574
564
  export declare const ZodSuccess: core.$constructor<ZodSuccess>;
575
- export declare function success<T extends core.$ZodType>(innerType: T, params?: string | core.$ZodSuccessParams): ZodSuccess<T>;
576
- export interface ZodCatch<T extends core.$ZodType = core.$ZodType> extends ZodType {
577
- _zod: core.$ZodCatchInternals<T>;
565
+ export declare function success<T extends core.SomeType>(innerType: T): ZodSuccess<T>;
566
+ export interface ZodCatch<T extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodCatchInternals<T>>, core.$ZodCatch<T> {
578
567
  unwrap(): T;
579
568
  /** @deprecated Use `.unwrap()` instead. */
580
569
  removeCatch(): T;
581
570
  }
582
571
  export declare const ZodCatch: core.$constructor<ZodCatch>;
583
- declare function _catch<T extends core.$ZodType>(innerType: T, catchValue: core.output<T> | ((ctx: core.$ZodCatchCtx) => core.output<T>), params?: string | core.$ZodCatchParams): ZodCatch<T>;
572
+ declare function _catch<T extends core.SomeType>(innerType: T, catchValue: core.output<T> | ((ctx: core.$ZodCatchCtx) => core.output<T>)): ZodCatch<T>;
584
573
  export { _catch as catch };
585
- export interface ZodNaN extends ZodType {
586
- _zod: core.$ZodNaNInternals;
574
+ export interface ZodNaN extends _ZodType<core.$ZodNaNInternals>, core.$ZodNaN {
587
575
  }
588
576
  export declare const ZodNaN: core.$constructor<ZodNaN>;
589
577
  export declare function nan(params?: string | core.$ZodNaNParams): ZodNaN;
590
- export interface ZodPipe<A extends core.$ZodType = core.$ZodType, B extends core.$ZodType = core.$ZodType> extends ZodType {
591
- _zod: core.$ZodPipeInternals<A, B>;
578
+ export interface ZodPipe<A extends core.SomeType = core.$ZodType, B extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodPipeInternals<A, B>>, core.$ZodPipe<A, B> {
592
579
  in: A;
593
580
  out: B;
594
581
  }
595
582
  export declare const ZodPipe: core.$constructor<ZodPipe>;
596
- export declare function pipe<const A extends core.$ZodType, B extends core.$ZodType<unknown, core.output<A>> = core.$ZodType<unknown, core.output<A>>>(in_: A, out: B | core.$ZodType<unknown, core.output<A>>, params?: string | core.$ZodPipeParams): ZodPipe<A, B>;
597
- export interface ZodReadonly<T extends core.$ZodType = core.$ZodType> extends ZodType {
598
- _zod: core.$ZodReadonlyInternals<T>;
583
+ export declare function pipe<const A extends core.SomeType, B extends core.$ZodType<unknown, core.output<A>> = core.$ZodType<unknown, core.output<A>>>(in_: A, out: B | core.$ZodType<unknown, core.output<A>>): ZodPipe<A, B>;
584
+ export interface ZodReadonly<T extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodReadonlyInternals<T>>, core.$ZodReadonly<T> {
599
585
  }
600
586
  export declare const ZodReadonly: core.$constructor<ZodReadonly>;
601
- export declare function readonly<T extends core.$ZodType>(innerType: T, params?: string | core.$ZodReadonlyParams): ZodReadonly<T>;
602
- export interface ZodTemplateLiteral<Template extends string = string> extends ZodType {
603
- _zod: core.$ZodTemplateLiteralInternals<Template>;
587
+ export declare function readonly<T extends core.SomeType>(innerType: T): ZodReadonly<T>;
588
+ export interface ZodTemplateLiteral<Template extends string = string> extends _ZodType<core.$ZodTemplateLiteralInternals<Template>>, core.$ZodTemplateLiteral<Template> {
604
589
  }
605
590
  export declare const ZodTemplateLiteral: core.$constructor<ZodTemplateLiteral>;
606
- export declare function templateLiteral<const Parts extends core.$TemplateLiteralPart[]>(parts: Parts, params?: string | core.$ZodTemplateLiteralParams): ZodTemplateLiteral<core.$PartsToTemplateLiteral<Parts>>;
607
- export interface ZodLazy<T extends core.$ZodType = core.$ZodType> extends ZodType {
608
- _zod: core.$ZodLazyInternals<T>;
591
+ export declare function templateLiteral<const Parts extends core.$ZodTemplateLiteralPart[]>(parts: Parts, params?: string | core.$ZodTemplateLiteralParams): ZodTemplateLiteral<core.$PartsToTemplateLiteral<Parts>>;
592
+ export interface ZodLazy<T extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodLazyInternals<T>>, core.$ZodLazy<T> {
609
593
  unwrap(): T;
610
594
  }
611
595
  export declare const ZodLazy: core.$constructor<ZodLazy>;
612
- export declare function lazy<T extends core.$ZodType>(getter: () => T): ZodLazy<T>;
613
- export interface ZodPromise<T extends core.$ZodType = core.$ZodType> extends ZodType {
614
- _zod: core.$ZodPromiseInternals<T>;
596
+ export declare function lazy<T extends core.SomeType>(getter: () => T): ZodLazy<T>;
597
+ export interface ZodPromise<T extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodPromiseInternals<T>>, core.$ZodPromise<T> {
615
598
  unwrap(): T;
616
599
  }
617
600
  export declare const ZodPromise: core.$constructor<ZodPromise>;
618
- export declare function promise<T extends core.$ZodType>(innerType: T, params?: string | core.$ZodPromiseParams): ZodPromise<T>;
619
- export interface ZodCustom<O = unknown, I = unknown> extends ZodType {
620
- _zod: core.$ZodCustomInternals<O, I>;
601
+ export declare function promise<T extends core.SomeType>(innerType: T): ZodPromise<T>;
602
+ export interface ZodCustom<O = unknown, I = unknown> extends _ZodType<core.$ZodCustomInternals<O, I>>, core.$ZodCustom<O, I> {
621
603
  }
622
604
  export declare const ZodCustom: core.$constructor<ZodCustom>;
623
- export declare function check<O = unknown>(fn: core.CheckFn<O>, params?: string | core.$ZodCustomParams): core.$ZodCheck<O>;
624
- export declare function custom<O = unknown, I = O>(fn?: (data: O) => unknown, _params?: string | core.$ZodCustomParams | undefined): ZodCustom<O, I>;
605
+ export declare function check<O = unknown>(fn: core.CheckFn<O>): core.$ZodCheck<O>;
606
+ export declare function custom<O>(fn?: (data: unknown) => unknown, _params?: string | core.$ZodCustomParams | undefined): ZodCustom<O, O>;
625
607
  export declare function refine<T>(fn: (arg: NoInfer<T>) => util.MaybeAsync<unknown>, _params?: string | core.$ZodCustomParams): core.$ZodCheck<T>;
626
- export declare function superRefine<T>(fn: (arg: T, payload: RefinementCtx<T>) => void | Promise<void>, params?: string | core.$ZodCustomParams): core.$ZodCheck<T>;
627
- declare abstract class Class {
628
- constructor(..._args: any[]);
629
- }
630
- type ZodInstanceOfParams = util.Params<ZodCustom, core.$ZodIssueCustom, "type" | "check" | "checks" | "fn" | "abort" | "error" | "params" | "path">;
631
- declare function _instanceof<T extends typeof Class>(cls: T, params?: ZodInstanceOfParams): ZodCustom<InstanceType<T>>;
608
+ export declare function superRefine<T>(fn: (arg: T, payload: RefinementCtx<T>) => void | Promise<void>): core.$ZodCheck<T>;
609
+ type ZodInstanceOfParams = core.Params<ZodCustom, core.$ZodIssueCustom, "type" | "check" | "checks" | "fn" | "abort" | "error" | "params" | "path">;
610
+ declare function _instanceof<T extends typeof util.Class>(cls: T, params?: ZodInstanceOfParams): ZodCustom<InstanceType<T>, InstanceType<T>>;
632
611
  export { _instanceof as instanceof };
633
- export declare const stringbool: (_params?: string | core.$ZodStringBoolParams) => ZodPipe<ZodUnknown, ZodBoolean>;
634
- export type ZodJSONSchema = ZodUnion<[
612
+ export declare const stringbool: (_params?: string | core.$ZodStringBoolParams) => ZodPipe<ZodPipe<ZodString, ZodTransform<boolean, string>>, ZodBoolean>;
613
+ type _ZodJSONSchema = ZodUnion<[
635
614
  ZodString,
636
615
  ZodNumber,
637
616
  ZodBoolean,
638
617
  ZodNull,
639
618
  ZodArray<ZodJSONSchema>,
640
619
  ZodRecord<ZodString, ZodJSONSchema>
641
- ]> & {
642
- _zod: {
643
- input: util.JSONType;
644
- output: util.JSONType;
645
- };
646
- };
647
- export declare function json(params?: string | core.$ZodCustomParams): ZodJSONSchema;
648
- export interface ZodPreprocessParams extends core.$ZodTransformParams, core.$ZodPipeParams {
620
+ ]>;
621
+ type _ZodJSONSchemaInternals = _ZodJSONSchema["_zod"];
622
+ export interface ZodJSONSchemaInternals extends _ZodJSONSchemaInternals {
623
+ output: util.JSONType;
624
+ input: util.JSONType;
625
+ }
626
+ export interface ZodJSONSchema extends _ZodJSONSchema {
627
+ _zod: ZodJSONSchemaInternals;
649
628
  }
650
- export declare function preprocess<A, U extends core.$ZodType>(fn: (arg: unknown, ctx: RefinementCtx) => A, schema: U, params?: ZodPreprocessParams): ZodPipe<ZodTransform<A, unknown>, U>;
629
+ export declare function json(params?: string | core.$ZodCustomParams): ZodJSONSchema;
630
+ export declare function preprocess<A, U extends core.SomeType, B = unknown>(fn: (arg: B, ctx: RefinementCtx) => A, schema: U): ZodPipe<ZodTransform<A, B>, U>;