zod 3.25.21 → 3.25.22

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 (506) hide show
  1. package/package.json +2 -2
  2. package/dist/cjs/v3/tests/all-errors.test.js +0 -147
  3. package/dist/cjs/v3/tests/anyunknown.test.js +0 -47
  4. package/dist/cjs/v3/tests/array.test.js +0 -80
  5. package/dist/cjs/v3/tests/async-parsing.test.js +0 -381
  6. package/dist/cjs/v3/tests/async-refinements.test.js +0 -60
  7. package/dist/cjs/v3/tests/base.test.js +0 -47
  8. package/dist/cjs/v3/tests/bigint.test.js +0 -74
  9. package/dist/cjs/v3/tests/branded.test.js +0 -58
  10. package/dist/cjs/v3/tests/catch.test.js +0 -181
  11. package/dist/cjs/v3/tests/coerce.test.js +0 -152
  12. package/dist/cjs/v3/tests/complex.test.js +0 -78
  13. package/dist/cjs/v3/tests/custom.test.js +0 -51
  14. package/dist/cjs/v3/tests/date.test.js +0 -49
  15. package/dist/cjs/v3/tests/deepmasking.test.js +0 -187
  16. package/dist/cjs/v3/tests/default.test.js +0 -86
  17. package/dist/cjs/v3/tests/description.test.js +0 -51
  18. package/dist/cjs/v3/tests/discriminated-unions.test.js +0 -321
  19. package/dist/cjs/v3/tests/enum.test.js +0 -91
  20. package/dist/cjs/v3/tests/error.test.js +0 -526
  21. package/dist/cjs/v3/tests/firstparty.test.js +0 -109
  22. package/dist/cjs/v3/tests/firstpartyschematypes.test.js +0 -8
  23. package/dist/cjs/v3/tests/function.test.js +0 -236
  24. package/dist/cjs/v3/tests/generics.test.js +0 -67
  25. package/dist/cjs/v3/tests/instanceof.test.js +0 -60
  26. package/dist/cjs/v3/tests/intersection.test.js +0 -111
  27. package/dist/cjs/v3/tests/language-server.source.js +0 -71
  28. package/dist/cjs/v3/tests/language-server.test.js +0 -177
  29. package/dist/cjs/v3/tests/literal.test.js +0 -55
  30. package/dist/cjs/v3/tests/map.test.js +0 -112
  31. package/dist/cjs/v3/tests/masking.test.js +0 -5
  32. package/dist/cjs/v3/tests/mocker.test.js +0 -19
  33. package/dist/cjs/v3/tests/nan.test.js +0 -42
  34. package/dist/cjs/v3/tests/nativeEnum.test.js +0 -100
  35. package/dist/cjs/v3/tests/nullable.test.js +0 -65
  36. package/dist/cjs/v3/tests/number.test.js +0 -189
  37. package/dist/cjs/v3/tests/object-augmentation.test.js +0 -50
  38. package/dist/cjs/v3/tests/object-in-es5-env.test.js +0 -49
  39. package/dist/cjs/v3/tests/object.test.js +0 -352
  40. package/dist/cjs/v3/tests/optional.test.js +0 -65
  41. package/dist/cjs/v3/tests/parseUtil.test.js +0 -20
  42. package/dist/cjs/v3/tests/parser.test.js +0 -55
  43. package/dist/cjs/v3/tests/partials.test.js +0 -201
  44. package/dist/cjs/v3/tests/pickomit.test.js +0 -113
  45. package/dist/cjs/v3/tests/pipeline.test.js +0 -50
  46. package/dist/cjs/v3/tests/preprocess.test.js +0 -181
  47. package/dist/cjs/v3/tests/primitive.test.js +0 -385
  48. package/dist/cjs/v3/tests/promise.test.js +0 -98
  49. package/dist/cjs/v3/tests/readonly.test.js +0 -190
  50. package/dist/cjs/v3/tests/record.test.js +0 -153
  51. package/dist/cjs/v3/tests/recursive.test.js +0 -161
  52. package/dist/cjs/v3/tests/refine.test.js +0 -279
  53. package/dist/cjs/v3/tests/safeparse.test.js +0 -46
  54. package/dist/cjs/v3/tests/set.test.js +0 -144
  55. package/dist/cjs/v3/tests/standard-schema.test.js +0 -102
  56. package/dist/cjs/v3/tests/string.test.js +0 -842
  57. package/dist/cjs/v3/tests/transformer.test.js +0 -218
  58. package/dist/cjs/v3/tests/tuple.test.js +0 -97
  59. package/dist/cjs/v3/tests/unions.test.js +0 -75
  60. package/dist/cjs/v3/tests/validations.test.js +0 -155
  61. package/dist/cjs/v3/tests/void.test.js +0 -36
  62. package/dist/cjs/v4/classic/tests/anyunknown.test.js +0 -45
  63. package/dist/cjs/v4/classic/tests/array.test.js +0 -249
  64. package/dist/cjs/v4/classic/tests/assignability.test.js +0 -110
  65. package/dist/cjs/v4/classic/tests/async-parsing.test.js +0 -364
  66. package/dist/cjs/v4/classic/tests/async-refinements.test.js +0 -82
  67. package/dist/cjs/v4/classic/tests/base.test.js +0 -31
  68. package/dist/cjs/v4/classic/tests/bigint.test.js +0 -73
  69. package/dist/cjs/v4/classic/tests/brand.test.js +0 -60
  70. package/dist/cjs/v4/classic/tests/catch.test.js +0 -214
  71. package/dist/cjs/v4/classic/tests/coalesce.test.js +0 -18
  72. package/dist/cjs/v4/classic/tests/coerce.test.js +0 -175
  73. package/dist/cjs/v4/classic/tests/custom.test.js +0 -38
  74. package/dist/cjs/v4/classic/tests/date.test.js +0 -48
  75. package/dist/cjs/v4/classic/tests/default.test.js +0 -88
  76. package/dist/cjs/v4/classic/tests/description.test.js +0 -51
  77. package/dist/cjs/v4/classic/tests/discriminated-unions.test.js +0 -540
  78. package/dist/cjs/v4/classic/tests/enum.test.js +0 -260
  79. package/dist/cjs/v4/classic/tests/error-utils.test.js +0 -411
  80. package/dist/cjs/v4/classic/tests/error.test.js +0 -651
  81. package/dist/cjs/v4/classic/tests/file.test.js +0 -68
  82. package/dist/cjs/v4/classic/tests/firstparty.test.js +0 -198
  83. package/dist/cjs/v4/classic/tests/function.test.js +0 -219
  84. package/dist/cjs/v4/classic/tests/generics.test.js +0 -72
  85. package/dist/cjs/v4/classic/tests/index.test.js +0 -765
  86. package/dist/cjs/v4/classic/tests/instanceof.test.js +0 -58
  87. package/dist/cjs/v4/classic/tests/intersection.test.js +0 -134
  88. package/dist/cjs/v4/classic/tests/json-schema.test.js +0 -1707
  89. package/dist/cjs/v4/classic/tests/json.test.js +0 -105
  90. package/dist/cjs/v4/classic/tests/lazy.test.js +0 -185
  91. package/dist/cjs/v4/classic/tests/literal.test.js +0 -94
  92. package/dist/cjs/v4/classic/tests/map.test.js +0 -193
  93. package/dist/cjs/v4/classic/tests/nan.test.js +0 -42
  94. package/dist/cjs/v4/classic/tests/nested-refine.test.js +0 -180
  95. package/dist/cjs/v4/classic/tests/nonoptional.test.js +0 -80
  96. package/dist/cjs/v4/classic/tests/nullable.test.js +0 -43
  97. package/dist/cjs/v4/classic/tests/number.test.js +0 -241
  98. package/dist/cjs/v4/classic/tests/object.test.js +0 -405
  99. package/dist/cjs/v4/classic/tests/optional.test.js +0 -98
  100. package/dist/cjs/v4/classic/tests/partial.test.js +0 -137
  101. package/dist/cjs/v4/classic/tests/pickomit.test.js +0 -125
  102. package/dist/cjs/v4/classic/tests/pipe.test.js +0 -92
  103. package/dist/cjs/v4/classic/tests/prefault.test.js +0 -22
  104. package/dist/cjs/v4/classic/tests/preprocess.test.js +0 -273
  105. package/dist/cjs/v4/classic/tests/primitive.test.js +0 -184
  106. package/dist/cjs/v4/classic/tests/promise.test.js +0 -91
  107. package/dist/cjs/v4/classic/tests/readonly.test.js +0 -241
  108. package/dist/cjs/v4/classic/tests/record.test.js +0 -307
  109. package/dist/cjs/v4/classic/tests/recursive-types.test.js +0 -108
  110. package/dist/cjs/v4/classic/tests/refine.test.js +0 -402
  111. package/dist/cjs/v4/classic/tests/registries.test.js +0 -155
  112. package/dist/cjs/v4/classic/tests/set.test.js +0 -182
  113. package/dist/cjs/v4/classic/tests/standard-schema.test.js +0 -77
  114. package/dist/cjs/v4/classic/tests/string-formats.test.js +0 -49
  115. package/dist/cjs/v4/classic/tests/string.test.js +0 -980
  116. package/dist/cjs/v4/classic/tests/template-literal.test.js +0 -705
  117. package/dist/cjs/v4/classic/tests/transform.test.js +0 -239
  118. package/dist/cjs/v4/classic/tests/tuple.test.js +0 -166
  119. package/dist/cjs/v4/classic/tests/union.test.js +0 -107
  120. package/dist/cjs/v4/classic/tests/validations.test.js +0 -301
  121. package/dist/cjs/v4/classic/tests/void.test.js +0 -34
  122. package/dist/cjs/v4/core/tests/index.test.js +0 -66
  123. package/dist/cjs/v4/core/tests/locales/be.test.js +0 -123
  124. package/dist/cjs/v4/core/tests/locales/en.test.js +0 -21
  125. package/dist/cjs/v4/core/tests/locales/ru.test.js +0 -123
  126. package/dist/cjs/v4/core/tests/locales/tr.test.js +0 -79
  127. package/dist/cjs/v4/mini/tests/assignability.test.js +0 -104
  128. package/dist/cjs/v4/mini/tests/brand.test.js +0 -58
  129. package/dist/cjs/v4/mini/tests/checks.test.js +0 -147
  130. package/dist/cjs/v4/mini/tests/computed.test.js +0 -55
  131. package/dist/cjs/v4/mini/tests/error.test.js +0 -45
  132. package/dist/cjs/v4/mini/tests/functions.test.js +0 -37
  133. package/dist/cjs/v4/mini/tests/index.test.js +0 -763
  134. package/dist/cjs/v4/mini/tests/number.test.js +0 -109
  135. package/dist/cjs/v4/mini/tests/object.test.js +0 -122
  136. package/dist/cjs/v4/mini/tests/prototypes.test.js +0 -44
  137. package/dist/cjs/v4/mini/tests/recursive-types.test.js +0 -106
  138. package/dist/cjs/v4/mini/tests/string.test.js +0 -265
  139. package/dist/types/v3/tests/all-errors.test.d.ts +0 -1
  140. package/dist/types/v3/tests/anyunknown.test.d.ts +0 -1
  141. package/dist/types/v3/tests/array.test.d.ts +0 -1
  142. package/dist/types/v3/tests/async-parsing.test.d.ts +0 -1
  143. package/dist/types/v3/tests/async-refinements.test.d.ts +0 -1
  144. package/dist/types/v3/tests/base.test.d.ts +0 -1
  145. package/dist/types/v3/tests/bigint.test.d.ts +0 -1
  146. package/dist/types/v3/tests/branded.test.d.ts +0 -1
  147. package/dist/types/v3/tests/catch.test.d.ts +0 -1
  148. package/dist/types/v3/tests/coerce.test.d.ts +0 -1
  149. package/dist/types/v3/tests/complex.test.d.ts +0 -1
  150. package/dist/types/v3/tests/custom.test.d.ts +0 -1
  151. package/dist/types/v3/tests/date.test.d.ts +0 -1
  152. package/dist/types/v3/tests/deepmasking.test.d.ts +0 -1
  153. package/dist/types/v3/tests/default.test.d.ts +0 -1
  154. package/dist/types/v3/tests/description.test.d.ts +0 -1
  155. package/dist/types/v3/tests/discriminated-unions.test.d.ts +0 -1
  156. package/dist/types/v3/tests/enum.test.d.ts +0 -1
  157. package/dist/types/v3/tests/error.test.d.ts +0 -1
  158. package/dist/types/v3/tests/firstparty.test.d.ts +0 -1
  159. package/dist/types/v3/tests/firstpartyschematypes.test.d.ts +0 -1
  160. package/dist/types/v3/tests/function.test.d.ts +0 -1
  161. package/dist/types/v3/tests/generics.test.d.ts +0 -1
  162. package/dist/types/v3/tests/instanceof.test.d.ts +0 -1
  163. package/dist/types/v3/tests/intersection.test.d.ts +0 -1
  164. package/dist/types/v3/tests/language-server.source.d.ts +0 -70
  165. package/dist/types/v3/tests/language-server.test.d.ts +0 -1
  166. package/dist/types/v3/tests/literal.test.d.ts +0 -1
  167. package/dist/types/v3/tests/map.test.d.ts +0 -1
  168. package/dist/types/v3/tests/masking.test.d.ts +0 -1
  169. package/dist/types/v3/tests/mocker.test.d.ts +0 -1
  170. package/dist/types/v3/tests/nan.test.d.ts +0 -1
  171. package/dist/types/v3/tests/nativeEnum.test.d.ts +0 -1
  172. package/dist/types/v3/tests/nullable.test.d.ts +0 -1
  173. package/dist/types/v3/tests/number.test.d.ts +0 -1
  174. package/dist/types/v3/tests/object-augmentation.test.d.ts +0 -1
  175. package/dist/types/v3/tests/object-in-es5-env.test.d.ts +0 -1
  176. package/dist/types/v3/tests/object.test.d.ts +0 -1
  177. package/dist/types/v3/tests/optional.test.d.ts +0 -1
  178. package/dist/types/v3/tests/parseUtil.test.d.ts +0 -1
  179. package/dist/types/v3/tests/parser.test.d.ts +0 -1
  180. package/dist/types/v3/tests/partials.test.d.ts +0 -1
  181. package/dist/types/v3/tests/pickomit.test.d.ts +0 -1
  182. package/dist/types/v3/tests/pipeline.test.d.ts +0 -1
  183. package/dist/types/v3/tests/preprocess.test.d.ts +0 -1
  184. package/dist/types/v3/tests/primitive.test.d.ts +0 -1
  185. package/dist/types/v3/tests/promise.test.d.ts +0 -1
  186. package/dist/types/v3/tests/readonly.test.d.ts +0 -1
  187. package/dist/types/v3/tests/record.test.d.ts +0 -1
  188. package/dist/types/v3/tests/recursive.test.d.ts +0 -1
  189. package/dist/types/v3/tests/refine.test.d.ts +0 -1
  190. package/dist/types/v3/tests/safeparse.test.d.ts +0 -1
  191. package/dist/types/v3/tests/set.test.d.ts +0 -1
  192. package/dist/types/v3/tests/standard-schema.test.d.ts +0 -1
  193. package/dist/types/v3/tests/string.test.d.ts +0 -1
  194. package/dist/types/v3/tests/transformer.test.d.ts +0 -1
  195. package/dist/types/v3/tests/tuple.test.d.ts +0 -1
  196. package/dist/types/v3/tests/unions.test.d.ts +0 -1
  197. package/dist/types/v3/tests/validations.test.d.ts +0 -1
  198. package/dist/types/v3/tests/void.test.d.ts +0 -1
  199. package/dist/types/v4/classic/tests/anyunknown.test.d.ts +0 -1
  200. package/dist/types/v4/classic/tests/array.test.d.ts +0 -1
  201. package/dist/types/v4/classic/tests/assignability.test.d.ts +0 -1
  202. package/dist/types/v4/classic/tests/async-parsing.test.d.ts +0 -1
  203. package/dist/types/v4/classic/tests/async-refinements.test.d.ts +0 -1
  204. package/dist/types/v4/classic/tests/base.test.d.ts +0 -1
  205. package/dist/types/v4/classic/tests/bigint.test.d.ts +0 -1
  206. package/dist/types/v4/classic/tests/brand.test.d.ts +0 -1
  207. package/dist/types/v4/classic/tests/catch.test.d.ts +0 -1
  208. package/dist/types/v4/classic/tests/coalesce.test.d.ts +0 -1
  209. package/dist/types/v4/classic/tests/coerce.test.d.ts +0 -1
  210. package/dist/types/v4/classic/tests/custom.test.d.ts +0 -1
  211. package/dist/types/v4/classic/tests/date.test.d.ts +0 -1
  212. package/dist/types/v4/classic/tests/default.test.d.ts +0 -1
  213. package/dist/types/v4/classic/tests/description.test.d.ts +0 -1
  214. package/dist/types/v4/classic/tests/discriminated-unions.test.d.ts +0 -1
  215. package/dist/types/v4/classic/tests/enum.test.d.ts +0 -1
  216. package/dist/types/v4/classic/tests/error-utils.test.d.ts +0 -1
  217. package/dist/types/v4/classic/tests/error.test.d.ts +0 -1
  218. package/dist/types/v4/classic/tests/file.test.d.ts +0 -1
  219. package/dist/types/v4/classic/tests/firstparty.test.d.ts +0 -1
  220. package/dist/types/v4/classic/tests/function.test.d.ts +0 -1
  221. package/dist/types/v4/classic/tests/generics.test.d.ts +0 -1
  222. package/dist/types/v4/classic/tests/index.test.d.ts +0 -1
  223. package/dist/types/v4/classic/tests/instanceof.test.d.ts +0 -1
  224. package/dist/types/v4/classic/tests/intersection.test.d.ts +0 -1
  225. package/dist/types/v4/classic/tests/json-schema.test.d.ts +0 -1
  226. package/dist/types/v4/classic/tests/json.test.d.ts +0 -1
  227. package/dist/types/v4/classic/tests/lazy.test.d.ts +0 -1
  228. package/dist/types/v4/classic/tests/literal.test.d.ts +0 -1
  229. package/dist/types/v4/classic/tests/map.test.d.ts +0 -1
  230. package/dist/types/v4/classic/tests/nan.test.d.ts +0 -1
  231. package/dist/types/v4/classic/tests/nested-refine.test.d.ts +0 -1
  232. package/dist/types/v4/classic/tests/nonoptional.test.d.ts +0 -1
  233. package/dist/types/v4/classic/tests/nullable.test.d.ts +0 -1
  234. package/dist/types/v4/classic/tests/number.test.d.ts +0 -1
  235. package/dist/types/v4/classic/tests/object.test.d.ts +0 -1
  236. package/dist/types/v4/classic/tests/optional.test.d.ts +0 -1
  237. package/dist/types/v4/classic/tests/partial.test.d.ts +0 -1
  238. package/dist/types/v4/classic/tests/pickomit.test.d.ts +0 -1
  239. package/dist/types/v4/classic/tests/pipe.test.d.ts +0 -1
  240. package/dist/types/v4/classic/tests/prefault.test.d.ts +0 -1
  241. package/dist/types/v4/classic/tests/preprocess.test.d.ts +0 -1
  242. package/dist/types/v4/classic/tests/primitive.test.d.ts +0 -1
  243. package/dist/types/v4/classic/tests/promise.test.d.ts +0 -1
  244. package/dist/types/v4/classic/tests/readonly.test.d.ts +0 -1
  245. package/dist/types/v4/classic/tests/record.test.d.ts +0 -1
  246. package/dist/types/v4/classic/tests/recursive-types.test.d.ts +0 -1
  247. package/dist/types/v4/classic/tests/refine.test.d.ts +0 -1
  248. package/dist/types/v4/classic/tests/registries.test.d.ts +0 -1
  249. package/dist/types/v4/classic/tests/set.test.d.ts +0 -1
  250. package/dist/types/v4/classic/tests/standard-schema.test.d.ts +0 -1
  251. package/dist/types/v4/classic/tests/string-formats.test.d.ts +0 -1
  252. package/dist/types/v4/classic/tests/string.test.d.ts +0 -1
  253. package/dist/types/v4/classic/tests/template-literal.test.d.ts +0 -1
  254. package/dist/types/v4/classic/tests/transform.test.d.ts +0 -1
  255. package/dist/types/v4/classic/tests/tuple.test.d.ts +0 -1
  256. package/dist/types/v4/classic/tests/union.test.d.ts +0 -1
  257. package/dist/types/v4/classic/tests/validations.test.d.ts +0 -1
  258. package/dist/types/v4/classic/tests/void.test.d.ts +0 -1
  259. package/dist/types/v4/core/tests/index.test.d.ts +0 -1
  260. package/dist/types/v4/core/tests/locales/be.test.d.ts +0 -1
  261. package/dist/types/v4/core/tests/locales/en.test.d.ts +0 -1
  262. package/dist/types/v4/core/tests/locales/ru.test.d.ts +0 -1
  263. package/dist/types/v4/core/tests/locales/tr.test.d.ts +0 -1
  264. package/dist/types/v4/mini/tests/assignability.test.d.ts +0 -1
  265. package/dist/types/v4/mini/tests/brand.test.d.ts +0 -1
  266. package/dist/types/v4/mini/tests/checks.test.d.ts +0 -1
  267. package/dist/types/v4/mini/tests/computed.test.d.ts +0 -1
  268. package/dist/types/v4/mini/tests/error.test.d.ts +0 -1
  269. package/dist/types/v4/mini/tests/functions.test.d.ts +0 -1
  270. package/dist/types/v4/mini/tests/index.test.d.ts +0 -1
  271. package/dist/types/v4/mini/tests/number.test.d.ts +0 -1
  272. package/dist/types/v4/mini/tests/object.test.d.ts +0 -1
  273. package/dist/types/v4/mini/tests/prototypes.test.d.ts +0 -1
  274. package/dist/types/v4/mini/tests/recursive-types.test.d.ts +0 -1
  275. package/dist/types/v4/mini/tests/string.test.d.ts +0 -1
  276. package/src/index.ts +0 -4
  277. package/src/v3/ZodError.ts +0 -329
  278. package/src/v3/benchmarks/datetime.ts +0 -58
  279. package/src/v3/benchmarks/discriminatedUnion.ts +0 -80
  280. package/src/v3/benchmarks/index.ts +0 -59
  281. package/src/v3/benchmarks/ipv4.ts +0 -57
  282. package/src/v3/benchmarks/object.ts +0 -69
  283. package/src/v3/benchmarks/primitives.ts +0 -162
  284. package/src/v3/benchmarks/realworld.ts +0 -63
  285. package/src/v3/benchmarks/string.ts +0 -55
  286. package/src/v3/benchmarks/union.ts +0 -80
  287. package/src/v3/errors.ts +0 -13
  288. package/src/v3/external.ts +0 -6
  289. package/src/v3/helpers/enumUtil.ts +0 -17
  290. package/src/v3/helpers/errorUtil.ts +0 -8
  291. package/src/v3/helpers/parseUtil.ts +0 -176
  292. package/src/v3/helpers/partialUtil.ts +0 -34
  293. package/src/v3/helpers/typeAliases.ts +0 -2
  294. package/src/v3/helpers/util.ts +0 -224
  295. package/src/v3/index.ts +0 -4
  296. package/src/v3/locales/en.ts +0 -120
  297. package/src/v3/standard-schema.ts +0 -113
  298. package/src/v3/tests/Mocker.ts +0 -54
  299. package/src/v3/tests/all-errors.test.ts +0 -157
  300. package/src/v3/tests/anyunknown.test.ts +0 -28
  301. package/src/v3/tests/array.test.ts +0 -71
  302. package/src/v3/tests/async-parsing.test.ts +0 -388
  303. package/src/v3/tests/async-refinements.test.ts +0 -46
  304. package/src/v3/tests/base.test.ts +0 -29
  305. package/src/v3/tests/bigint.test.ts +0 -55
  306. package/src/v3/tests/branded.test.ts +0 -53
  307. package/src/v3/tests/catch.test.ts +0 -220
  308. package/src/v3/tests/coerce.test.ts +0 -133
  309. package/src/v3/tests/complex.test.ts +0 -56
  310. package/src/v3/tests/custom.test.ts +0 -31
  311. package/src/v3/tests/date.test.ts +0 -32
  312. package/src/v3/tests/deepmasking.test.ts +0 -186
  313. package/src/v3/tests/default.test.ts +0 -112
  314. package/src/v3/tests/description.test.ts +0 -33
  315. package/src/v3/tests/discriminated-unions.test.ts +0 -315
  316. package/src/v3/tests/enum.test.ts +0 -80
  317. package/src/v3/tests/error.test.ts +0 -551
  318. package/src/v3/tests/firstparty.test.ts +0 -87
  319. package/src/v3/tests/firstpartyschematypes.test.ts +0 -21
  320. package/src/v3/tests/function.test.ts +0 -257
  321. package/src/v3/tests/generics.test.ts +0 -48
  322. package/src/v3/tests/instanceof.test.ts +0 -37
  323. package/src/v3/tests/intersection.test.ts +0 -110
  324. package/src/v3/tests/language-server.source.ts +0 -76
  325. package/src/v3/tests/language-server.test.ts +0 -207
  326. package/src/v3/tests/literal.test.ts +0 -36
  327. package/src/v3/tests/map.test.ts +0 -110
  328. package/src/v3/tests/masking.test.ts +0 -4
  329. package/src/v3/tests/mocker.test.ts +0 -19
  330. package/src/v3/tests/nan.test.ts +0 -21
  331. package/src/v3/tests/nativeEnum.test.ts +0 -87
  332. package/src/v3/tests/nullable.test.ts +0 -42
  333. package/src/v3/tests/number.test.ts +0 -176
  334. package/src/v3/tests/object-augmentation.test.ts +0 -29
  335. package/src/v3/tests/object-in-es5-env.test.ts +0 -29
  336. package/src/v3/tests/object.test.ts +0 -434
  337. package/src/v3/tests/optional.test.ts +0 -42
  338. package/src/v3/tests/parseUtil.test.ts +0 -23
  339. package/src/v3/tests/parser.test.ts +0 -41
  340. package/src/v3/tests/partials.test.ts +0 -243
  341. package/src/v3/tests/pickomit.test.ts +0 -111
  342. package/src/v3/tests/pipeline.test.ts +0 -29
  343. package/src/v3/tests/preprocess.test.ts +0 -188
  344. package/src/v3/tests/primitive.test.ts +0 -440
  345. package/src/v3/tests/promise.test.ts +0 -90
  346. package/src/v3/tests/readonly.test.ts +0 -194
  347. package/src/v3/tests/record.test.ts +0 -171
  348. package/src/v3/tests/recursive.test.ts +0 -197
  349. package/src/v3/tests/refine.test.ts +0 -297
  350. package/src/v3/tests/safeparse.test.ts +0 -27
  351. package/src/v3/tests/set.test.ts +0 -142
  352. package/src/v3/tests/standard-schema.test.ts +0 -83
  353. package/src/v3/tests/string.test.ts +0 -916
  354. package/src/v3/tests/transformer.test.ts +0 -233
  355. package/src/v3/tests/tuple.test.ts +0 -90
  356. package/src/v3/tests/unions.test.ts +0 -57
  357. package/src/v3/tests/validations.test.ts +0 -133
  358. package/src/v3/tests/void.test.ts +0 -15
  359. package/src/v3/types.ts +0 -5135
  360. package/src/v4/classic/checks.ts +0 -30
  361. package/src/v4/classic/coerce.ts +0 -27
  362. package/src/v4/classic/compat.ts +0 -76
  363. package/src/v4/classic/errors.ts +0 -75
  364. package/src/v4/classic/external.ts +0 -31
  365. package/src/v4/classic/index.ts +0 -5
  366. package/src/v4/classic/iso.ts +0 -90
  367. package/src/v4/classic/parse.ts +0 -33
  368. package/src/v4/classic/schemas.ts +0 -2062
  369. package/src/v4/classic/tests/anyunknown.test.ts +0 -26
  370. package/src/v4/classic/tests/array.test.ts +0 -257
  371. package/src/v4/classic/tests/assignability.test.ts +0 -124
  372. package/src/v4/classic/tests/async-parsing.test.ts +0 -381
  373. package/src/v4/classic/tests/async-refinements.test.ts +0 -68
  374. package/src/v4/classic/tests/base.test.ts +0 -7
  375. package/src/v4/classic/tests/bigint.test.ts +0 -54
  376. package/src/v4/classic/tests/brand.test.ts +0 -57
  377. package/src/v4/classic/tests/catch.test.ts +0 -252
  378. package/src/v4/classic/tests/coalesce.test.ts +0 -20
  379. package/src/v4/classic/tests/coerce.test.ts +0 -160
  380. package/src/v4/classic/tests/custom.test.ts +0 -16
  381. package/src/v4/classic/tests/date.test.ts +0 -31
  382. package/src/v4/classic/tests/default.test.ts +0 -114
  383. package/src/v4/classic/tests/description.test.ts +0 -32
  384. package/src/v4/classic/tests/discriminated-unions.test.ts +0 -566
  385. package/src/v4/classic/tests/enum.test.ts +0 -285
  386. package/src/v4/classic/tests/error-utils.test.ts +0 -480
  387. package/src/v4/classic/tests/error.test.ts +0 -698
  388. package/src/v4/classic/tests/file.test.ts +0 -52
  389. package/src/v4/classic/tests/firstparty.test.ts +0 -177
  390. package/src/v4/classic/tests/function.test.ts +0 -230
  391. package/src/v4/classic/tests/generics.test.ts +0 -58
  392. package/src/v4/classic/tests/index.test.ts +0 -909
  393. package/src/v4/classic/tests/instanceof.test.ts +0 -34
  394. package/src/v4/classic/tests/intersection.test.ts +0 -171
  395. package/src/v4/classic/tests/json-schema.test.ts +0 -1810
  396. package/src/v4/classic/tests/json.test.ts +0 -108
  397. package/src/v4/classic/tests/lazy.test.ts +0 -227
  398. package/src/v4/classic/tests/literal.test.ts +0 -82
  399. package/src/v4/classic/tests/map.test.ts +0 -196
  400. package/src/v4/classic/tests/nan.test.ts +0 -21
  401. package/src/v4/classic/tests/nested-refine.test.ts +0 -165
  402. package/src/v4/classic/tests/nonoptional.test.ts +0 -86
  403. package/src/v4/classic/tests/nullable.test.ts +0 -22
  404. package/src/v4/classic/tests/number.test.ts +0 -242
  405. package/src/v4/classic/tests/object.test.ts +0 -493
  406. package/src/v4/classic/tests/optional.test.ts +0 -103
  407. package/src/v4/classic/tests/partial.test.ts +0 -147
  408. package/src/v4/classic/tests/pickomit.test.ts +0 -125
  409. package/src/v4/classic/tests/pipe.test.ts +0 -81
  410. package/src/v4/classic/tests/prefault.test.ts +0 -37
  411. package/src/v4/classic/tests/preprocess.test.ts +0 -272
  412. package/src/v4/classic/tests/primitive.test.ts +0 -175
  413. package/src/v4/classic/tests/promise.test.ts +0 -81
  414. package/src/v4/classic/tests/readonly.test.ts +0 -252
  415. package/src/v4/classic/tests/record.test.ts +0 -332
  416. package/src/v4/classic/tests/recursive-types.test.ts +0 -126
  417. package/src/v4/classic/tests/refine.test.ts +0 -423
  418. package/src/v4/classic/tests/registries.test.ts +0 -159
  419. package/src/v4/classic/tests/set.test.ts +0 -179
  420. package/src/v4/classic/tests/standard-schema.test.ts +0 -57
  421. package/src/v4/classic/tests/string-formats.test.ts +0 -31
  422. package/src/v4/classic/tests/string.test.ts +0 -1081
  423. package/src/v4/classic/tests/template-literal.test.ts +0 -758
  424. package/src/v4/classic/tests/transform.test.ts +0 -250
  425. package/src/v4/classic/tests/tuple.test.ts +0 -163
  426. package/src/v4/classic/tests/union.test.ts +0 -94
  427. package/src/v4/classic/tests/validations.test.ts +0 -277
  428. package/src/v4/classic/tests/void.test.ts +0 -12
  429. package/src/v4/core/api.ts +0 -1533
  430. package/src/v4/core/checks.ts +0 -1282
  431. package/src/v4/core/config.ts +0 -15
  432. package/src/v4/core/core.ts +0 -98
  433. package/src/v4/core/doc.ts +0 -45
  434. package/src/v4/core/errors.ts +0 -433
  435. package/src/v4/core/function.ts +0 -143
  436. package/src/v4/core/index.ts +0 -15
  437. package/src/v4/core/json-schema.ts +0 -106
  438. package/src/v4/core/parse.ts +0 -94
  439. package/src/v4/core/regexes.ts +0 -133
  440. package/src/v4/core/registries.ts +0 -89
  441. package/src/v4/core/schemas.ts +0 -3802
  442. package/src/v4/core/standard-schema.ts +0 -64
  443. package/src/v4/core/tests/index.test.ts +0 -46
  444. package/src/v4/core/tests/locales/be.test.ts +0 -124
  445. package/src/v4/core/tests/locales/en.test.ts +0 -22
  446. package/src/v4/core/tests/locales/ru.test.ts +0 -128
  447. package/src/v4/core/tests/locales/tr.test.ts +0 -69
  448. package/src/v4/core/to-json-schema.ts +0 -790
  449. package/src/v4/core/util.ts +0 -750
  450. package/src/v4/core/versions.ts +0 -5
  451. package/src/v4/core/zsf.ts +0 -323
  452. package/src/v4/index.ts +0 -4
  453. package/src/v4/locales/ar.ts +0 -125
  454. package/src/v4/locales/az.ts +0 -121
  455. package/src/v4/locales/be.ts +0 -185
  456. package/src/v4/locales/ca.ts +0 -127
  457. package/src/v4/locales/cs.ts +0 -142
  458. package/src/v4/locales/de.ts +0 -124
  459. package/src/v4/locales/en.ts +0 -127
  460. package/src/v4/locales/es.ts +0 -124
  461. package/src/v4/locales/fa.ts +0 -134
  462. package/src/v4/locales/fi.ts +0 -131
  463. package/src/v4/locales/fr.ts +0 -124
  464. package/src/v4/locales/frCA.ts +0 -126
  465. package/src/v4/locales/he.ts +0 -125
  466. package/src/v4/locales/hu.ts +0 -126
  467. package/src/v4/locales/id.ts +0 -124
  468. package/src/v4/locales/index.ts +0 -34
  469. package/src/v4/locales/it.ts +0 -125
  470. package/src/v4/locales/ja.ts +0 -122
  471. package/src/v4/locales/ko.ts +0 -131
  472. package/src/v4/locales/mk.ts +0 -127
  473. package/src/v4/locales/ms.ts +0 -124
  474. package/src/v4/locales/no.ts +0 -124
  475. package/src/v4/locales/ota.ts +0 -125
  476. package/src/v4/locales/pl.ts +0 -125
  477. package/src/v4/locales/pt.ts +0 -123
  478. package/src/v4/locales/ru.ts +0 -185
  479. package/src/v4/locales/sl.ts +0 -125
  480. package/src/v4/locales/ta.ts +0 -125
  481. package/src/v4/locales/th.ts +0 -126
  482. package/src/v4/locales/tr.ts +0 -121
  483. package/src/v4/locales/ua.ts +0 -126
  484. package/src/v4/locales/ur.ts +0 -126
  485. package/src/v4/locales/vi.ts +0 -125
  486. package/src/v4/locales/zh-CN.ts +0 -123
  487. package/src/v4/locales/zh-tw.ts +0 -125
  488. package/src/v4/mini/checks.ts +0 -32
  489. package/src/v4/mini/coerce.ts +0 -22
  490. package/src/v4/mini/external.ts +0 -26
  491. package/src/v4/mini/index.ts +0 -3
  492. package/src/v4/mini/iso.ts +0 -62
  493. package/src/v4/mini/parse.ts +0 -1
  494. package/src/v4/mini/schemas.ts +0 -1556
  495. package/src/v4/mini/tests/assignability.test.ts +0 -117
  496. package/src/v4/mini/tests/brand.test.ts +0 -51
  497. package/src/v4/mini/tests/checks.test.ts +0 -144
  498. package/src/v4/mini/tests/computed.test.ts +0 -36
  499. package/src/v4/mini/tests/error.test.ts +0 -22
  500. package/src/v4/mini/tests/functions.test.ts +0 -43
  501. package/src/v4/mini/tests/index.test.ts +0 -914
  502. package/src/v4/mini/tests/number.test.ts +0 -95
  503. package/src/v4/mini/tests/object.test.ts +0 -139
  504. package/src/v4/mini/tests/prototypes.test.ts +0 -23
  505. package/src/v4/mini/tests/recursive-types.test.ts +0 -124
  506. package/src/v4/mini/tests/string.test.ts +0 -284
