zod 3.25.0 → 3.25.3

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