@@ -1,2062 +0,0 @@
1
- import * as core from "zod/v4/core";
2
- import { util } from "zod/v4/core";
3
-
4
- import * as checks from "./checks.js";
5
- import * as iso from "./iso.js";
6
- import * as parse from "./parse.js";
7
-
8
- export * as iso from "./iso.js";
9
- export * as coerce from "./coerce.js";
10
-
11
- ///////////////////////////////////////////
12
- ///////////////////////////////////////////
13
- //////////// ////////////
14
- //////////// ZodType ////////////
15
- //////////// ////////////
16
- ///////////////////////////////////////////
17
- ///////////////////////////////////////////
18
-
19
- export interface RefinementCtx<T = unknown> extends core.ParsePayload<T> {
20
- addIssue(arg: string | core.$ZodRawIssue | Partial<core.$ZodIssueCustom>): void;
21
- }
22
-
23
- export interface ZodType<out Output = unknown, out Input = unknown> extends core.$ZodType<Output, Input> {
24
- def: this["_zod"]["def"];
25
- /** @deprecated Use `.def` instead. */
26
- _def: this["_zod"]["def"];
27
- // /** @deprecated Use `z.output<typeof schema>` instead. */
28
- _output: core.output<this>;
29
- // /** @deprecated Use `z.input<typeof schema>` instead. */
30
- _input: core.input<this>;
31
- // base methods
32
- check(...checks: (core.CheckFn<core.output<this>> | core.$ZodCheck<core.output<this>>)[]): this;
33
- clone(def?: this["_zod"]["def"], params?: { parent: boolean }): this;
34
- register<R extends core.$ZodRegistry>(
35
- registry: R,
36
- ...meta: this extends R["_schema"]
37
- ? undefined extends R["_meta"]
38
- ? [core.$ZodRegistry<R["_meta"], this>["_meta"]?]
39
- : [core.$ZodRegistry<R["_meta"], this>["_meta"]]
40
- : ["Incompatible schema"]
41
- ): this;
42
-
43
- brand<T extends PropertyKey = PropertyKey>(value?: T): PropertyKey extends T ? this : core.$ZodBranded<this, T>;
44
-
45
- // parsing
46
- parse(data: unknown, params?: core.ParseContext<core.$ZodIssue>): core.output<this>;
47
- safeParse(data: unknown, params?: core.ParseContext<core.$ZodIssue>): parse.ZodSafeParseResult<core.output<this>>;
48
- parseAsync(data: unknown, params?: core.ParseContext<core.$ZodIssue>): Promise<core.output<this>>;
49
- safeParseAsync(
50
- data: unknown,
51
- params?: core.ParseContext<core.$ZodIssue>
52
- ): Promise<parse.ZodSafeParseResult<core.output<this>>>;
53
- spa: (
54
- data: unknown,
55
- params?: core.ParseContext<core.$ZodIssue>
56
- ) => Promise<parse.ZodSafeParseResult<core.output<this>>>;
57
-
58
- // refinements
59
- refine(check: (arg: core.output<this>) => unknown | Promise<unknown>, params?: string | core.$ZodCustomParams): this;
60
- /** @deprecated Use `.check()` instead. */
61
- superRefine(
62
- refinement: (arg: core.output<this>, ctx: RefinementCtx<this["_zod"]["output"]>) => void | Promise<void>
63
- ): this;
64
- overwrite(fn: (x: core.output<this>) => core.output<this>): this;
65
-
66
- // wrappers
67
- optional(): ZodOptional<this>;
68
- nonoptional(params?: string | core.$ZodNonOptionalParams): ZodNonOptional<this>;
69
- nullable(): ZodNullable<this>;
70
- nullish(): ZodOptional<ZodNullable<this>>;
71
- default(def: util.NoUndefined<core.output<this>>): ZodDefault<this>;
72
- default(def: () => util.NoUndefined<core.output<this>>): ZodDefault<this>;
73
- prefault(def: () => core.input<this>): ZodPrefault<this>;
74
- prefault(def: core.input<this>): ZodPrefault<this>;
75
- array(): ZodArray<this>;
76
- or<T extends core.$ZodType>(option: T): ZodUnion<[this, T]>;
77
- and<T extends core.$ZodType>(incoming: T): ZodIntersection<this, T>;
78
- transform<NewOut>(
79
- transform: (arg: core.output<this>, ctx: RefinementCtx<core.output<this>>) => NewOut | Promise<NewOut>
80
- ): ZodPipe<this, ZodTransform<Awaited<NewOut>, core.output<this>>>;
81
- catch(def: core.output<this>): ZodCatch<this>;
82
- catch(def: (ctx: core.$ZodCatchCtx) => core.output<this>): ZodCatch<this>;
83
- pipe<T extends core.$ZodType<any, this["_zod"]["output"]>>(
84
- target: T | core.$ZodType<any, this["_zod"]["output"]>
85
- ): ZodPipe<this, T>;
86
- readonly(): ZodReadonly<this>;
87
-
88
- /** Returns a new instance that has been registered in `z.globalRegistry` with the specified description */
89
- describe(description: string): this;
90
- description?: string;
91
- /** Returns the metadata associated with this instance in `z.globalRegistry` */
92
- meta(): core.$replace<core.GlobalMeta, this> | undefined;
93
- /** Returns a new instance that has been registered in `z.globalRegistry` with the specified metadata */
94
- meta(data: core.$replace<core.GlobalMeta, this>): this;
95
-
96
- // helpers
97
- /** @deprecated Try safe-parsing `undefined` (this is what `isOptional` does internally):
98
- *
99
- * ```ts
100
- * const schema = z.string().optional();
101
- * const isOptional = schema.safeParse(undefined).success; // true
102
- * ```
103
- */
104
- isOptional(): boolean;
105
- /**
106
- * @deprecated Try safe-parsing `null` (this is what `isNullable` does internally):
107
- *
108
- * ```ts
109
- * const schema = z.string().nullable();
110
- * const isNullable = schema.safeParse(null).success; // true
111
- * ```
112
- */
113
- isNullable(): boolean;
114
- }
115
-
116
- export const ZodType: core.$constructor<ZodType> = /*@__PURE__*/ core.$constructor("ZodType", (inst, def) => {
117
- core.$ZodType.init(inst, def);
118
- inst.def = def;
119
- inst._def = def;
120
-
121
- // base methods
122
- inst.check = (...checks) => {
123
- return inst.clone(
124
- {
125
- ...def,
126
- checks: [
127
- ...(def.checks ?? []),
128
- ...checks.map((ch) =>
129
- typeof ch === "function" ? { _zod: { check: ch, def: { check: "custom" }, onattach: [] } } : ch
130
- ),
131
- ],
132
- }
133
- // { parent: true }
134
- );
135
- };
136
- inst.clone = (def, params) => core.clone(inst, def, params);
137
- inst.brand = () => inst as any;
138
- inst.register = ((reg: any, meta: any) => {
139
- reg.add(inst, meta);
140
- return inst;
141
- }) as any;
142
-
143
- // const parse: <T extends core.$ZodType>(
144
- // schema: T,
145
- // value: unknown,
146
- // _ctx?: core.ParseContext<core.$ZodIssue>
147
- // ) => core.output<T> = /* @__PURE__ */ core._parse(ZodError, parse) as any;
148
-
149
- // const safeParse: <T extends core.$ZodType>(
150
- // schema: T,
151
- // value: unknown,
152
- // _ctx?: core.ParseContext<core.$ZodIssue>
153
- // ) => ZodSafeParseResult<core.output<T>> = /* @__PURE__ */ core._safeParse(ZodError) as any;
154
-
155
- // const parseAsync: <T extends core.$ZodType>(
156
- // schema: T,
157
- // value: unknown,
158
- // _ctx?: core.ParseContext<core.$ZodIssue>
159
- // ) => Promise<core.output<T>> = /* @__PURE__ */ core._parseAsync(ZodError) as any;
160
-
161
- // const safeParseAsync: <T extends core.$ZodType>(
162
- // schema: T,
163
- // value: unknown,
164
- // _ctx?: core.ParseContext<core.$ZodIssue>
165
- // ) => Promise<ZodSafeParseResult<core.output<T>>> = /* @__PURE__ */ core._safeParseAsync(ZodError) as any;
166
-
167
- // parsing
168
- inst.parse = (data, params) => parse.parse(inst, data, params, { callee: inst.parse });
169
- inst.safeParse = (data, params) => parse.safeParse(inst, data, params);
170
- inst.parseAsync = async (data, params) => parse.parseAsync(inst, data, params, { callee: inst.parseAsync });
171
- inst.safeParseAsync = async (data, params) => parse.safeParseAsync(inst, data, params);
172
- inst.spa = inst.safeParseAsync;
173
-
174
- // refinements
175
- inst.refine = (check, params) => inst.check(refine(check, params));
176
- inst.superRefine = (refinement) => inst.check(superRefine(refinement));
177
- inst.overwrite = (fn) => inst.check(checks.overwrite(fn));
178
-
179
- // wrappers
180
- inst.optional = () => optional(inst);
181
- inst.nullable = () => nullable(inst);
182
- inst.nullish = () => optional(nullable(inst));
183
- inst.nonoptional = (params) => nonoptional(inst, params);
184
- inst.array = () => array(inst);
185
- inst.or = (arg) => union([inst, arg]);
186
- inst.and = (arg) => intersection(inst, arg);
187
- inst.transform = (tx) => pipe(inst, transform(tx as any)) as never;
188
- inst.default = (def) => _default(inst, def);
189
- inst.prefault = (def) => prefault(inst, def);
190
- // inst.coalesce = (def, params) => coalesce(inst, def, params);
191
- inst.catch = (params) => _catch(inst, params);
192
- inst.pipe = (target) => pipe(inst, target);
193
- inst.readonly = () => readonly(inst);
194
-
195
- // meta
196
- inst.describe = (description) => {
197
- const cl = inst.clone();
198
- core.globalRegistry.add(cl, { description });
199
- return cl;
200
- };
201
- Object.defineProperty(inst, "description", {
202
- get() {
203
- return core.globalRegistry.get(inst)?.description;
204
- },
205
- configurable: true,
206
- });
207
- inst.meta = (...args: any) => {
208
- if (args.length === 0) {
209
- return core.globalRegistry.get(inst);
210
- }
211
- const cl = inst.clone();
212
- core.globalRegistry.add(cl, args[0]);
213
- return cl as any;
214
- };
215
-
216
- // helpers
217
- inst.isOptional = () => inst.safeParse(undefined).success;
218
- inst.isNullable = () => inst.safeParse(null).success;
219
- return inst;
220
- });
221
-
222
- // ZodString
223
- export interface _ZodString<Input = unknown> extends ZodType {
224
- _zod: core.$ZodStringInternals<Input>;
225
-
226
- format: string | null;
227
- minLength: number | null;
228
- maxLength: number | null;
229
-
230
- // /** @deprecated Use `z.jsonString()` instead. */
231
- // json(params?: string | core.$ZodCheckJSONStringParams): this;
232
-
233
- // miscellaneous checks
234
- regex(regex: RegExp, params?: string | core.$ZodCheckRegexParams): this;
235
- includes(value: string, params?: core.$ZodCheckIncludesParams): this;
236
- startsWith(value: string, params?: string | core.$ZodCheckStartsWithParams): this;
237
- endsWith(value: string, params?: string | core.$ZodCheckEndsWithParams): this;
238
- min(minLength: number, params?: string | core.$ZodCheckMinLengthParams): this;
239
- max(maxLength: number, params?: string | core.$ZodCheckMaxLengthParams): this;
240
- length(len: number, params?: string | core.$ZodCheckLengthEqualsParams): this;
241
- nonempty(params?: string | core.$ZodCheckMinLengthParams): this;
242
- lowercase(params?: string | core.$ZodCheckLowerCaseParams): this;
243
- uppercase(params?: string | core.$ZodCheckUpperCaseParams): this;
244
-
245
- // transforms
246
- trim(): this;
247
- normalize(form?: "NFC" | "NFD" | "NFKC" | "NFKD" | (string & {})): this;
248
- toLowerCase(): this;
249
- toUpperCase(): this;
250
- }
251
-
252
- /** @internal */
253
- export const _ZodString: core.$constructor<_ZodString> = /*@__PURE__*/ core.$constructor("_ZodString", (inst, def) => {
254
- core.$ZodString.init(inst, def);
255
- ZodType.init(inst, def);
256
-
257
- const bag = inst._zod.bag;
258
- inst.format = bag.format ?? null;
259
- inst.minLength = bag.minimum ?? null;
260
- inst.maxLength = bag.maximum ?? null;
261
-
262
- // validations
263
- inst.regex = (...args) => inst.check(checks.regex(...args));
264
- inst.includes = (...args) => inst.check(checks.includes(...args));
265
- inst.startsWith = (params) => inst.check(checks.startsWith(params));
266
- inst.endsWith = (params) => inst.check(checks.endsWith(params));
267
- inst.min = (...args) => inst.check(checks.minLength(...args));
268
- inst.max = (...args) => inst.check(checks.maxLength(...args));
269
- inst.length = (...args) => inst.check(checks.length(...args));
270
- inst.nonempty = (...args) => inst.check(checks.minLength(1, ...args));
271
- inst.lowercase = (params) => inst.check(checks.lowercase(params));
272
- inst.uppercase = (params) => inst.check(checks.uppercase(params));
273
-
274
- // transforms
275
- inst.trim = () => inst.check(checks.trim());
276
- inst.normalize = (...args) => inst.check(checks.normalize(...args));
277
- inst.toLowerCase = () => inst.check(checks.toLowerCase());
278
- inst.toUpperCase = () => inst.check(checks.toUpperCase());
279
- });
280
-
281
- export interface ZodString extends _ZodString<string> {
282
- // string format checks
283
- // email(): ZodString;
284
- // email(params?: string): ZodString;
285
- // email(params?: StringFormatParams): ZodString;
286
- /** @deprecated Use `z.email()` instead. */
287
- email(params?: string | core.$ZodCheckEmailParams): this;
288
- /** @deprecated Use `z.url()` instead. */
289
- url(params?: string | core.$ZodCheckURLParams): this;
290
- /** @deprecated Use `z.jwt()` instead. */
291
- jwt(params?: string | core.$ZodCheckJWTParams): this;
292
- /** @deprecated Use `z.emoji()` instead. */
293
- emoji(params?: string | core.$ZodCheckEmojiParams): this;
294
- /** @deprecated Use `z.guid()` instead. */
295
- guid(params?: string | core.$ZodCheckGUIDParams): this;
296
- /** @deprecated Use `z.uuid()` instead. */
297
- uuid(params?: string | core.$ZodCheckUUIDParams): this;
298
- /** @deprecated Use `z.uuid()` instead. */
299
- uuidv4(params?: string | core.$ZodCheckUUIDParams): this;
300
- /** @deprecated Use `z.uuid()` instead. */
301
- uuidv6(params?: string | core.$ZodCheckUUIDParams): this;
302
- /** @deprecated Use `z.uuid()` instead. */
303
- uuidv7(params?: string | core.$ZodCheckUUIDParams): this;
304
- /** @deprecated Use `z.nanoid()` instead. */
305
- nanoid(params?: string | core.$ZodCheckNanoIDParams): this;
306
- /** @deprecated Use `z.guid()` instead. */
307
- guid(params?: string | core.$ZodCheckGUIDParams): this;
308
- /** @deprecated Use `z.cuid()` instead. */
309
- cuid(params?: string | core.$ZodCheckCUIDParams): this;
310
- /** @deprecated Use `z.cuid2()` instead. */
311
- cuid2(params?: string | core.$ZodCheckCUID2Params): this;
312
- /** @deprecated Use `z.ulid()` instead. */
313
- ulid(params?: string | core.$ZodCheckULIDParams): this;
314
- /** @deprecated Use `z.base64()` instead. */
315
- base64(params?: string | core.$ZodCheckBase64Params): this;
316
- /** @deprecated Use `z.base64url()` instead. */
317
- base64url(params?: string | core.$ZodCheckBase64URLParams): this;
318
- // /** @deprecated Use `z.jsonString()` instead. */
319
- // jsonString(params?: string | core.$ZodCheckJSONStringParams): this;
320
- /** @deprecated Use `z.xid()` instead. */
321
- xid(params?: string | core.$ZodCheckXIDParams): this;
322
- /** @deprecated Use `z.ksuid()` instead. */
323
- ksuid(params?: string | core.$ZodCheckKSUIDParams): this;
324
- // /** @deprecated Use `z.ipv4()` or `z.ipv6()` instead. */
325
- // ip(params?: string | (core.$ZodCheckIPv4Params & { version?: "v4" | "v6" })): ZodUnion<[this, this]>;
326
- /** @deprecated Use `z.ipv4()` instead. */
327
- ipv4(params?: string | core.$ZodCheckIPv4Params): this;
328
- /** @deprecated Use `z.ipv6()` instead. */
329
- ipv6(params?: string | core.$ZodCheckIPv6Params): this;
330
- /** @deprecated Use `z.cidrv4()` instead. */
331
- cidrv4(params?: string | core.$ZodCheckCIDRv4Params): this;
332
- /** @deprecated Use `z.cidrv6()` instead. */
333
- cidrv6(params?: string | core.$ZodCheckCIDRv6Params): this;
334
- /** @deprecated Use `z.e164()` instead. */
335
- e164(params?: string | core.$ZodCheckE164Params): this;
336
-
337
- // ISO 8601 checks
338
- /** @deprecated Use `z.iso.datetime()` instead. */
339
- datetime(params?: string | core.$ZodCheckISODateTimeParams): this;
340
- /** @deprecated Use `z.iso.date()` instead. */
341
- date(params?: string | core.$ZodCheckISODateParams): this;
342
- /** @deprecated Use `z.iso.time()` instead. */
343
- time(
344
- params?:
345
- | string
346
- // | {
347
- // message?: string | undefined;
348
- // precision?: number | null;
349
- // }
350
- | core.$ZodCheckISOTimeParams
351
- ): this;
352
- /** @deprecated Use `z.iso.duration()` instead. */
353
- duration(params?: string | core.$ZodCheckISODurationParams): this;
354
- }
355
-
356
- export const ZodString: core.$constructor<ZodString> = /*@__PURE__*/ core.$constructor("ZodString", (inst, def) => {
357
- core.$ZodString.init(inst, def);
358
- _ZodString.init(inst, def);
359
-
360
- inst.email = (params) => inst.check(core._email(ZodEmail, params));
361
- inst.url = (params) => inst.check(core._url(ZodURL, params));
362
- inst.jwt = (params) => inst.check(core._jwt(ZodJWT, params));
363
- inst.emoji = (params) => inst.check(core._emoji(ZodEmoji, params));
364
- inst.guid = (params) => inst.check(core._guid(ZodGUID, params));
365
- inst.uuid = (params) => inst.check(core._uuid(ZodUUID, params));
366
- inst.uuidv4 = (params) => inst.check(core._uuidv4(ZodUUID, params));
367
- inst.uuidv6 = (params) => inst.check(core._uuidv6(ZodUUID, params));
368
- inst.uuidv7 = (params) => inst.check(core._uuidv7(ZodUUID, params));
369
- inst.nanoid = (params) => inst.check(core._nanoid(ZodNanoID, params));
370
- inst.guid = (params) => inst.check(core._guid(ZodGUID, params));
371
- inst.cuid = (params) => inst.check(core._cuid(ZodCUID, params));
372
- inst.cuid2 = (params) => inst.check(core._cuid2(ZodCUID2, params));
373
- inst.ulid = (params) => inst.check(core._ulid(ZodULID, params));
374
- inst.base64 = (params) => inst.check(core._base64(ZodBase64, params));
375
- inst.base64url = (params) => inst.check(core._base64url(ZodBase64URL, params));
376
- inst.xid = (params) => inst.check(core._xid(ZodXID, params));
377
- inst.ksuid = (params) => inst.check(core._ksuid(ZodKSUID, params));
378
- inst.ipv4 = (params) => inst.check(core._ipv4(ZodIPv4, params));
379
- inst.ipv6 = (params) => inst.check(core._ipv6(ZodIPv6, params));
380
- inst.cidrv4 = (params) => inst.check(core._cidrv4(ZodCIDRv4, params));
381
- inst.cidrv6 = (params) => inst.check(core._cidrv6(ZodCIDRv6, params));
382
- inst.e164 = (params) => inst.check(core._e164(ZodE164, params));
383
-
384
- // iso
385
- inst.datetime = (params) => inst.check(iso.datetime(params as any));
386
- inst.date = (params) => inst.check(iso.date(params as any));
387
- inst.time = (params) => inst.check(iso.time(params as any));
388
- inst.duration = (params) => inst.check(iso.duration(params as any));
389
- });
390
-
391
- export function string(params?: string | core.$ZodStringParams): ZodString {
392
- return core._string(ZodString, params) as any;
393
- }
394
-
395
- // ZodStringFormat
396
- export interface ZodStringFormat<Format extends core.$ZodStringFormats = core.$ZodStringFormats> extends _ZodString {
397
- _zod: core.$ZodStringFormatInternals<Format>;
398
- }
399
- export const ZodStringFormat: core.$constructor<ZodStringFormat> = /*@__PURE__*/ core.$constructor(
400
- "ZodStringFormat",
401
- (inst, def) => {
402
- core.$ZodStringFormat.init(inst, def);
403
- _ZodString.init(inst, def);
404
- }
405
- );
406
-
407
- // ZodEmail
408
- export interface ZodEmail extends ZodStringFormat<"email"> {
409
- _zod: core.$ZodEmailInternals;
410
- }
411
- export const ZodEmail: core.$constructor<ZodEmail> = /*@__PURE__*/ core.$constructor("ZodEmail", (inst, def) => {
412
- // ZodStringFormat.init(inst, def);
413
- core.$ZodEmail.init(inst, def);
414
- ZodStringFormat.init(inst, def);
415
- });
416
-
417
- export function email(params?: string | core.$ZodEmailParams): ZodEmail {
418
- return core._email(ZodEmail, params);
419
- }
420
-
421
- // ZodGUID
422
- export interface ZodGUID extends ZodStringFormat<"guid"> {
423
- _zod: core.$ZodGUIDInternals;
424
- }
425
- export const ZodGUID: core.$constructor<ZodGUID> = /*@__PURE__*/ core.$constructor("ZodGUID", (inst, def) => {
426
- // ZodStringFormat.init(inst, def);
427
- core.$ZodGUID.init(inst, def);
428
- ZodStringFormat.init(inst, def);
429
- });
430
-
431
- export function guid(params?: string | core.$ZodGUIDParams): ZodGUID {
432
- return core._guid(ZodGUID, params);
433
- }
434
-
435
- // ZodUUID
436
- export interface ZodUUID extends ZodStringFormat<"uuid"> {
437
- _zod: core.$ZodUUIDInternals;
438
- }
439
- export const ZodUUID: core.$constructor<ZodUUID> = /*@__PURE__*/ core.$constructor("ZodUUID", (inst, def) => {
440
- // ZodStringFormat.init(inst, def);
441
- core.$ZodUUID.init(inst, def);
442
- ZodStringFormat.init(inst, def);
443
- });
444
-
445
- export function uuid(params?: string | core.$ZodUUIDParams): ZodUUID {
446
- return core._uuid(ZodUUID, params);
447
- }
448
-
449
- export function uuidv4(params?: string | core.$ZodUUIDv4Params): ZodUUID {
450
- return core._uuidv4(ZodUUID, params);
451
- }
452
-
453
- // ZodUUIDv6
454
-
455
- export function uuidv6(params?: string | core.$ZodUUIDv6Params): ZodUUID {
456
- return core._uuidv6(ZodUUID, params);
457
- }
458
-
459
- // ZodUUIDv7
460
-
461
- export function uuidv7(params?: string | core.$ZodUUIDv7Params): ZodUUID {
462
- return core._uuidv7(ZodUUID, params);
463
- }
464
-
465
- // ZodURL
466
- export interface ZodURL extends ZodStringFormat<"url"> {
467
- _zod: core.$ZodURLInternals;
468
- }
469
- export const ZodURL: core.$constructor<ZodURL> = /*@__PURE__*/ core.$constructor("ZodURL", (inst, def) => {
470
- // ZodStringFormat.init(inst, def);
471
- core.$ZodURL.init(inst, def);
472
- ZodStringFormat.init(inst, def);
473
- });
474
-
475
- export function url(params?: string | core.$ZodURLParams): ZodURL {
476
- return core._url(ZodURL, params);
477
- }
478
-
479
- // ZodEmoji
480
- export interface ZodEmoji extends ZodStringFormat<"emoji"> {
481
- _zod: core.$ZodEmojiInternals;
482
- }
483
- export const ZodEmoji: core.$constructor<ZodEmoji> = /*@__PURE__*/ core.$constructor("ZodEmoji", (inst, def) => {
484
- // ZodStringFormat.init(inst, def);
485
- core.$ZodEmoji.init(inst, def);
486
- ZodStringFormat.init(inst, def);
487
- });
488
-
489
- export function emoji(params?: string | core.$ZodEmojiParams): ZodEmoji {
490
- return core._emoji(ZodEmoji, params);
491
- }
492
-
493
- // ZodNanoID
494
- export interface ZodNanoID extends ZodStringFormat<"nanoid"> {
495
- _zod: core.$ZodNanoIDInternals;
496
- }
497
- export const ZodNanoID: core.$constructor<ZodNanoID> = /*@__PURE__*/ core.$constructor("ZodNanoID", (inst, def) => {
498
- // ZodStringFormat.init(inst, def);
499
- core.$ZodNanoID.init(inst, def);
500
- ZodStringFormat.init(inst, def);
501
- });
502
-
503
- export function nanoid(params?: string | core.$ZodNanoIDParams): ZodNanoID {
504
- return core._nanoid(ZodNanoID, params);
505
- }
506
-
507
- // ZodCUID
508
- export interface ZodCUID extends ZodStringFormat<"cuid"> {
509
- _zod: core.$ZodCUIDInternals;
510
- }
511
- export const ZodCUID: core.$constructor<ZodCUID> = /*@__PURE__*/ core.$constructor("ZodCUID", (inst, def) => {
512
- // ZodStringFormat.init(inst, def);
513
- core.$ZodCUID.init(inst, def);
514
- ZodStringFormat.init(inst, def);
515
- });
516
-
517
- export function cuid(params?: string | core.$ZodCUIDParams): ZodCUID {
518
- return core._cuid(ZodCUID, params);
519
- }
520
-
521
- // ZodCUID2
522
- export interface ZodCUID2 extends ZodStringFormat<"cuid2"> {
523
- _zod: core.$ZodCUID2Internals;
524
- }
525
- export const ZodCUID2: core.$constructor<ZodCUID2> = /*@__PURE__*/ core.$constructor("ZodCUID2", (inst, def) => {
526
- // ZodStringFormat.init(inst, def);
527
- core.$ZodCUID2.init(inst, def);
528
- ZodStringFormat.init(inst, def);
529
- });
530
-
531
- export function cuid2(params?: string | core.$ZodCUID2Params): ZodCUID2 {
532
- return core._cuid2(ZodCUID2, params);
533
- }
534
-
535
- // ZodULID
536
- export interface ZodULID extends ZodStringFormat<"ulid"> {
537
- _zod: core.$ZodULIDInternals;
538
- }
539
- export const ZodULID: core.$constructor<ZodULID> = /*@__PURE__*/ core.$constructor("ZodULID", (inst, def) => {
540
- // ZodStringFormat.init(inst, def);
541
- core.$ZodULID.init(inst, def);
542
- ZodStringFormat.init(inst, def);
543
- });
544
-
545
- export function ulid(params?: string | core.$ZodULIDParams): ZodULID {
546
- return core._ulid(ZodULID, params);
547
- }
548
-
549
- // ZodXID
550
- export interface ZodXID extends ZodStringFormat<"xid"> {
551
- _zod: core.$ZodXIDInternals;
552
- }
553
- export const ZodXID: core.$constructor<ZodXID> = /*@__PURE__*/ core.$constructor("ZodXID", (inst, def) => {
554
- // ZodStringFormat.init(inst, def);
555
- core.$ZodXID.init(inst, def);
556
- ZodStringFormat.init(inst, def);
557
- });
558
-
559
- export function xid(params?: string | core.$ZodXIDParams): ZodXID {
560
- return core._xid(ZodXID, params);
561
- }
562
-
563
- // ZodKSUID
564
- export interface ZodKSUID extends ZodStringFormat<"ksuid"> {
565
- _zod: core.$ZodKSUIDInternals;
566
- }
567
- export const ZodKSUID: core.$constructor<ZodKSUID> = /*@__PURE__*/ core.$constructor("ZodKSUID", (inst, def) => {
568
- // ZodStringFormat.init(inst, def);
569
- core.$ZodKSUID.init(inst, def);
570
- ZodStringFormat.init(inst, def);
571
- });
572
-
573
- export function ksuid(params?: string | core.$ZodKSUIDParams): ZodKSUID {
574
- return core._ksuid(ZodKSUID, params);
575
- }
576
-
577
- // ZodIP
578
- // export interface ZodIP extends ZodStringFormat<"ip"> {
579
- // _zod: core.$ZodIPInternals;
580
- // }
581
- // export const ZodIP: core.$constructor<ZodIP> = /*@__PURE__*/ core.$constructor("ZodIP", (inst, def) => {
582
- // // ZodStringFormat.init(inst, def);
583
- // core.$ZodIP.init(inst, def);
584
- // ZodStringFormat.init(inst, def);
585
- // });
586
-
587
- // export function ip(params?: string | core.$ZodIPParams): ZodIP {
588
- // return core._ip(ZodIP, params);
589
- // }
590
-
591
- // ZodIPv4
592
- export interface ZodIPv4 extends ZodStringFormat<"ipv4"> {
593
- _zod: core.$ZodIPv4Internals;
594
- }
595
- export const ZodIPv4: core.$constructor<ZodIPv4> = /*@__PURE__*/ core.$constructor("ZodIPv4", (inst, def) => {
596
- // ZodStringFormat.init(inst, def);
597
- core.$ZodIPv4.init(inst, def);
598
- ZodStringFormat.init(inst, def);
599
- });
600
-
601
- export function ipv4(params?: string | core.$ZodIPv4Params): ZodIPv4 {
602
- return core._ipv4(ZodIPv4, params);
603
- }
604
-
605
- // ZodIPv6
606
- export interface ZodIPv6 extends ZodStringFormat<"ipv6"> {
607
- _zod: core.$ZodIPv6Internals;
608
- }
609
- export const ZodIPv6: core.$constructor<ZodIPv6> = /*@__PURE__*/ core.$constructor("ZodIPv6", (inst, def) => {
610
- // ZodStringFormat.init(inst, def);
611
- core.$ZodIPv6.init(inst, def);
612
- ZodStringFormat.init(inst, def);
613
- });
614
- export function ipv6(params?: string | core.$ZodIPv6Params): ZodIPv6 {
615
- return core._ipv6(ZodIPv6, params);
616
- }
617
-
618
- // ZodCIDRv4
619
- export interface ZodCIDRv4 extends ZodStringFormat<"cidrv4"> {
620
- _zod: core.$ZodCIDRv4Internals;
621
- }
622
- export const ZodCIDRv4: core.$constructor<ZodCIDRv4> = /*@__PURE__*/ core.$constructor("ZodCIDRv4", (inst, def) => {
623
- core.$ZodCIDRv4.init(inst, def);
624
- ZodStringFormat.init(inst, def);
625
- });
626
-
627
- export function cidrv4(params?: string | core.$ZodCIDRv4Params): ZodCIDRv4 {
628
- return core._cidrv4(ZodCIDRv4, params);
629
- }
630
-
631
- // ZodCIDRv6
632
- export interface ZodCIDRv6 extends ZodStringFormat<"cidrv6"> {
633
- _zod: core.$ZodCIDRv6Internals;
634
- }
635
- export const ZodCIDRv6: core.$constructor<ZodCIDRv6> = /*@__PURE__*/ core.$constructor("ZodCIDRv6", (inst, def) => {
636
- core.$ZodCIDRv6.init(inst, def);
637
- ZodStringFormat.init(inst, def);
638
- });
639
-
640
- export function cidrv6(params?: string | core.$ZodCIDRv6Params): ZodCIDRv6 {
641
- return core._cidrv6(ZodCIDRv6, params);
642
- }
643
-
644
- // ZodBase64
645
- export interface ZodBase64 extends ZodStringFormat<"base64"> {
646
- _zod: core.$ZodBase64Internals;
647
- }
648
- export const ZodBase64: core.$constructor<ZodBase64> = /*@__PURE__*/ core.$constructor("ZodBase64", (inst, def) => {
649
- // ZodStringFormat.init(inst, def);
650
- core.$ZodBase64.init(inst, def);
651
- ZodStringFormat.init(inst, def);
652
- });
653
- export function base64(params?: string | core.$ZodBase64Params): ZodBase64 {
654
- return core._base64(ZodBase64, params);
655
- }
656
-
657
- // ZodBase64URL
658
- export interface ZodBase64URL extends ZodStringFormat<"base64url"> {
659
- _zod: core.$ZodBase64URLInternals;
660
- }
661
- export const ZodBase64URL: core.$constructor<ZodBase64URL> = /*@__PURE__*/ core.$constructor(
662
- "ZodBase64URL",
663
- (inst, def) => {
664
- // ZodStringFormat.init(inst, def);
665
- core.$ZodBase64URL.init(inst, def);
666
- ZodStringFormat.init(inst, def);
667
- }
668
- );
669
- export function base64url(params?: string | core.$ZodBase64URLParams): ZodBase64URL {
670
- return core._base64url(ZodBase64URL, params);
671
- }
672
-
673
- // ZodE164
674
- export interface ZodE164 extends ZodStringFormat<"e164"> {
675
- _zod: core.$ZodE164Internals;
676
- }
677
- export const ZodE164: core.$constructor<ZodE164> = /*@__PURE__*/ core.$constructor("ZodE164", (inst, def) => {
678
- // ZodStringFormat.init(inst, def);
679
- core.$ZodE164.init(inst, def);
680
- ZodStringFormat.init(inst, def);
681
- });
682
-
683
- export function e164(params?: string | core.$ZodE164Params): ZodE164 {
684
- return core._e164(ZodE164, params);
685
- }
686
-
687
- // ZodJWT
688
- export interface ZodJWT extends ZodStringFormat<"jwt"> {
689
- _zod: core.$ZodJWTInternals;
690
- }
691
- export const ZodJWT: core.$constructor<ZodJWT> = /*@__PURE__*/ core.$constructor("ZodJWT", (inst, def) => {
692
- // ZodStringFormat.init(inst, def);
693
- core.$ZodJWT.init(inst, def);
694
- ZodStringFormat.init(inst, def);
695
- });
696
-
697
- export function jwt(params?: string | core.$ZodJWTParams): ZodJWT {
698
- return core._jwt(ZodJWT, params);
699
- }
700
-
701
- // ZodNumber
702
- export interface _ZodNumber<Input = unknown> extends ZodType {
703
- _zod: core.$ZodNumberInternals<Input>;
704
-
705
- gt(value: number, params?: string | core.$ZodCheckGreaterThanParams): this;
706
- /** Identical to .min() */
707
- gte(value: number, params?: string | core.$ZodCheckGreaterThanParams): this;
708
- min(value: number, params?: string | core.$ZodCheckGreaterThanParams): this;
709
- lt(value: number, params?: string | core.$ZodCheckLessThanParams): this;
710
- /** Identical to .max() */
711
- lte(value: number, params?: string | core.$ZodCheckLessThanParams): this;
712
- max(value: number, params?: string | core.$ZodCheckLessThanParams): this;
713
- /** Consider `z.int()` instead. This API is considered *legacy*; it will never be removed but a better alternative exists. */
714
- int(params?: string | core.$ZodCheckNumberFormatParams): this;
715
- /** @deprecated This is now identical to `.int()`. Only numbers in the safe integer range are accepted. */
716
- safe(params?: string | core.$ZodCheckNumberFormatParams): this;
717
- positive(params?: string | core.$ZodCheckGreaterThanParams): this;
718
- nonnegative(params?: string | core.$ZodCheckGreaterThanParams): this;
719
- negative(params?: string | core.$ZodCheckLessThanParams): this;
720
- nonpositive(params?: string | core.$ZodCheckLessThanParams): this;
721
- multipleOf(value: number, params?: string | core.$ZodCheckMultipleOfParams): this;
722
- /** @deprecated Use `.multipleOf()` instead. */
723
- step(value: number, params?: string | core.$ZodCheckMultipleOfParams): this;
724
-
725
- /** @deprecated In v4 and later, z.number() does not allow infinite values by default. This is a no-op. */
726
- finite(params?: unknown): this;
727
-
728
- minValue: number | null;
729
- maxValue: number | null;
730
- /** @deprecated Check the `format` property instead. */
731
- isInt: boolean;
732
- /** @deprecated Number schemas no longer accept infinite values, so this always returns `true`. */
733
- isFinite: boolean;
734
- format: string | null;
735
- }
736
-
737
- export interface ZodNumber extends _ZodNumber<number> {}
738
-
739
- export const ZodNumber: core.$constructor<ZodNumber> = /*@__PURE__*/ core.$constructor("ZodNumber", (inst, def) => {
740
- core.$ZodNumber.init(inst, def);
741
- ZodType.init(inst, def);
742
-
743
- inst.gt = (value, params) => inst.check(checks.gt(value, params));
744
- inst.gte = (value, params) => inst.check(checks.gte(value, params));
745
- inst.min = (value, params) => inst.check(checks.gte(value, params));
746
- inst.lt = (value, params) => inst.check(checks.lt(value, params));
747
- inst.lte = (value, params) => inst.check(checks.lte(value, params));
748
- inst.max = (value, params) => inst.check(checks.lte(value, params));
749
- inst.int = (params) => inst.check(int(params));
750
- inst.safe = (params) => inst.check(int(params));
751
- inst.positive = (params) => inst.check(checks.gt(0, params));
752
- inst.nonnegative = (params) => inst.check(checks.gte(0, params));
753
- inst.negative = (params) => inst.check(checks.lt(0, params));
754
- inst.nonpositive = (params) => inst.check(checks.lte(0, params));
755
- inst.multipleOf = (value, params) => inst.check(checks.multipleOf(value, params));
756
- inst.step = (value, params) => inst.check(checks.multipleOf(value, params));
757
-
758
- // inst.finite = (params) => inst.check(core.finite(params));
759
- inst.finite = () => inst;
760
-
761
- const bag = inst._zod.bag;
762
- inst.minValue =
763
- Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;
764
- inst.maxValue =
765
- Math.min(bag.maximum ?? Number.POSITIVE_INFINITY, bag.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null;
766
- inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? 0.5);
767
- inst.isFinite = true;
768
- inst.format = bag.format ?? null;
769
- });
770
-
771
- export function number(params?: string | core.$ZodNumberParams): ZodNumber {
772
- return core._number(ZodNumber, params) as any;
773
- }
774
-
775
- // ZodNumberFormat
776
- export interface ZodNumberFormat extends ZodNumber {
777
- _zod: core.$ZodNumberFormatInternals;
778
- }
779
- export const ZodNumberFormat: core.$constructor<ZodNumberFormat> = /*@__PURE__*/ core.$constructor(
780
- "ZodNumberFormat",
781
- (inst, def) => {
782
- core.$ZodNumberFormat.init(inst, def);
783
- ZodNumber.init(inst, def);
784
- }
785
- );
786
-
787
- // int
788
- export interface ZodInt extends ZodNumberFormat {}
789
- export function int(params?: string | core.$ZodCheckNumberFormatParams): ZodInt {
790
- return core._int(ZodNumberFormat, params);
791
- }
792
-
793
- // float32
794
- export interface ZodFloat32 extends ZodNumberFormat {}
795
- export function float32(params?: string | core.$ZodCheckNumberFormatParams): ZodFloat32 {
796
- return core._float32(ZodNumberFormat, params);
797
- }
798
-
799
- // float64
800
- export interface ZodFloat64 extends ZodNumberFormat {}
801
- export function float64(params?: string | core.$ZodCheckNumberFormatParams): ZodFloat64 {
802
- return core._float64(ZodNumberFormat, params);
803
- }
804
-
805
- // int32
806
- export interface ZodInt32 extends ZodNumberFormat {}
807
- export function int32(params?: string | core.$ZodCheckNumberFormatParams): ZodInt32 {
808
- return core._int32(ZodNumberFormat, params);
809
- }
810
-
811
- // uint32
812
- export interface ZodUInt32 extends ZodNumberFormat {}
813
- export function uint32(params?: string | core.$ZodCheckNumberFormatParams): ZodUInt32 {
814
- return core._uint32(ZodNumberFormat, params);
815
- }
816
-
817
- // boolean
818
- export interface _ZodBoolean<T = unknown> extends ZodType {
819
- _zod: core.$ZodBooleanInternals<T>;
820
- }
821
- export interface ZodBoolean extends _ZodBoolean<boolean> {}
822
- export const ZodBoolean: core.$constructor<ZodBoolean> = /*@__PURE__*/ core.$constructor("ZodBoolean", (inst, def) => {
823
- core.$ZodBoolean.init(inst, def);
824
- ZodType.init(inst, def);
825
- });
826
-
827
- export function boolean(params?: string | core.$ZodBooleanParams): ZodBoolean {
828
- return core._boolean(ZodBoolean, params) as any;
829
- }
830
-
831
- // bigint
832
- export interface _ZodBigInt<T = unknown> extends ZodType {
833
- _zod: core.$ZodBigIntInternals<T>;
834
-
835
- gte(value: bigint, params?: string | core.$ZodCheckGreaterThanParams): this;
836
- /** Alias of `.gte()` */
837
- min(value: bigint, params?: string | core.$ZodCheckGreaterThanParams): this;
838
- gt(value: bigint, params?: string | core.$ZodCheckGreaterThanParams): this;
839
- /** Alias of `.lte()` */
840
- lte(value: bigint, params?: string | core.$ZodCheckLessThanParams): this;
841
- max(value: bigint, params?: string | core.$ZodCheckLessThanParams): this;
842
- lt(value: bigint, params?: string | core.$ZodCheckLessThanParams): this;
843
- positive(params?: string | core.$ZodCheckGreaterThanParams): this;
844
- negative(params?: string | core.$ZodCheckLessThanParams): this;
845
- nonpositive(params?: string | core.$ZodCheckLessThanParams): this;
846
- nonnegative(params?: string | core.$ZodCheckGreaterThanParams): this;
847
- multipleOf(value: bigint, params?: string | core.$ZodCheckMultipleOfParams): this;
848
-
849
- minValue: bigint | null;
850
- maxValue: bigint | null;
851
- format: string | null;
852
- }
853
-
854
- export interface ZodBigInt extends _ZodBigInt<bigint> {}
855
- export const ZodBigInt: core.$constructor<ZodBigInt> = /*@__PURE__*/ core.$constructor("ZodBigInt", (inst, def) => {
856
- core.$ZodBigInt.init(inst, def);
857
- ZodType.init(inst, def);
858
-
859
- inst.gte = (value, params) => inst.check(checks.gte(value, params));
860
- inst.min = (value, params) => inst.check(checks.gte(value, params));
861
- inst.gt = (value, params) => inst.check(checks.gt(value, params));
862
- inst.gte = (value, params) => inst.check(checks.gte(value, params));
863
- inst.min = (value, params) => inst.check(checks.gte(value, params));
864
- inst.lt = (value, params) => inst.check(checks.lt(value, params));
865
- inst.lte = (value, params) => inst.check(checks.lte(value, params));
866
- inst.max = (value, params) => inst.check(checks.lte(value, params));
867
- inst.positive = (params) => inst.check(checks.gt(BigInt(0), params));
868
- inst.negative = (params) => inst.check(checks.lt(BigInt(0), params));
869
- inst.nonpositive = (params) => inst.check(checks.lte(BigInt(0), params));
870
- inst.nonnegative = (params) => inst.check(checks.gte(BigInt(0), params));
871
- inst.multipleOf = (value, params) => inst.check(checks.multipleOf(value, params));
872
-
873
- const bag = inst._zod.bag;
874
- inst.minValue = bag.minimum ?? null;
875
- inst.maxValue = bag.maximum ?? null;
876
- inst.format = bag.format ?? null;
877
- });
878
-
879
- export function bigint(params?: string | core.$ZodBigIntParams): ZodBigInt {
880
- return core._bigint(ZodBigInt, params) as any;
881
- }
882
- // bigint formats
883
-
884
- // ZodBigIntFormat
885
- export interface ZodBigIntFormat extends ZodBigInt {
886
- _zod: core.$ZodBigIntFormatInternals;
887
- }
888
- export const ZodBigIntFormat: core.$constructor<ZodBigIntFormat> = /*@__PURE__*/ core.$constructor(
889
- "ZodBigIntFormat",
890
- (inst, def) => {
891
- core.$ZodBigIntFormat.init(inst, def);
892
- ZodBigInt.init(inst, def);
893
- }
894
- );
895
-
896
- // int64
897
- export function int64(params?: string | core.$ZodBigIntFormatParams): ZodBigIntFormat {
898
- return core._int64(ZodBigIntFormat, params);
899
- }
900
-
901
- // uint64
902
- export function uint64(params?: string | core.$ZodBigIntFormatParams): ZodBigIntFormat {
903
- return core._uint64(ZodBigIntFormat, params);
904
- }
905
-
906
- // symbol
907
- export interface ZodSymbol extends ZodType {
908
- _zod: core.$ZodSymbolInternals;
909
- }
910
- export const ZodSymbol: core.$constructor<ZodSymbol> = /*@__PURE__*/ core.$constructor("ZodSymbol", (inst, def) => {
911
- core.$ZodSymbol.init(inst, def);
912
- ZodType.init(inst, def);
913
- });
914
-
915
- export function symbol(params?: string | core.$ZodSymbolParams): ZodSymbol {
916
- return core._symbol(ZodSymbol, params);
917
- }
918
-
919
- // ZodUndefined
920
- export interface ZodUndefined extends ZodType {
921
- _zod: core.$ZodUndefinedInternals;
922
- }
923
- export const ZodUndefined: core.$constructor<ZodUndefined> = /*@__PURE__*/ core.$constructor(
924
- "ZodUndefined",
925
- (inst, def) => {
926
- core.$ZodUndefined.init(inst, def);
927
- ZodType.init(inst, def);
928
- }
929
- );
930
-
931
- function _undefined(params?: string | core.$ZodUndefinedParams): ZodUndefined {
932
- return core._undefined(ZodUndefined, params);
933
- }
934
- export { _undefined as undefined };
935
-
936
- // ZodNull
937
- export interface ZodNull extends ZodType {
938
- _zod: core.$ZodNullInternals;
939
- }
940
- export const ZodNull: core.$constructor<ZodNull> = /*@__PURE__*/ core.$constructor("ZodNull", (inst, def) => {
941
- core.$ZodNull.init(inst, def);
942
- ZodType.init(inst, def);
943
- });
944
-
945
- function _null(params?: string | core.$ZodNullParams): ZodNull {
946
- return core._null(ZodNull, params);
947
- }
948
- export { _null as null };
949
-
950
- // ZodAny
951
- export interface ZodAny extends ZodType {
952
- _zod: core.$ZodAnyInternals;
953
- }
954
- export const ZodAny: core.$constructor<ZodAny> = /*@__PURE__*/ core.$constructor("ZodAny", (inst, def) => {
955
- core.$ZodAny.init(inst, def);
956
- ZodType.init(inst, def);
957
- });
958
-
959
- export function any(): ZodAny {
960
- return core._any(ZodAny);
961
- }
962
-
963
- // ZodUnknown
964
- export interface ZodUnknown extends ZodType {
965
- _zod: core.$ZodUnknownInternals;
966
- }
967
- export const ZodUnknown: core.$constructor<ZodUnknown> = /*@__PURE__*/ core.$constructor("ZodUnknown", (inst, def) => {
968
- core.$ZodUnknown.init(inst, def);
969
- ZodType.init(inst, def);
970
- });
971
-
972
- export function unknown(): ZodUnknown {
973
- return core._unknown(ZodUnknown);
974
- }
975
-
976
- // ZodNever
977
- export interface ZodNever extends ZodType {
978
- _zod: core.$ZodNeverInternals;
979
- }
980
- export const ZodNever: core.$constructor<ZodNever> = /*@__PURE__*/ core.$constructor("ZodNever", (inst, def) => {
981
- core.$ZodNever.init(inst, def);
982
- ZodType.init(inst, def);
983
- });
984
-
985
- export function never(params?: string | core.$ZodNeverParams): ZodNever {
986
- return core._never(ZodNever, params);
987
- }
988
-
989
- // ZodVoid
990
- export interface ZodVoid extends ZodType {
991
- _zod: core.$ZodVoidInternals;
992
- }
993
- export const ZodVoid: core.$constructor<ZodVoid> = /*@__PURE__*/ core.$constructor("ZodVoid", (inst, def) => {
994
- core.$ZodVoid.init(inst, def);
995
- ZodType.init(inst, def);
996
- });
997
-
998
- function _void(params?: string | core.$ZodVoidParams): ZodVoid {
999
- return core._void(ZodVoid, params);
1000
- }
1001
- export { _void as void };
1002
-
1003
- // ZodDate
1004
- export interface _ZodDate<T = unknown> extends ZodType {
1005
- _zod: core.$ZodDateInternals<T>;
1006
-
1007
- min(value: number | Date, params?: string | core.$ZodCheckGreaterThanParams): this;
1008
- max(value: number | Date, params?: string | core.$ZodCheckLessThanParams): this;
1009
-
1010
- /** @deprecated Not recommended. */
1011
- minDate: Date | null;
1012
- /** @deprecated Not recommended. */
1013
- maxDate: Date | null;
1014
- }
1015
-
1016
- export interface ZodDate extends _ZodDate<Date> {}
1017
- export const ZodDate: core.$constructor<ZodDate> = /*@__PURE__*/ core.$constructor("ZodDate", (inst, def) => {
1018
- core.$ZodDate.init(inst, def);
1019
- ZodType.init(inst, def);
1020
-
1021
- inst.min = (value, params) => inst.check(checks.gte(value, params));
1022
- inst.max = (value, params) => inst.check(checks.lte(value, params));
1023
-
1024
- const c = inst._zod.bag;
1025
- inst.minDate = c.minimum ? new Date(c.minimum) : null;
1026
- inst.maxDate = c.maximum ? new Date(c.maximum) : null;
1027
- });
1028
-
1029
- export function date(params?: string | core.$ZodDateParams): ZodDate {
1030
- return core._date(ZodDate, params);
1031
- }
1032
-
1033
- // ZodArray
1034
- export interface ZodArray<T extends core.$ZodType = core.$ZodType> extends ZodType {
1035
- _zod: core.$ZodArrayInternals<T>;
1036
-
1037
- element: T;
1038
- min(minLength: number, params?: string | core.$ZodCheckMinLengthParams): this;
1039
- nonempty(params?: string | core.$ZodCheckMinLengthParams): this;
1040
- max(maxLength: number, params?: string | core.$ZodCheckMaxLengthParams): this;
1041
- length(len: number, params?: string | core.$ZodCheckLengthEqualsParams): this;
1042
- }
1043
- export const ZodArray: core.$constructor<ZodArray> = /*@__PURE__*/ core.$constructor("ZodArray", (inst, def) => {
1044
- core.$ZodArray.init(inst, def);
1045
- ZodType.init(inst, def);
1046
-
1047
- inst.element = def.element as any;
1048
- inst.min = (minLength, params) => inst.check(checks.minLength(minLength, params));
1049
- inst.nonempty = (params) => inst.check(checks.minLength(1, params));
1050
- inst.max = (maxLength, params) => inst.check(checks.maxLength(maxLength, params));
1051
- inst.length = (len, params) => inst.check(checks.length(len, params));
1052
- });
1053
-
1054
- export function array<T extends core.$ZodType>(element: T, params?: string | core.$ZodArrayParams): ZodArray<T> {
1055
- return core._array(ZodArray, element, params) as any;
1056
- }
1057
-
1058
- // .keyof
1059
- export function keyof<T extends ZodObject>(schema: T): ZodLiteral<keyof T["_zod"]["output"]> {
1060
- const shape = schema._zod.def.shape;
1061
- return literal(Object.keys(shape)) as any;
1062
- }
1063
-
1064
- // ZodObject
1065
-
1066
- export interface ZodObject<
1067
- /** @ts-ignore Cast variance */
1068
- out Shape extends core.$ZodShape = core.$ZodLooseShape,
1069
- out Config extends core.$ZodObjectConfig = core.$ZodObjectConfig,
1070
- > extends ZodType {
1071
- _zod: core.$ZodObjectInternals<Shape, Config>;
1072
- shape: Shape;
1073
-
1074
- keyof(): ZodEnum<util.ToEnum<keyof Shape & string>>;
1075
- /** Define a schema to validate all unrecognized keys. This overrides the existing strict/loose behavior. */
1076
- catchall<T extends core.$ZodType>(schema: T): ZodObject<Shape, core.$catchall<T>>;
1077
-
1078
- /** @deprecated Use `z.looseObject()` or `.loose()` instead. */
1079
- passthrough(): ZodObject<Shape, core.$loose>;
1080
- /** Consider `z.looseObject(A.shape)` instead */
1081
- loose(): ZodObject<Shape, core.$loose>;
1082
-
1083
- /** Consider `z.strictObject(A.shape)` instead */
1084
- strict(): ZodObject<Shape, core.$strict>;
1085
-
1086
- /** This is the default behavior. This method call is likely unnecessary. */
1087
- strip(): ZodObject<Shape, core.$strict>;
1088
-
1089
- extend<U extends core.$ZodLooseShape & Partial<Record<keyof Shape, core.$ZodType>>>(
1090
- shape: U
1091
- ): ZodObject<util.Extend<Shape, U>, Config>;
1092
-
1093
- /**
1094
- * @deprecated Use destructuring to merge the shapes:
1095
- *
1096
- * ```ts
1097
- * z.object({
1098
- * ...A.shape,
1099
- * ...B.shape
1100
- * });
1101
- * ```
1102
- */
1103
- merge<U extends ZodObject>(other: U): ZodObject<util.Extend<Shape, U["shape"]>, U["_zod"]["config"]>;
1104
-
1105
- pick<M extends util.Exactly<util.Mask<keyof Shape>, M>>(
1106
- mask: M
1107
- ): ZodObject<util.Flatten<Pick<Shape, Extract<keyof Shape, keyof M>>>, Config>;
1108
-
1109
- omit<M extends util.Exactly<util.Mask<keyof Shape>, M>>(
1110
- mask: M
1111
- ): ZodObject<util.Flatten<Omit<Shape, Extract<keyof Shape, keyof M>>>, Config>;
1112
-
1113
- partial(): ZodObject<
1114
- {
1115
- [k in keyof Shape]: ZodOptional<Shape[k]>;
1116
- },
1117
- Config
1118
- >;
1119
- partial<M extends util.Exactly<util.Mask<keyof Shape>, M>>(
1120
- mask: M
1121
- ): ZodObject<
1122
- {
1123
- [k in keyof Shape]: k extends keyof M ? ZodOptional<Shape[k]> : Shape[k];
1124
- },
1125
- Config
1126
- >;
1127
-
1128
- // required
1129
- required(): ZodObject<
1130
- {
1131
- [k in keyof Shape]: ZodNonOptional<Shape[k]>;
1132
- },
1133
- Config
1134
- >;
1135
- required<M extends util.Exactly<util.Mask<keyof Shape>, M>>(
1136
- mask: M
1137
- ): ZodObject<
1138
- {
1139
- [k in keyof Shape]: k extends keyof M ? ZodNonOptional<Shape[k]> : Shape[k];
1140
- },
1141
- Config
1142
- >;
1143
- }
1144
-
1145
- export const ZodObject: core.$constructor<ZodObject> = /*@__PURE__*/ core.$constructor("ZodObject", (inst, def) => {
1146
- core.$ZodObject.init(inst, def);
1147
- ZodType.init(inst, def);
1148
-
1149
- util.defineLazy(inst, "shape", () => {
1150
- return Object.fromEntries(Object.entries(inst._zod.def.shape));
1151
- });
1152
- inst.keyof = () => _enum(Object.keys(inst._zod.def.shape)) as any;
1153
- inst.catchall = (catchall) => inst.clone({ ...inst._zod.def, catchall });
1154
- inst.passthrough = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
1155
- // inst.nonstrict = () => inst.clone({ ...inst._zod.def, catchall: api.unknown() });
1156
- inst.loose = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
1157
- inst.strict = () => inst.clone({ ...inst._zod.def, catchall: never() });
1158
- inst.strip = () => inst.clone({ ...inst._zod.def, catchall: undefined });
1159
-
1160
- inst.extend = (incoming: any) => {
1161
- return util.extend(inst, incoming);
1162
- };
1163
- inst.merge = (other) => util.merge(inst, other);
1164
- inst.pick = (mask) => util.pick(inst, mask);
1165
- inst.omit = (mask) => util.omit(inst, mask);
1166
- inst.partial = (...args: any[]) => util.partial(ZodOptional, inst, args[0] as object);
1167
- inst.required = (...args: any[]) => util.required(ZodNonOptional, inst, args[0] as object);
1168
- });
1169
-
1170
- export function object<T extends core.$ZodLooseShape = Partial<Record<never, core.$ZodType>>>(
1171
- shape?: T,
1172
- params?: string | core.$ZodObjectParams
1173
- ): ZodObject<util.Writeable<T> & {}, core.$strip> {
1174
- const def: core.$ZodObjectDef = {
1175
- type: "object",
1176
-
1177
- get shape() {
1178
- util.assignProp(this, "shape", { ...shape });
1179
- return this.shape;
1180
- },
1181
-
1182
- ...util.normalizeParams(params),
1183
- };
1184
- return new ZodObject(def) as any;
1185
- }
1186
-
1187
- // strictObject
1188
-
1189
- export function strictObject<T extends core.$ZodLooseShape>(
1190
- shape: T,
1191
- params?: string | core.$ZodObjectParams
1192
- ): ZodObject<T, core.$strict> {
1193
- return new ZodObject({
1194
- type: "object",
1195
-
1196
- get shape() {
1197
- util.assignProp(this, "shape", { ...shape });
1198
- return this.shape;
1199
- },
1200
-
1201
- catchall: never(),
1202
- ...util.normalizeParams(params),
1203
- }) as any;
1204
- }
1205
-
1206
- // looseObject
1207
-
1208
- export function looseObject<T extends core.$ZodLooseShape>(
1209
- shape: T,
1210
- params?: string | core.$ZodObjectParams
1211
- ): ZodObject<T, core.$loose> {
1212
- return new ZodObject({
1213
- type: "object",
1214
-
1215
- get shape() {
1216
- util.assignProp(this, "shape", { ...shape });
1217
- return this.shape;
1218
- },
1219
-
1220
- catchall: unknown(),
1221
- ...util.normalizeParams(params),
1222
- }) as any;
1223
- }
1224
-
1225
- // ZodUnion
1226
- export interface ZodUnion<T extends readonly core.$ZodType[] = readonly core.$ZodType[]> extends ZodType {
1227
- _zod: core.$ZodUnionInternals<T>;
1228
- options: T;
1229
- }
1230
- export const ZodUnion: core.$constructor<ZodUnion> = /*@__PURE__*/ core.$constructor("ZodUnion", (inst, def) => {
1231
- core.$ZodUnion.init(inst, def);
1232
- ZodType.init(inst, def);
1233
- inst.options = def.options;
1234
- });
1235
-
1236
- export function union<const T extends readonly core.$ZodType[]>(
1237
- options: T,
1238
- params?: string | core.$ZodUnionParams
1239
- ): ZodUnion<T> {
1240
- return new ZodUnion({
1241
- type: "union",
1242
- options,
1243
- ...util.normalizeParams(params),
1244
- }) as ZodUnion<T>;
1245
- }
1246
-
1247
- // ZodDiscriminatedUnion
1248
- export interface ZodDiscriminatedUnion<Options extends readonly core.$ZodType[] = readonly core.$ZodType[]>
1249
- extends ZodUnion<Options> {
1250
- _zod: core.$ZodDiscriminatedUnionInternals<Options>;
1251
- }
1252
- export const ZodDiscriminatedUnion: core.$constructor<ZodDiscriminatedUnion> = /*@__PURE__*/ core.$constructor(
1253
- "ZodDiscriminatedUnion",
1254
- (inst, def) => {
1255
- ZodUnion.init(inst, def);
1256
- core.$ZodDiscriminatedUnion.init(inst, def);
1257
- }
1258
- );
1259
-
1260
- export interface $ZodTypeDiscriminableInternals extends core.$ZodTypeInternals {
1261
- disc: util.DiscriminatorMap;
1262
- }
1263
-
1264
- export interface $ZodTypeDiscriminable extends ZodType {
1265
- _zod: $ZodTypeDiscriminableInternals;
1266
- }
1267
-
1268
- export function discriminatedUnion<Types extends readonly [$ZodTypeDiscriminable, ...$ZodTypeDiscriminable[]]>(
1269
- discriminator: string,
1270
- options: Types,
1271
- params?: string | core.$ZodDiscriminatedUnionParams
1272
- ): ZodDiscriminatedUnion<Types> {
1273
- // const [options, params] = args;
1274
- return new ZodDiscriminatedUnion({
1275
- type: "union",
1276
- options,
1277
- discriminator,
1278
- ...util.normalizeParams(params),
1279
- }) as any;
1280
- }
1281
-
1282
- // ZodIntersection
1283
- export interface ZodIntersection<A extends core.$ZodType = core.$ZodType, B extends core.$ZodType = core.$ZodType>
1284
- extends ZodType {
1285
- _zod: core.$ZodIntersectionInternals<A, B>;
1286
- }
1287
- export const ZodIntersection: core.$constructor<ZodIntersection> = /*@__PURE__*/ core.$constructor(
1288
- "ZodIntersection",
1289
- (inst, def) => {
1290
- core.$ZodIntersection.init(inst, def);
1291
- ZodType.init(inst, def);
1292
- }
1293
- );
1294
-
1295
- export function intersection<T extends core.$ZodType, U extends core.$ZodType>(
1296
- left: T,
1297
- right: U
1298
- ): ZodIntersection<T, U> {
1299
- return new ZodIntersection({
1300
- type: "intersection",
1301
- left,
1302
- right,
1303
- }) as ZodIntersection<T, U>;
1304
- }
1305
-
1306
- // ZodTuple
1307
- export interface ZodTuple<
1308
- T extends util.TupleItems = util.TupleItems,
1309
- Rest extends core.$ZodType | null = core.$ZodType | null,
1310
- > extends ZodType {
1311
- _zod: core.$ZodTupleInternals<T, Rest>;
1312
- rest<Rest extends core.$ZodType>(rest: Rest): ZodTuple<T, Rest>;
1313
- }
1314
- export const ZodTuple: core.$constructor<ZodTuple> = /*@__PURE__*/ core.$constructor("ZodTuple", (inst, def) => {
1315
- core.$ZodTuple.init(inst, def);
1316
- ZodType.init(inst, def);
1317
- inst.rest = (rest) =>
1318
- inst.clone({
1319
- ...inst._zod.def,
1320
- rest,
1321
- }) as any;
1322
- });
1323
-
1324
- export function tuple<T extends readonly [core.$ZodType, ...core.$ZodType[]]>(
1325
- items: T,
1326
- params?: string | core.$ZodTupleParams
1327
- ): ZodTuple<T, null>;
1328
- export function tuple<T extends readonly [core.$ZodType, ...core.$ZodType[]], Rest extends core.$ZodType>(
1329
- items: T,
1330
- rest: Rest,
1331
- params?: string | core.$ZodTupleParams
1332
- ): ZodTuple<T, Rest>;
1333
- export function tuple(items: [], params?: string | core.$ZodTupleParams): ZodTuple<[], null>;
1334
- export function tuple(
1335
- items: core.$ZodType[],
1336
- _paramsOrRest?: string | core.$ZodTupleParams | core.$ZodType,
1337
- _params?: string | core.$ZodTupleParams
1338
- ) {
1339
- const hasRest = _paramsOrRest instanceof core.$ZodType;
1340
- const params = hasRest ? _params : _paramsOrRest;
1341
- const rest = hasRest ? _paramsOrRest : null;
1342
- return new ZodTuple({
1343
- type: "tuple",
1344
- items,
1345
- rest,
1346
- ...util.normalizeParams(params),
1347
- });
1348
- }
1349
-
1350
- // ZodRecord
1351
- export interface ZodRecord<
1352
- Key extends core.$ZodRecordKey = core.$ZodRecordKey,
1353
- Value extends core.$ZodType = core.$ZodType,
1354
- > extends ZodType {
1355
- _zod: core.$ZodRecordInternals<Key, Value>;
1356
- keyType: Key;
1357
- valueType: Value;
1358
- }
1359
- export const ZodRecord: core.$constructor<ZodRecord> = /*@__PURE__*/ core.$constructor("ZodRecord", (inst, def) => {
1360
- core.$ZodRecord.init(inst, def);
1361
- ZodType.init(inst, def);
1362
-
1363
- inst.keyType = def.keyType;
1364
- inst.valueType = def.valueType;
1365
- });
1366
-
1367
- export function record<Key extends core.$ZodRecordKey, Value extends core.$ZodType>(
1368
- keyType: Key,
1369
- valueType: Value,
1370
- params?: string | core.$ZodRecordParams
1371
- ): ZodRecord<Key, Value> {
1372
- return new ZodRecord({
1373
- type: "record",
1374
- keyType,
1375
- valueType,
1376
- ...util.normalizeParams(params),
1377
- }) as ZodRecord<Key, Value>;
1378
- }
1379
-
1380
- export function partialRecord<Key extends core.$ZodRecordKey, Value extends core.$ZodType>(
1381
- keyType: Key,
1382
- valueType: Value,
1383
- params?: string | core.$ZodRecordParams
1384
- ): ZodRecord<ZodUnion<[Key, ZodNever]>, Value> {
1385
- return new ZodRecord({
1386
- type: "record",
1387
- keyType: union([keyType, never()]),
1388
- valueType,
1389
- ...util.normalizeParams(params),
1390
- }) as ZodRecord<ZodUnion<[Key, ZodNever]>, Value>;
1391
- }
1392
-
1393
- // ZodMap
1394
- export interface ZodMap<Key extends core.$ZodType = core.$ZodType, Value extends core.$ZodType = core.$ZodType>
1395
- extends ZodType {
1396
- _zod: core.$ZodMapInternals<Key, Value>;
1397
-
1398
- keyType: Key;
1399
- valueType: Value;
1400
- }
1401
- export const ZodMap: core.$constructor<ZodMap> = /*@__PURE__*/ core.$constructor("ZodMap", (inst, def) => {
1402
- core.$ZodMap.init(inst, def);
1403
- ZodType.init(inst, def);
1404
- inst.keyType = def.keyType;
1405
- inst.valueType = def.valueType;
1406
- });
1407
-
1408
- export function map<Key extends core.$ZodType, Value extends core.$ZodType>(
1409
- keyType: Key,
1410
- valueType: Value,
1411
- params?: string | core.$ZodMapParams
1412
- ): ZodMap<Key, Value> {
1413
- return new ZodMap({
1414
- type: "map",
1415
- keyType,
1416
- valueType,
1417
- ...util.normalizeParams(params),
1418
- }) as ZodMap<Key, Value>;
1419
- }
1420
-
1421
- // ZodSet
1422
- export interface ZodSet<T extends core.$ZodType = core.$ZodType> extends ZodType {
1423
- _zod: core.$ZodSetInternals<T>;
1424
- min(minSize: number, params?: string | core.$ZodCheckMinSizeParams): this;
1425
- /** */
1426
- nonempty(params?: string | core.$ZodCheckMinSizeParams): this;
1427
- max(maxSize: number, params?: string | core.$ZodCheckMaxSizeParams): this;
1428
- size(size: number, params?: string | core.$ZodCheckSizeEqualsParams): this;
1429
- }
1430
- export const ZodSet: core.$constructor<ZodSet> = /*@__PURE__*/ core.$constructor("ZodSet", (inst, def) => {
1431
- core.$ZodSet.init(inst, def);
1432
- ZodType.init(inst, def);
1433
-
1434
- inst.min = (...args) => inst.check(core._minSize(...args));
1435
- inst.nonempty = (params) => inst.check(core._minSize(1, params));
1436
- inst.max = (...args) => inst.check(core._maxSize(...args));
1437
- inst.size = (...args) => inst.check(core._size(...args));
1438
- });
1439
-
1440
- export function set<Value extends core.$ZodType>(
1441
- valueType: Value,
1442
- params?: string | core.$ZodSetParams
1443
- ): ZodSet<Value> {
1444
- return new ZodSet({
1445
- type: "set",
1446
- valueType,
1447
- ...util.normalizeParams(params),
1448
- }) as ZodSet<Value>;
1449
- }
1450
-
1451
- // ZodEnum
1452
- // @ts
1453
- export interface ZodEnum<T extends util.EnumLike = util.EnumLike> extends ZodType {
1454
- _zod: core.$ZodEnumInternals<T>;
1455
-
1456
- enum: T;
1457
- options: Array<T[keyof T]>;
1458
-
1459
- extract<const U extends readonly (keyof T)[]>(
1460
- values: U,
1461
- params?: string | core.$ZodEnumParams
1462
- ): ZodEnum<util.Flatten<Pick<T, U[number]>>>;
1463
- exclude<const U extends readonly (keyof T)[]>(
1464
- values: U,
1465
- params?: string | core.$ZodEnumParams
1466
- ): ZodEnum<util.Flatten<Omit<T, U[number]>>>;
1467
- }
1468
- export const ZodEnum: core.$constructor<ZodEnum> = /*@__PURE__*/ core.$constructor("ZodEnum", (inst, def) => {
1469
- core.$ZodEnum.init(inst, def);
1470
- ZodType.init(inst, def);
1471
-
1472
- inst.enum = def.entries;
1473
- inst.options = Object.values(def.entries);
1474
-
1475
- const keys = new Set(Object.keys(def.entries));
1476
-
1477
- inst.extract = (values, params) => {
1478
- const newEntries: Record<string, any> = {};
1479
- for (const value of values) {
1480
- if (keys.has(value)) {
1481
- newEntries[value] = def.entries[value];
1482
- } else throw new Error(`Key ${value} not found in enum`);
1483
- }
1484
- return new ZodEnum({
1485
- ...def,
1486
- checks: [],
1487
- ...util.normalizeParams(params),
1488
- entries: newEntries,
1489
- }) as any;
1490
- };
1491
-
1492
- inst.exclude = (values, params) => {
1493
- const newEntries: Record<string, any> = { ...def.entries };
1494
- for (const value of values) {
1495
- if (keys.has(value)) {
1496
- delete newEntries[value];
1497
- } else throw new Error(`Key ${value} not found in enum`);
1498
- }
1499
- return new ZodEnum({
1500
- ...def,
1501
- checks: [],
1502
- ...util.normalizeParams(params),
1503
- entries: newEntries,
1504
- }) as any;
1505
- };
1506
- });
1507
-
1508
- function _enum<const T extends readonly string[]>(
1509
- values: T,
1510
- params?: string | core.$ZodEnumParams
1511
- ): ZodEnum<util.ToEnum<T[number]>>;
1512
- function _enum<const T extends util.EnumLike>(entries: T, params?: string | core.$ZodEnumParams): ZodEnum<T>;
1513
- function _enum(values: any, params?: string | core.$ZodEnumParams) {
1514
- const entries: any = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
1515
-
1516
- return new ZodEnum({
1517
- type: "enum",
1518
- entries,
1519
- ...util.normalizeParams(params),
1520
- }) as any;
1521
- }
1522
- export { _enum as enum };
1523
-
1524
- /** @deprecated This API has been merged into `z.enum()`. Use `z.enum()` instead.
1525
- *
1526
- * ```ts
1527
- * enum Colors { red, green, blue }
1528
- * z.enum(Colors);
1529
- * ```
1530
- */
1531
- export function nativeEnum<T extends util.EnumLike>(entries: T, params?: string | core.$ZodEnumParams): ZodEnum<T> {
1532
- return new ZodEnum({
1533
- type: "enum",
1534
- entries,
1535
- ...util.normalizeParams(params),
1536
- }) as any as ZodEnum<T>;
1537
- }
1538
-
1539
- // ZodLiteral
1540
- export interface ZodLiteral<T extends util.Primitive = util.Primitive> extends ZodType {
1541
- _zod: core.$ZodLiteralInternals<T>;
1542
- values: Set<T>;
1543
- }
1544
- export const ZodLiteral: core.$constructor<ZodLiteral> = /*@__PURE__*/ core.$constructor("ZodLiteral", (inst, def) => {
1545
- core.$ZodLiteral.init(inst, def);
1546
- ZodType.init(inst, def);
1547
- inst.values = new Set(def.values);
1548
- });
1549
-
1550
- export function literal<const T extends Array<util.Literal>>(
1551
- value: T,
1552
- params?: string | core.$ZodLiteralParams
1553
- ): ZodLiteral<T[number]>;
1554
- export function literal<const T extends util.Literal>(
1555
- value: T,
1556
- params?: string | core.$ZodLiteralParams
1557
- ): ZodLiteral<T>;
1558
- export function literal(value: any, params: any) {
1559
- return new ZodLiteral({
1560
- type: "literal",
1561
- values: Array.isArray(value) ? value : [value],
1562
- ...util.normalizeParams(params),
1563
- });
1564
- }
1565
-
1566
- // ZodFile
1567
- export interface ZodFile extends ZodType {
1568
- _zod: core.$ZodFileInternals;
1569
-
1570
- min(size: number, params?: string | core.$ZodCheckMinSizeParams): this;
1571
- max(size: number, params?: string | core.$ZodCheckMaxSizeParams): this;
1572
- mime(types: Array<util.MimeTypes>, params?: string | core.$ZodCheckMimeTypeParams): this;
1573
- }
1574
- export const ZodFile: core.$constructor<ZodFile> = /*@__PURE__*/ core.$constructor("ZodFile", (inst, def) => {
1575
- core.$ZodFile.init(inst, def);
1576
- ZodType.init(inst, def);
1577
-
1578
- inst.min = (size, params) => inst.check(core._minSize(size, params));
1579
- inst.max = (size, params) => inst.check(core._maxSize(size, params));
1580
- inst.mime = (types, params) => inst.check(core._mime(types, params));
1581
- });
1582
-
1583
- export function file(params?: string | core.$ZodFileParams): ZodFile {
1584
- return core._file(ZodFile, params) as any;
1585
- }
1586
-
1587
- // ZodTransform
1588
- export interface ZodTransform<O = unknown, I = unknown> extends ZodType {
1589
- _zod: core.$ZodTransformInternals<O, I>;
1590
- }
1591
- export const ZodTransform: core.$constructor<ZodTransform> = /*@__PURE__*/ core.$constructor(
1592
- "ZodTransform",
1593
- (inst, def) => {
1594
- core.$ZodTransform.init(inst, def);
1595
- ZodType.init(inst, def);
1596
-
1597
- inst._zod.parse = (payload, _ctx) => {
1598
- (payload as RefinementCtx).addIssue = (issue) => {
1599
- if (typeof issue === "string") {
1600
- payload.issues.push(util.issue(issue, payload.value, def));
1601
- } else {
1602
- // for Zod 3 backwards compatibility
1603
- const _issue = issue as any;
1604
-
1605
- if (_issue.fatal) _issue.continue = false;
1606
- _issue.code ??= "custom";
1607
- _issue.input ??= payload.value;
1608
- _issue.inst ??= inst;
1609
- _issue.continue ??= true;
1610
- payload.issues.push(util.issue(_issue));
1611
- }
1612
- };
1613
-
1614
- const output = def.transform(payload.value, payload);
1615
- if (output instanceof Promise) {
1616
- return output.then((output) => {
1617
- payload.value = output;
1618
- return payload;
1619
- });
1620
- }
1621
- payload.value = output;
1622
- return payload;
1623
- };
1624
- }
1625
- );
1626
-
1627
- export function transform<I = unknown, O = I>(
1628
- fn: (input: I, ctx: core.ParsePayload) => O
1629
- ): ZodTransform<Awaited<O>, I> {
1630
- return new ZodTransform({
1631
- type: "transform",
1632
- transform: fn as any,
1633
- }) as any;
1634
- }
1635
-
1636
- // ZodOptional
1637
- export interface ZodOptional<T extends core.$ZodType = core.$ZodType> extends ZodType {
1638
- _zod: core.$ZodOptionalInternals<T>;
1639
-
1640
- unwrap(): T;
1641
- }
1642
- export const ZodOptional: core.$constructor<ZodOptional> = /*@__PURE__*/ core.$constructor(
1643
- "ZodOptional",
1644
- (inst, def) => {
1645
- core.$ZodOptional.init(inst, def);
1646
- ZodType.init(inst, def);
1647
-
1648
- inst.unwrap = () => inst._zod.def.innerType;
1649
- }
1650
- );
1651
-
1652
- export function optional<T extends core.$ZodType>(innerType: T): ZodOptional<T> {
1653
- return new ZodOptional({
1654
- type: "optional",
1655
- innerType,
1656
- }) as ZodOptional<T>;
1657
- }
1658
-
1659
- // ZodNullable
1660
- export interface ZodNullable<T extends core.$ZodType = core.$ZodType> extends ZodType {
1661
- _zod: core.$ZodNullableInternals<T>;
1662
-
1663
- unwrap(): T;
1664
- }
1665
- export const ZodNullable: core.$constructor<ZodNullable> = /*@__PURE__*/ core.$constructor(
1666
- "ZodNullable",
1667
- (inst, def) => {
1668
- core.$ZodNullable.init(inst, def);
1669
- ZodType.init(inst, def);
1670
-
1671
- inst.unwrap = () => inst._zod.def.innerType;
1672
- }
1673
- );
1674
-
1675
- export function nullable<T extends core.$ZodType>(innerType: T): ZodNullable<T> {
1676
- return new ZodNullable({
1677
- type: "nullable",
1678
- innerType,
1679
- }) as ZodNullable<T>;
1680
- }
1681
-
1682
- // nullish
1683
- export function nullish<T extends core.$ZodType>(innerType: T): ZodOptional<ZodNullable<T>> {
1684
- return optional(nullable(innerType));
1685
- }
1686
-
1687
- // ZodDefault
1688
- export interface ZodDefault<T extends core.$ZodType = core.$ZodType> extends ZodType {
1689
- _zod: core.$ZodDefaultInternals<T>;
1690
-
1691
- unwrap(): T;
1692
- /** @deprecated Use `.unwrap()` instead. */
1693
- removeDefault(): T;
1694
- }
1695
- export const ZodDefault: core.$constructor<ZodDefault> = /*@__PURE__*/ core.$constructor("ZodDefault", (inst, def) => {
1696
- core.$ZodDefault.init(inst, def);
1697
- ZodType.init(inst, def);
1698
-
1699
- inst.unwrap = () => inst._zod.def.innerType;
1700
- inst.removeDefault = inst.unwrap;
1701
- });
1702
-
1703
- export function _default<T extends core.$ZodType>(
1704
- innerType: T,
1705
- defaultValue: util.NoUndefined<core.output<T>> | (() => util.NoUndefined<core.output<T>>)
1706
- ): ZodDefault<T> {
1707
- return new ZodDefault({
1708
- type: "default",
1709
- innerType,
1710
- get defaultValue() {
1711
- return typeof defaultValue === "function" ? (defaultValue as Function)() : defaultValue;
1712
- },
1713
- }) as any as ZodDefault<T>;
1714
- }
1715
-
1716
- // ZodPrefault
1717
- export interface ZodPrefault<T extends core.$ZodType = core.$ZodType> extends ZodType {
1718
- _zod: core.$ZodPrefaultInternals<T>;
1719
- unwrap(): T;
1720
- }
1721
- export const ZodPrefault: core.$constructor<ZodPrefault> = /*@__PURE__*/ core.$constructor(
1722
- "ZodPrefault",
1723
- (inst, def) => {
1724
- core.$ZodPrefault.init(inst, def);
1725
- ZodType.init(inst, def);
1726
- inst.unwrap = () => inst._zod.def.innerType;
1727
- }
1728
- );
1729
-
1730
- export function prefault<T extends core.$ZodType>(
1731
- innerType: T,
1732
- defaultValue: core.input<T> | (() => core.input<T>)
1733
- ): ZodPrefault<T> {
1734
- return new ZodPrefault({
1735
- type: "prefault",
1736
- innerType,
1737
- get defaultValue() {
1738
- return typeof defaultValue === "function" ? (defaultValue as Function)() : defaultValue;
1739
- },
1740
- }) as ZodPrefault<T>;
1741
- }
1742
-
1743
- // ZodNonOptional
1744
- export interface ZodNonOptional<T extends core.$ZodType = core.$ZodType> extends ZodType {
1745
- _zod: core.$ZodNonOptionalInternals<T>;
1746
-
1747
- unwrap(): T;
1748
- }
1749
- export const ZodNonOptional: core.$constructor<ZodNonOptional> = /*@__PURE__*/ core.$constructor(
1750
- "ZodNonOptional",
1751
- (inst, def) => {
1752
- core.$ZodNonOptional.init(inst, def);
1753
- ZodType.init(inst, def);
1754
-
1755
- inst.unwrap = () => inst._zod.def.innerType;
1756
- }
1757
- );
1758
-
1759
- export function nonoptional<T extends core.$ZodType>(
1760
- innerType: T,
1761
- params?: string | core.$ZodNonOptionalParams
1762
- ): ZodNonOptional<T> {
1763
- return new ZodNonOptional({
1764
- type: "nonoptional",
1765
- innerType,
1766
- ...util.normalizeParams(params),
1767
- }) as ZodNonOptional<T>;
1768
- }
1769
-
1770
- // ZodSuccess
1771
- export interface ZodSuccess<T extends core.$ZodType = core.$ZodType> extends ZodType {
1772
- _zod: core.$ZodSuccessInternals<T>;
1773
-
1774
- unwrap(): T;
1775
- }
1776
- export const ZodSuccess: core.$constructor<ZodSuccess> = /*@__PURE__*/ core.$constructor("ZodSuccess", (inst, def) => {
1777
- core.$ZodSuccess.init(inst, def);
1778
- ZodType.init(inst, def);
1779
-
1780
- inst.unwrap = () => inst._zod.def.innerType;
1781
- });
1782
-
1783
- export function success<T extends core.$ZodType>(innerType: T): ZodSuccess<T> {
1784
- return new ZodSuccess({
1785
- type: "success",
1786
- innerType,
1787
- }) as ZodSuccess<T>;
1788
- }
1789
-
1790
- // ZodCatch
1791
- export interface ZodCatch<T extends core.$ZodType = core.$ZodType> extends ZodType {
1792
- _zod: core.$ZodCatchInternals<T>;
1793
-
1794
- unwrap(): T;
1795
- /** @deprecated Use `.unwrap()` instead. */
1796
- removeCatch(): T;
1797
- }
1798
- export const ZodCatch: core.$constructor<ZodCatch> = /*@__PURE__*/ core.$constructor("ZodCatch", (inst, def) => {
1799
- core.$ZodCatch.init(inst, def);
1800
- ZodType.init(inst, def);
1801
-
1802
- inst.unwrap = () => inst._zod.def.innerType;
1803
- inst.removeCatch = inst.unwrap;
1804
- });
1805
-
1806
- function _catch<T extends core.$ZodType>(
1807
- innerType: T,
1808
- catchValue: core.output<T> | ((ctx: core.$ZodCatchCtx) => core.output<T>)
1809
- ): ZodCatch<T> {
1810
- return new ZodCatch({
1811
- type: "catch",
1812
- innerType,
1813
- catchValue: (typeof catchValue === "function" ? catchValue : () => catchValue) as (
1814
- ctx: core.$ZodCatchCtx
1815
- ) => core.output<T>,
1816
- }) as ZodCatch<T>;
1817
- }
1818
- export { _catch as catch };
1819
-
1820
- // ZodNaN
1821
- export interface ZodNaN extends ZodType {
1822
- _zod: core.$ZodNaNInternals;
1823
- }
1824
- export const ZodNaN: core.$constructor<ZodNaN> = /*@__PURE__*/ core.$constructor("ZodNaN", (inst, def) => {
1825
- core.$ZodNaN.init(inst, def);
1826
- ZodType.init(inst, def);
1827
- });
1828
-
1829
- export function nan(params?: string | core.$ZodNaNParams): ZodNaN {
1830
- return core._nan(ZodNaN, params);
1831
- }
1832
-
1833
- // ZodPipe
1834
- export interface ZodPipe<A extends core.$ZodType = core.$ZodType, B extends core.$ZodType = core.$ZodType>
1835
- extends ZodType {
1836
- _zod: core.$ZodPipeInternals<A, B>;
1837
-
1838
- in: A;
1839
- out: B;
1840
- }
1841
- export const ZodPipe: core.$constructor<ZodPipe> = /*@__PURE__*/ core.$constructor("ZodPipe", (inst, def) => {
1842
- core.$ZodPipe.init(inst, def);
1843
- ZodType.init(inst, def);
1844
-
1845
- inst.in = def.in;
1846
- inst.out = def.out;
1847
- });
1848
-
1849
- export function pipe<
1850
- const A extends core.$ZodType,
1851
- B extends core.$ZodType<unknown, core.output<A>> = core.$ZodType<unknown, core.output<A>>,
1852
- >(in_: A, out: B | core.$ZodType<unknown, core.output<A>>): ZodPipe<A, B>;
1853
- export function pipe(in_: core.$ZodType, out: core.$ZodType) {
1854
- return new ZodPipe({
1855
- type: "pipe",
1856
- in: in_,
1857
- out,
1858
-
1859
- // ...util.normalizeParams(params),
1860
- });
1861
- }
1862
-
1863
- // ZodReadonly
1864
- export interface ZodReadonly<T extends core.$ZodType = core.$ZodType> extends ZodType {
1865
- _zod: core.$ZodReadonlyInternals<T>;
1866
- }
1867
- export const ZodReadonly: core.$constructor<ZodReadonly> = /*@__PURE__*/ core.$constructor(
1868
- "ZodReadonly",
1869
- (inst, def) => {
1870
- core.$ZodReadonly.init(inst, def);
1871
- ZodType.init(inst, def);
1872
- }
1873
- );
1874
-
1875
- export function readonly<T extends core.$ZodType>(innerType: T): ZodReadonly<T> {
1876
- return new ZodReadonly({
1877
- type: "readonly",
1878
- innerType,
1879
- }) as ZodReadonly<T>;
1880
- }
1881
-
1882
- // ZodTemplateLiteral
1883
- export interface ZodTemplateLiteral<Template extends string = string> extends ZodType {
1884
- _zod: core.$ZodTemplateLiteralInternals<Template>;
1885
- }
1886
- export const ZodTemplateLiteral: core.$constructor<ZodTemplateLiteral> = /*@__PURE__*/ core.$constructor(
1887
- "ZodTemplateLiteral",
1888
- (inst, def) => {
1889
- core.$ZodTemplateLiteral.init(inst, def);
1890
- ZodType.init(inst, def);
1891
- }
1892
- );
1893
-
1894
- export function templateLiteral<const Parts extends core.$ZodTemplateLiteralPart[]>(
1895
- parts: Parts,
1896
- params?: string | core.$ZodTemplateLiteralParams
1897
- ): ZodTemplateLiteral<core.$PartsToTemplateLiteral<Parts>> {
1898
- return new ZodTemplateLiteral({
1899
- type: "template_literal",
1900
- parts,
1901
- ...util.normalizeParams(params),
1902
- }) as any;
1903
- }
1904
-
1905
- // ZodLazy
1906
- export interface ZodLazy<T extends core.$ZodType = core.$ZodType> extends ZodType {
1907
- _zod: core.$ZodLazyInternals<T>;
1908
-
1909
- unwrap(): T;
1910
- }
1911
- export const ZodLazy: core.$constructor<ZodLazy> = /*@__PURE__*/ core.$constructor("ZodLazy", (inst, def) => {
1912
- core.$ZodLazy.init(inst, def);
1913
- ZodType.init(inst, def);
1914
-
1915
- inst.unwrap = () => inst._zod.def.getter();
1916
- });
1917
-
1918
- export function lazy<T extends core.$ZodType>(getter: () => T): ZodLazy<T> {
1919
- return new ZodLazy({
1920
- type: "lazy",
1921
- getter,
1922
- }) as ZodLazy<T>;
1923
- }
1924
-
1925
- // ZodPromise
1926
- export interface ZodPromise<T extends core.$ZodType = core.$ZodType> extends ZodType {
1927
- _zod: core.$ZodPromiseInternals<T>;
1928
-
1929
- unwrap(): T;
1930
- }
1931
- export const ZodPromise: core.$constructor<ZodPromise> = /*@__PURE__*/ core.$constructor("ZodPromise", (inst, def) => {
1932
- core.$ZodPromise.init(inst, def);
1933
- ZodType.init(inst, def);
1934
-
1935
- inst.unwrap = () => inst._zod.def.innerType;
1936
- });
1937
-
1938
- export function promise<T extends core.$ZodType>(innerType: T): ZodPromise<T> {
1939
- return new ZodPromise({
1940
- type: "promise",
1941
- innerType,
1942
- }) as ZodPromise<T>;
1943
- }
1944
-
1945
- // ZodCustom
1946
- export interface ZodCustom<O = unknown, I = unknown> extends ZodType {
1947
- _zod: core.$ZodCustomInternals<O, I>;
1948
- }
1949
- export const ZodCustom: core.$constructor<ZodCustom> = /*@__PURE__*/ core.$constructor("ZodCustom", (inst, def) => {
1950
- core.$ZodCustom.init(inst, def);
1951
- ZodType.init(inst, def);
1952
- });
1953
-
1954
- // custom checks
1955
- export function check<O = unknown>(fn: core.CheckFn<O>, params?: string | core.$ZodCustomParams): core.$ZodCheck<O> {
1956
- const ch = new core.$ZodCheck({
1957
- check: "custom",
1958
- ...util.normalizeParams(params),
1959
- });
1960
-
1961
- ch._zod.check = fn;
1962
- return ch;
1963
- }
1964
-
1965
- export function custom<O>(
1966
- fn?: (data: unknown) => unknown,
1967
- _params?: string | core.$ZodCustomParams | undefined
1968
- ): ZodCustom<O, O> {
1969
- return core._custom(ZodCustom, fn ?? (() => true), _params) as any;
1970
- }
1971
-
1972
- export function refine<T>(
1973
- fn: (arg: NoInfer<T>) => util.MaybeAsync<unknown>,
1974
- _params: string | core.$ZodCustomParams = {}
1975
- ): core.$ZodCheck<T> {
1976
- return core._custom(ZodCustom, fn, _params);
1977
- }
1978
-
1979
- // superRefine
1980
- export function superRefine<T>(
1981
- fn: (arg: T, payload: RefinementCtx<T>) => void | Promise<void>,
1982
- params?: string | core.$ZodCustomParams
1983
- ): core.$ZodCheck<T> {
1984
- const ch = check<T>((payload) => {
1985
- (payload as RefinementCtx).addIssue = (issue) => {
1986
- if (typeof issue === "string") {
1987
- payload.issues.push(util.issue(issue, payload.value, ch._zod.def));
1988
- } else {
1989
- // for Zod 3 backwards compatibility
1990
- const _issue: any = issue;
1991
- if (_issue.fatal) _issue.continue = false;
1992
- _issue.code ??= "custom";
1993
- _issue.input ??= payload.value;
1994
- _issue.inst ??= ch;
1995
- _issue.continue ??= !ch._zod.def.abort;
1996
- payload.issues.push(util.issue(_issue));
1997
- }
1998
- };
1999
-
2000
- return fn(payload.value, payload as RefinementCtx<T>);
2001
- }, params);
2002
- return ch;
2003
- }
2004
-
2005
- type ZodInstanceOfParams = core.Params<
2006
- ZodCustom,
2007
- core.$ZodIssueCustom,
2008
- "type" | "check" | "checks" | "fn" | "abort" | "error" | "params" | "path"
2009
- >;
2010
- function _instanceof<T extends typeof util.Class>(
2011
- cls: T,
2012
- params: ZodInstanceOfParams = {
2013
- error: `Input not instance of ${cls.name}`,
2014
- }
2015
- ): ZodCustom<InstanceType<T>> {
2016
- const inst = new ZodCustom({
2017
- type: "custom",
2018
- check: "custom",
2019
- fn: (data) => data instanceof cls,
2020
- abort: true,
2021
- ...(util.normalizeParams(params) as any),
2022
- });
2023
- inst._zod.bag.Class = cls;
2024
- return inst as any;
2025
- }
2026
- export { _instanceof as instanceof };
2027
-
2028
- // stringbool
2029
- export const stringbool: (_params?: string | core.$ZodStringBoolParams) => ZodPipe<ZodUnknown, ZodBoolean> =
2030
- /*@__PURE__*/ core._stringbool.bind(null, {
2031
- Pipe: ZodPipe,
2032
- Boolean: ZodBoolean,
2033
- Unknown: ZodUnknown,
2034
- }) as any;
2035
-
2036
- // json
2037
- export type ZodJSONSchema = ZodUnion<
2038
- [ZodString, ZodNumber, ZodBoolean, ZodNull, ZodArray<ZodJSONSchema>, ZodRecord<ZodString, ZodJSONSchema>]
2039
- > & {
2040
- _zod: {
2041
- input: util.JSONType;
2042
- output: util.JSONType;
2043
- };
2044
- };
2045
-
2046
- export function json(params?: string | core.$ZodCustomParams): ZodJSONSchema {
2047
- const jsonSchema: any = lazy(() => {
2048
- return union([string(params), number(), boolean(), _null(), array(jsonSchema), record(string(), jsonSchema)]);
2049
- });
2050
-
2051
- return jsonSchema;
2052
- }
2053
-
2054
- // preprocess
2055
-
2056
- // /** @deprecated Use `z.pipe()` and `z.transform()` instead. */
2057
- export function preprocess<A, U extends core.$ZodType>(
2058
- fn: (arg: unknown, ctx: RefinementCtx) => A,
2059
- schema: U
2060
- ): ZodPipe<ZodTransform<A, unknown>, U> {
2061
- return pipe(transform(fn as any), schema as any);
2062
- }