@willaimg/yatsp 4.3.6

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 (830) hide show
  1. package/README.md +22 -0
  2. package/compile.cjs +96 -0
  3. package/compile.d.cts +1 -0
  4. package/compile.d.ts +1 -0
  5. package/compile.js +52 -0
  6. package/index.cjs +52 -0
  7. package/index.d.cts +3 -0
  8. package/index.d.ts +3 -0
  9. package/index.js +7 -0
  10. package/locales/index.cjs +36 -0
  11. package/locales/index.d.cts +1 -0
  12. package/locales/index.d.ts +1 -0
  13. package/locales/index.js +1 -0
  14. package/mini/index.cjs +51 -0
  15. package/mini/index.d.cts +3 -0
  16. package/mini/index.d.ts +3 -0
  17. package/mini/index.js +3 -0
  18. package/package.json +142 -0
  19. package/src/compile.ts +56 -0
  20. package/src/index.ts +7 -0
  21. package/src/locales/index.ts +1 -0
  22. package/src/mini/index.ts +3 -0
  23. package/src/v3/YatspError.ts +340 -0
  24. package/src/v3/benchmarks/datetime.ts +58 -0
  25. package/src/v3/benchmarks/discriminatedUnion.ts +80 -0
  26. package/src/v3/benchmarks/index.ts +59 -0
  27. package/src/v3/benchmarks/ipv4.ts +57 -0
  28. package/src/v3/benchmarks/object.ts +69 -0
  29. package/src/v3/benchmarks/primitives.ts +162 -0
  30. package/src/v3/benchmarks/realworld.ts +63 -0
  31. package/src/v3/benchmarks/string.ts +55 -0
  32. package/src/v3/benchmarks/union.ts +80 -0
  33. package/src/v3/errors.ts +13 -0
  34. package/src/v3/external.ts +6 -0
  35. package/src/v3/helpers/enumUtil.ts +17 -0
  36. package/src/v3/helpers/errorUtil.ts +8 -0
  37. package/src/v3/helpers/parseUtil.ts +176 -0
  38. package/src/v3/helpers/partialUtil.ts +34 -0
  39. package/src/v3/helpers/typeAliases.ts +2 -0
  40. package/src/v3/helpers/util.ts +224 -0
  41. package/src/v3/index.ts +4 -0
  42. package/src/v3/locales/en.ts +124 -0
  43. package/src/v3/standard-schema.ts +113 -0
  44. package/src/v3/tests/Mocker.ts +54 -0
  45. package/src/v3/tests/all-errors.test.ts +157 -0
  46. package/src/v3/tests/anyunknown.test.ts +28 -0
  47. package/src/v3/tests/array.test.ts +71 -0
  48. package/src/v3/tests/async-parsing.test.ts +388 -0
  49. package/src/v3/tests/async-refinements.test.ts +46 -0
  50. package/src/v3/tests/base.test.ts +29 -0
  51. package/src/v3/tests/bigint.test.ts +55 -0
  52. package/src/v3/tests/branded.test.ts +53 -0
  53. package/src/v3/tests/catch.test.ts +220 -0
  54. package/src/v3/tests/coerce.test.ts +133 -0
  55. package/src/v3/tests/complex.test.ts +70 -0
  56. package/src/v3/tests/custom.test.ts +31 -0
  57. package/src/v3/tests/date.test.ts +32 -0
  58. package/src/v3/tests/deepmasking.test.ts +186 -0
  59. package/src/v3/tests/default.test.ts +112 -0
  60. package/src/v3/tests/description.test.ts +33 -0
  61. package/src/v3/tests/discriminated-unions.test.ts +315 -0
  62. package/src/v3/tests/enum.test.ts +80 -0
  63. package/src/v3/tests/error.test.ts +586 -0
  64. package/src/v3/tests/firstparty.test.ts +87 -0
  65. package/src/v3/tests/firstpartyschematypes.test.ts +21 -0
  66. package/src/v3/tests/function.test.ts +261 -0
  67. package/src/v3/tests/generics.test.ts +48 -0
  68. package/src/v3/tests/instanceof.test.ts +37 -0
  69. package/src/v3/tests/intersection.test.ts +128 -0
  70. package/src/v3/tests/language-server.source.ts +76 -0
  71. package/src/v3/tests/language-server.test.ts +206 -0
  72. package/src/v3/tests/literal.test.ts +36 -0
  73. package/src/v3/tests/map.test.ts +110 -0
  74. package/src/v3/tests/masking.test.ts +4 -0
  75. package/src/v3/tests/mocker.test.ts +19 -0
  76. package/src/v3/tests/nan.test.ts +24 -0
  77. package/src/v3/tests/nativeEnum.test.ts +87 -0
  78. package/src/v3/tests/nullable.test.ts +42 -0
  79. package/src/v3/tests/number.test.ts +176 -0
  80. package/src/v3/tests/object-augmentation.test.ts +29 -0
  81. package/src/v3/tests/object-in-es5-env.test.ts +29 -0
  82. package/src/v3/tests/object.test.ts +431 -0
  83. package/src/v3/tests/optional.test.ts +42 -0
  84. package/src/v3/tests/parseUtil.test.ts +23 -0
  85. package/src/v3/tests/parser.test.ts +41 -0
  86. package/src/v3/tests/partials.test.ts +243 -0
  87. package/src/v3/tests/pickomit.test.ts +111 -0
  88. package/src/v3/tests/pipeline.test.ts +29 -0
  89. package/src/v3/tests/preprocess.test.ts +186 -0
  90. package/src/v3/tests/primitive.test.ts +440 -0
  91. package/src/v3/tests/promise.test.ts +90 -0
  92. package/src/v3/tests/readonly.test.ts +114 -0
  93. package/src/v3/tests/record.test.ts +171 -0
  94. package/src/v3/tests/recursive.test.ts +197 -0
  95. package/src/v3/tests/refine.test.ts +313 -0
  96. package/src/v3/tests/safeparse.test.ts +27 -0
  97. package/src/v3/tests/set.test.ts +142 -0
  98. package/src/v3/tests/standard-schema.test.ts +83 -0
  99. package/src/v3/tests/string.test.ts +922 -0
  100. package/src/v3/tests/transformer.test.ts +233 -0
  101. package/src/v3/tests/tuple.test.ts +90 -0
  102. package/src/v3/tests/unions.test.ts +57 -0
  103. package/src/v3/tests/validations.test.ts +133 -0
  104. package/src/v3/tests/void.test.ts +15 -0
  105. package/src/v3/types.ts +5162 -0
  106. package/src/v4/classic/checks.ts +33 -0
  107. package/src/v4/classic/coerce.ts +27 -0
  108. package/src/v4/classic/compat.ts +78 -0
  109. package/src/v4/classic/deep-partial.ts +76 -0
  110. package/src/v4/classic/errors.ts +97 -0
  111. package/src/v4/classic/external.ts +57 -0
  112. package/src/v4/classic/from-json-schema.ts +944 -0
  113. package/src/v4/classic/in-out.ts +45 -0
  114. package/src/v4/classic/index.ts +5 -0
  115. package/src/v4/classic/iso.ts +20 -0
  116. package/src/v4/classic/parse.ts +88 -0
  117. package/src/v4/classic/schemas.ts +2994 -0
  118. package/src/v4/classic/tests/anyunknown.test.ts +26 -0
  119. package/src/v4/classic/tests/apply.test.ts +86 -0
  120. package/src/v4/classic/tests/array.test.ts +264 -0
  121. package/src/v4/classic/tests/assignability.test.ts +402 -0
  122. package/src/v4/classic/tests/async-parsing.test.ts +381 -0
  123. package/src/v4/classic/tests/async-refinements.test.ts +68 -0
  124. package/src/v4/classic/tests/base.test.ts +7 -0
  125. package/src/v4/classic/tests/bigint.test.ts +89 -0
  126. package/src/v4/classic/tests/brand.test.ts +106 -0
  127. package/src/v4/classic/tests/catch.test.ts +604 -0
  128. package/src/v4/classic/tests/coalesce.test.ts +20 -0
  129. package/src/v4/classic/tests/codec-examples.test.ts +572 -0
  130. package/src/v4/classic/tests/codec.test.ts +704 -0
  131. package/src/v4/classic/tests/coerce.test.ts +160 -0
  132. package/src/v4/classic/tests/continuability.test.ts +374 -0
  133. package/src/v4/classic/tests/credit-card.test.ts +76 -0
  134. package/src/v4/classic/tests/custom.test.ts +40 -0
  135. package/src/v4/classic/tests/cyclic-data.test.ts +985 -0
  136. package/src/v4/classic/tests/date.test.ts +92 -0
  137. package/src/v4/classic/tests/datetime.test.ts +316 -0
  138. package/src/v4/classic/tests/deep-partial.test.ts +380 -0
  139. package/src/v4/classic/tests/default-locale.test.ts +32 -0
  140. package/src/v4/classic/tests/default.test.ts +455 -0
  141. package/src/v4/classic/tests/describe-meta-checks.test.ts +27 -0
  142. package/src/v4/classic/tests/description.test.ts +32 -0
  143. package/src/v4/classic/tests/detached-methods.test.ts +226 -0
  144. package/src/v4/classic/tests/discriminated-unions.test.ts +942 -0
  145. package/src/v4/classic/tests/enum.test.ts +305 -0
  146. package/src/v4/classic/tests/error-utils.test.ts +917 -0
  147. package/src/v4/classic/tests/error.test.ts +1108 -0
  148. package/src/v4/classic/tests/file.test.ts +96 -0
  149. package/src/v4/classic/tests/firstparty.test.ts +179 -0
  150. package/src/v4/classic/tests/fix-json-issue.test.ts +26 -0
  151. package/src/v4/classic/tests/from-json-schema.test.ts +1467 -0
  152. package/src/v4/classic/tests/function.test.ts +391 -0
  153. package/src/v4/classic/tests/generics.test.ts +72 -0
  154. package/src/v4/classic/tests/global-config.test.ts +32 -0
  155. package/src/v4/classic/tests/hash.test.ts +67 -0
  156. package/src/v4/classic/tests/iban.test.ts +81 -0
  157. package/src/v4/classic/tests/in-out.test.ts +159 -0
  158. package/src/v4/classic/tests/index.test.ts +958 -0
  159. package/src/v4/classic/tests/instance-footprint.test.ts +319 -0
  160. package/src/v4/classic/tests/instanceof.test.ts +127 -0
  161. package/src/v4/classic/tests/intersection.test.ts +334 -0
  162. package/src/v4/classic/tests/issue-schema.test.ts +215 -0
  163. package/src/v4/classic/tests/jitless-allows-eval.test.ts +39 -0
  164. package/src/v4/classic/tests/json.test.ts +109 -0
  165. package/src/v4/classic/tests/lazy.test.ts +262 -0
  166. package/src/v4/classic/tests/literal.test.ts +128 -0
  167. package/src/v4/classic/tests/locales_ka.test.ts +29 -0
  168. package/src/v4/classic/tests/locales_ro.test.ts +24 -0
  169. package/src/v4/classic/tests/map.test.ts +342 -0
  170. package/src/v4/classic/tests/nan.test.ts +21 -0
  171. package/src/v4/classic/tests/nested-refine.test.ts +168 -0
  172. package/src/v4/classic/tests/nonoptional.test.ts +101 -0
  173. package/src/v4/classic/tests/nullable.test.ts +22 -0
  174. package/src/v4/classic/tests/number.test.ts +401 -0
  175. package/src/v4/classic/tests/object.test.ts +1006 -0
  176. package/src/v4/classic/tests/optin-ladder.test.ts +235 -0
  177. package/src/v4/classic/tests/optional.test.ts +366 -0
  178. package/src/v4/classic/tests/partial.test.ts +497 -0
  179. package/src/v4/classic/tests/pickomit.test.ts +211 -0
  180. package/src/v4/classic/tests/pipe.test.ts +101 -0
  181. package/src/v4/classic/tests/prefault.test.ts +144 -0
  182. package/src/v4/classic/tests/preprocess-types.test.ts +44 -0
  183. package/src/v4/classic/tests/preprocess.test.ts +351 -0
  184. package/src/v4/classic/tests/primitive.test.ts +175 -0
  185. package/src/v4/classic/tests/promise.test.ts +81 -0
  186. package/src/v4/classic/tests/properties.test.ts +141 -0
  187. package/src/v4/classic/tests/prototypes.test.ts +23 -0
  188. package/src/v4/classic/tests/readonly.test.ts +184 -0
  189. package/src/v4/classic/tests/record.test.ts +885 -0
  190. package/src/v4/classic/tests/recursive-types.test.ts +707 -0
  191. package/src/v4/classic/tests/redos.test.ts +68 -0
  192. package/src/v4/classic/tests/refine.test.ts +693 -0
  193. package/src/v4/classic/tests/registries.test.ts +243 -0
  194. package/src/v4/classic/tests/set.test.ts +190 -0
  195. package/src/v4/classic/tests/standard-schema.test.ts +153 -0
  196. package/src/v4/classic/tests/string-formats.test.ts +125 -0
  197. package/src/v4/classic/tests/string.test.ts +1440 -0
  198. package/src/v4/classic/tests/stringbool.test.ts +124 -0
  199. package/src/v4/classic/tests/template-literal.test.ts +814 -0
  200. package/src/v4/classic/tests/to-json-schema-methods.test.ts +438 -0
  201. package/src/v4/classic/tests/to-json-schema.test.ts +4733 -0
  202. package/src/v4/classic/tests/transform.test.ts +378 -0
  203. package/src/v4/classic/tests/tuple.test.ts +511 -0
  204. package/src/v4/classic/tests/union.test.ts +310 -0
  205. package/src/v4/classic/tests/url.test.ts +13 -0
  206. package/src/v4/classic/tests/validate.test.ts +645 -0
  207. package/src/v4/classic/tests/validations.test.ts +283 -0
  208. package/src/v4/classic/tests/void.test.ts +12 -0
  209. package/src/v4/core/api.ts +1913 -0
  210. package/src/v4/core/checks.ts +1274 -0
  211. package/src/v4/core/compile.ts +2315 -0
  212. package/src/v4/core/core.ts +230 -0
  213. package/src/v4/core/doc.ts +52 -0
  214. package/src/v4/core/errors.ts +546 -0
  215. package/src/v4/core/index.ts +19 -0
  216. package/src/v4/core/json-schema-generator.ts +131 -0
  217. package/src/v4/core/json-schema-processors.ts +934 -0
  218. package/src/v4/core/json-schema.ts +148 -0
  219. package/src/v4/core/memoizer.ts +331 -0
  220. package/src/v4/core/parse.ts +309 -0
  221. package/src/v4/core/regexes.ts +217 -0
  222. package/src/v4/core/registries.ts +109 -0
  223. package/src/v4/core/schemas.ts +5295 -0
  224. package/src/v4/core/standard-schema.ts +159 -0
  225. package/src/v4/core/tests/cached.test.ts +54 -0
  226. package/src/v4/core/tests/compile-differential.test.ts +1004 -0
  227. package/src/v4/core/tests/compile-generative.test.ts +445 -0
  228. package/src/v4/core/tests/compile-global.test.ts +89 -0
  229. package/src/v4/core/tests/compile-off-by-default.test.ts +26 -0
  230. package/src/v4/core/tests/compile-stats.test.ts +34 -0
  231. package/src/v4/core/tests/compile.test.ts +2040 -0
  232. package/src/v4/core/tests/email-regex.test.ts +140 -0
  233. package/src/v4/core/tests/extend.test.ts +59 -0
  234. package/src/v4/core/tests/index.test.ts +46 -0
  235. package/src/v4/core/tests/locales/be.test.ts +124 -0
  236. package/src/v4/core/tests/locales/el.test.ts +214 -0
  237. package/src/v4/core/tests/locales/en.test.ts +22 -0
  238. package/src/v4/core/tests/locales/es.test.ts +180 -0
  239. package/src/v4/core/tests/locales/fr.test.ts +72 -0
  240. package/src/v4/core/tests/locales/he.test.ts +379 -0
  241. package/src/v4/core/tests/locales/hr.test.ts +163 -0
  242. package/src/v4/core/tests/locales/nl.test.ts +46 -0
  243. package/src/v4/core/tests/locales/parity.test.ts +42 -0
  244. package/src/v4/core/tests/locales/ru.test.ts +128 -0
  245. package/src/v4/core/tests/locales/tg.test.ts +85 -0
  246. package/src/v4/core/tests/locales/tk.test.ts +69 -0
  247. package/src/v4/core/tests/locales/tr.test.ts +69 -0
  248. package/src/v4/core/tests/locales/uz.test.ts +105 -0
  249. package/src/v4/core/tests/polyfill-collision.test.ts +46 -0
  250. package/src/v4/core/tests/record-constructor.test.ts +125 -0
  251. package/src/v4/core/tests/recursive-tuples.test.ts +45 -0
  252. package/src/v4/core/tests/treeshake.test.ts +51 -0
  253. package/src/v4/core/tests/url-no-canparse.test.ts +133 -0
  254. package/src/v4/core/to-json-schema.ts +857 -0
  255. package/src/v4/core/util.ts +1284 -0
  256. package/src/v4/core/versions.ts +5 -0
  257. package/src/v4/core/visit.ts +193 -0
  258. package/src/v4/core/zsf.ts +323 -0
  259. package/src/v4/index.ts +4 -0
  260. package/src/v4/locales/ar.ts +120 -0
  261. package/src/v4/locales/az.ts +116 -0
  262. package/src/v4/locales/be.ts +188 -0
  263. package/src/v4/locales/bg.ts +133 -0
  264. package/src/v4/locales/bn.ts +123 -0
  265. package/src/v4/locales/ca.ts +121 -0
  266. package/src/v4/locales/ckb.ts +140 -0
  267. package/src/v4/locales/cs.ts +123 -0
  268. package/src/v4/locales/da.ts +128 -0
  269. package/src/v4/locales/de.ts +121 -0
  270. package/src/v4/locales/el.ts +124 -0
  271. package/src/v4/locales/en.ts +136 -0
  272. package/src/v4/locales/eo.ts +123 -0
  273. package/src/v4/locales/es.ts +145 -0
  274. package/src/v4/locales/fa.ts +131 -0
  275. package/src/v4/locales/fi.ts +126 -0
  276. package/src/v4/locales/fr-CA.ts +121 -0
  277. package/src/v4/locales/fr.ts +139 -0
  278. package/src/v4/locales/gu.ts +123 -0
  279. package/src/v4/locales/he.ts +253 -0
  280. package/src/v4/locales/hi.ts +126 -0
  281. package/src/v4/locales/hr.ts +135 -0
  282. package/src/v4/locales/hu.ts +122 -0
  283. package/src/v4/locales/hy.ts +175 -0
  284. package/src/v4/locales/id.ts +120 -0
  285. package/src/v4/locales/index.ts +63 -0
  286. package/src/v4/locales/is.ts +124 -0
  287. package/src/v4/locales/it.ts +121 -0
  288. package/src/v4/locales/ja.ts +119 -0
  289. package/src/v4/locales/ka.ts +128 -0
  290. package/src/v4/locales/kh.ts +7 -0
  291. package/src/v4/locales/km.ts +124 -0
  292. package/src/v4/locales/kn.ts +126 -0
  293. package/src/v4/locales/ko.ts +126 -0
  294. package/src/v4/locales/lt.ts +243 -0
  295. package/src/v4/locales/mk.ts +123 -0
  296. package/src/v4/locales/ms.ts +120 -0
  297. package/src/v4/locales/ne.ts +128 -0
  298. package/src/v4/locales/nl.ts +126 -0
  299. package/src/v4/locales/nn.ts +121 -0
  300. package/src/v4/locales/no.ts +121 -0
  301. package/src/v4/locales/ota.ts +122 -0
  302. package/src/v4/locales/pl.ts +123 -0
  303. package/src/v4/locales/ps.ts +131 -0
  304. package/src/v4/locales/pt-BR.ts +161 -0
  305. package/src/v4/locales/pt.ts +159 -0
  306. package/src/v4/locales/ro.ts +132 -0
  307. package/src/v4/locales/ru.ts +188 -0
  308. package/src/v4/locales/sk.ts +123 -0
  309. package/src/v4/locales/sl.ts +123 -0
  310. package/src/v4/locales/sv.ts +124 -0
  311. package/src/v4/locales/ta.ts +123 -0
  312. package/src/v4/locales/tg.ts +135 -0
  313. package/src/v4/locales/th.ts +124 -0
  314. package/src/v4/locales/tk.ts +113 -0
  315. package/src/v4/locales/tr.ts +116 -0
  316. package/src/v4/locales/ua.ts +7 -0
  317. package/src/v4/locales/uk.ts +122 -0
  318. package/src/v4/locales/ur.ts +124 -0
  319. package/src/v4/locales/uz.ts +120 -0
  320. package/src/v4/locales/vi.ts +122 -0
  321. package/src/v4/locales/yo.ts +129 -0
  322. package/src/v4/locales/zh-CN.ts +121 -0
  323. package/src/v4/locales/zh-TW.ts +120 -0
  324. package/src/v4/mini/checks.ts +33 -0
  325. package/src/v4/mini/coerce.ts +27 -0
  326. package/src/v4/mini/deep-partial.ts +73 -0
  327. package/src/v4/mini/external.ts +52 -0
  328. package/src/v4/mini/in-out.ts +45 -0
  329. package/src/v4/mini/index.ts +3 -0
  330. package/src/v4/mini/iso.ts +66 -0
  331. package/src/v4/mini/parse.ts +16 -0
  332. package/src/v4/mini/schemas.ts +2093 -0
  333. package/src/v4/mini/tests/apply.test.ts +57 -0
  334. package/src/v4/mini/tests/assignability.test.ts +190 -0
  335. package/src/v4/mini/tests/brand.test.ts +94 -0
  336. package/src/v4/mini/tests/checks.test.ts +158 -0
  337. package/src/v4/mini/tests/codec.test.ts +582 -0
  338. package/src/v4/mini/tests/computed.test.ts +30 -0
  339. package/src/v4/mini/tests/cyclic-data.test.ts +84 -0
  340. package/src/v4/mini/tests/deep-partial.test.ts +54 -0
  341. package/src/v4/mini/tests/error.test.ts +41 -0
  342. package/src/v4/mini/tests/functions.test.ts +14 -0
  343. package/src/v4/mini/tests/index.test.ts +1148 -0
  344. package/src/v4/mini/tests/number.test.ts +109 -0
  345. package/src/v4/mini/tests/object.test.ts +292 -0
  346. package/src/v4/mini/tests/prototypes.test.ts +43 -0
  347. package/src/v4/mini/tests/recursive-types.test.ts +341 -0
  348. package/src/v4/mini/tests/standard-schema.test.ts +50 -0
  349. package/src/v4/mini/tests/string.test.ts +396 -0
  350. package/src/v4-mini/index.ts +3 -0
  351. package/v3/YatspError.cjs +167 -0
  352. package/v3/YatspError.d.cts +164 -0
  353. package/v3/YatspError.d.ts +164 -0
  354. package/v3/YatspError.js +143 -0
  355. package/v3/errors.cjs +36 -0
  356. package/v3/errors.d.cts +5 -0
  357. package/v3/errors.d.ts +5 -0
  358. package/v3/errors.js +9 -0
  359. package/v3/external.cjs +41 -0
  360. package/v3/external.d.cts +6 -0
  361. package/v3/external.d.ts +6 -0
  362. package/v3/external.js +6 -0
  363. package/v3/helpers/enumUtil.cjs +21 -0
  364. package/v3/helpers/enumUtil.d.cts +8 -0
  365. package/v3/helpers/enumUtil.d.ts +8 -0
  366. package/v3/helpers/enumUtil.js +1 -0
  367. package/v3/helpers/errorUtil.cjs +28 -0
  368. package/v3/helpers/errorUtil.d.cts +9 -0
  369. package/v3/helpers/errorUtil.d.ts +9 -0
  370. package/v3/helpers/errorUtil.js +6 -0
  371. package/v3/helpers/parseUtil.cjs +143 -0
  372. package/v3/helpers/parseUtil.d.cts +78 -0
  373. package/v3/helpers/parseUtil.d.ts +78 -0
  374. package/v3/helpers/parseUtil.js +109 -0
  375. package/v3/helpers/partialUtil.cjs +21 -0
  376. package/v3/helpers/partialUtil.d.cts +8 -0
  377. package/v3/helpers/partialUtil.d.ts +8 -0
  378. package/v3/helpers/partialUtil.js +1 -0
  379. package/v3/helpers/typeAliases.cjs +21 -0
  380. package/v3/helpers/typeAliases.d.cts +2 -0
  381. package/v3/helpers/typeAliases.d.ts +2 -0
  382. package/v3/helpers/typeAliases.js +1 -0
  383. package/v3/helpers/util.cjs +156 -0
  384. package/v3/helpers/util.d.cts +85 -0
  385. package/v3/helpers/util.d.ts +85 -0
  386. package/v3/helpers/util.js +133 -0
  387. package/v3/index.cjs +52 -0
  388. package/v3/index.d.cts +4 -0
  389. package/v3/index.d.ts +4 -0
  390. package/v3/index.js +4 -0
  391. package/v3/locales/en.cjs +112 -0
  392. package/v3/locales/en.d.cts +3 -0
  393. package/v3/locales/en.d.ts +3 -0
  394. package/v3/locales/en.js +109 -0
  395. package/v3/standard-schema.cjs +21 -0
  396. package/v3/standard-schema.d.cts +102 -0
  397. package/v3/standard-schema.d.ts +102 -0
  398. package/v3/standard-schema.js +1 -0
  399. package/v3/types.cjs +3798 -0
  400. package/v3/types.d.cts +1034 -0
  401. package/v3/types.d.ts +1034 -0
  402. package/v3/types.js +3697 -0
  403. package/v4/classic/checks.cjs +53 -0
  404. package/v4/classic/checks.d.cts +1 -0
  405. package/v4/classic/checks.d.ts +1 -0
  406. package/v4/classic/checks.js +1 -0
  407. package/v4/classic/coerce.cjs +66 -0
  408. package/v4/classic/coerce.d.cts +17 -0
  409. package/v4/classic/coerce.d.ts +17 -0
  410. package/v4/classic/coerce.js +17 -0
  411. package/v4/classic/compat.cjs +80 -0
  412. package/v4/classic/compat.d.cts +48 -0
  413. package/v4/classic/compat.d.ts +48 -0
  414. package/v4/classic/compat.js +31 -0
  415. package/v4/classic/deep-partial.cjs +58 -0
  416. package/v4/classic/deep-partial.d.cts +14 -0
  417. package/v4/classic/deep-partial.d.ts +14 -0
  418. package/v4/classic/deep-partial.js +13 -0
  419. package/v4/classic/errors.cjs +102 -0
  420. package/v4/classic/errors.d.cts +29 -0
  421. package/v4/classic/errors.d.ts +29 -0
  422. package/v4/classic/errors.js +57 -0
  423. package/v4/classic/external.cjs +97 -0
  424. package/v4/classic/external.d.cts +19 -0
  425. package/v4/classic/external.d.ts +19 -0
  426. package/v4/classic/external.js +17 -0
  427. package/v4/classic/from-json-schema.cjs +926 -0
  428. package/v4/classic/from-json-schema.d.cts +12 -0
  429. package/v4/classic/from-json-schema.d.ts +12 -0
  430. package/v4/classic/from-json-schema.js +881 -0
  431. package/v4/classic/in-out.cjs +82 -0
  432. package/v4/classic/in-out.d.cts +8 -0
  433. package/v4/classic/in-out.d.ts +8 -0
  434. package/v4/classic/in-out.js +36 -0
  435. package/v4/classic/index.cjs +52 -0
  436. package/v4/classic/index.d.cts +3 -0
  437. package/v4/classic/index.d.ts +3 -0
  438. package/v4/classic/index.js +4 -0
  439. package/v4/classic/iso.cjs +68 -0
  440. package/v4/classic/iso.d.cts +7 -0
  441. package/v4/classic/iso.d.ts +7 -0
  442. package/v4/classic/iso.js +15 -0
  443. package/v4/classic/parse.cjs +63 -0
  444. package/v4/classic/parse.d.cts +44 -0
  445. package/v4/classic/parse.d.ts +44 -0
  446. package/v4/classic/parse.js +16 -0
  447. package/v4/classic/schemas.cjs +1676 -0
  448. package/v4/classic/schemas.d.cts +816 -0
  449. package/v4/classic/schemas.d.ts +816 -0
  450. package/v4/classic/schemas.js +1535 -0
  451. package/v4/core/api.cjs +1269 -0
  452. package/v4/core/api.d.cts +335 -0
  453. package/v4/core/api.d.ts +335 -0
  454. package/v4/core/api.js +1107 -0
  455. package/v4/core/checks.cjs +561 -0
  456. package/v4/core/checks.d.cts +294 -0
  457. package/v4/core/checks.d.ts +294 -0
  458. package/v4/core/checks.js +516 -0
  459. package/v4/core/compile.cjs +1908 -0
  460. package/v4/core/compile.d.cts +65 -0
  461. package/v4/core/compile.d.ts +65 -0
  462. package/v4/core/compile.js +1858 -0
  463. package/v4/core/core.cjs +167 -0
  464. package/v4/core/core.d.cts +82 -0
  465. package/v4/core/core.d.ts +82 -0
  466. package/v4/core/core.js +141 -0
  467. package/v4/core/doc.cjs +61 -0
  468. package/v4/core/doc.d.cts +16 -0
  469. package/v4/core/doc.d.ts +16 -0
  470. package/v4/core/doc.js +38 -0
  471. package/v4/core/errors.cjs +317 -0
  472. package/v4/core/errors.d.cts +225 -0
  473. package/v4/core/errors.d.ts +225 -0
  474. package/v4/core/errors.js +267 -0
  475. package/v4/core/index.cjs +70 -0
  476. package/v4/core/index.d.cts +19 -0
  477. package/v4/core/index.d.ts +19 -0
  478. package/v4/core/index.js +19 -0
  479. package/v4/core/json-schema-generator.cjs +122 -0
  480. package/v4/core/json-schema-generator.d.cts +65 -0
  481. package/v4/core/json-schema-generator.d.ts +65 -0
  482. package/v4/core/json-schema-generator.js +99 -0
  483. package/v4/core/json-schema-processors.cjs +929 -0
  484. package/v4/core/json-schema-processors.d.cts +65 -0
  485. package/v4/core/json-schema-processors.d.ts +65 -0
  486. package/v4/core/json-schema-processors.js +843 -0
  487. package/v4/core/json-schema.cjs +21 -0
  488. package/v4/core/json-schema.d.cts +89 -0
  489. package/v4/core/json-schema.d.ts +89 -0
  490. package/v4/core/json-schema.js +1 -0
  491. package/v4/core/memoizer.cjs +360 -0
  492. package/v4/core/memoizer.d.cts +15 -0
  493. package/v4/core/memoizer.d.ts +15 -0
  494. package/v4/core/memoizer.js +311 -0
  495. package/v4/core/parse.cjs +233 -0
  496. package/v4/core/parse.d.cts +52 -0
  497. package/v4/core/parse.d.ts +52 -0
  498. package/v4/core/parse.js +175 -0
  499. package/v4/core/regexes.cjs +209 -0
  500. package/v4/core/regexes.d.cts +90 -0
  501. package/v4/core/regexes.d.ts +90 -0
  502. package/v4/core/regexes.js +156 -0
  503. package/v4/core/registries.cjs +76 -0
  504. package/v4/core/registries.d.cts +35 -0
  505. package/v4/core/registries.d.ts +35 -0
  506. package/v4/core/registries.js +52 -0
  507. package/v4/core/schemas.cjs +2669 -0
  508. package/v4/core/schemas.d.cts +1273 -0
  509. package/v4/core/schemas.d.ts +1273 -0
  510. package/v4/core/schemas.js +2606 -0
  511. package/v4/core/standard-schema.cjs +21 -0
  512. package/v4/core/standard-schema.d.cts +126 -0
  513. package/v4/core/standard-schema.d.ts +126 -0
  514. package/v4/core/standard-schema.js +1 -0
  515. package/v4/core/to-json-schema.cjs +681 -0
  516. package/v4/core/to-json-schema.d.cts +154 -0
  517. package/v4/core/to-json-schema.d.ts +154 -0
  518. package/v4/core/to-json-schema.js +651 -0
  519. package/v4/core/util.cjs +949 -0
  520. package/v4/core/util.d.cts +278 -0
  521. package/v4/core/util.d.ts +278 -0
  522. package/v4/core/util.js +859 -0
  523. package/v4/core/versions.cjs +27 -0
  524. package/v4/core/versions.d.cts +5 -0
  525. package/v4/core/versions.d.ts +5 -0
  526. package/v4/core/versions.js +5 -0
  527. package/v4/core/visit.cjs +214 -0
  528. package/v4/core/visit.d.cts +30 -0
  529. package/v4/core/visit.d.ts +30 -0
  530. package/v4/core/visit.js +169 -0
  531. package/v4/index.cjs +51 -0
  532. package/v4/index.d.cts +3 -0
  533. package/v4/index.d.ts +3 -0
  534. package/v4/index.js +4 -0
  535. package/v4/locales/ar.cjs +138 -0
  536. package/v4/locales/ar.d.cts +5 -0
  537. package/v4/locales/ar.d.ts +4 -0
  538. package/v4/locales/ar.js +111 -0
  539. package/v4/locales/az.cjs +137 -0
  540. package/v4/locales/az.d.cts +5 -0
  541. package/v4/locales/az.d.ts +4 -0
  542. package/v4/locales/az.js +110 -0
  543. package/v4/locales/be.cjs +195 -0
  544. package/v4/locales/be.d.cts +5 -0
  545. package/v4/locales/be.d.ts +4 -0
  546. package/v4/locales/be.js +168 -0
  547. package/v4/locales/bg.cjs +152 -0
  548. package/v4/locales/bg.d.cts +5 -0
  549. package/v4/locales/bg.d.ts +4 -0
  550. package/v4/locales/bg.js +125 -0
  551. package/v4/locales/bn.cjs +140 -0
  552. package/v4/locales/bn.d.cts +5 -0
  553. package/v4/locales/bn.d.ts +4 -0
  554. package/v4/locales/bn.js +113 -0
  555. package/v4/locales/ca.cjs +139 -0
  556. package/v4/locales/ca.d.cts +5 -0
  557. package/v4/locales/ca.d.ts +4 -0
  558. package/v4/locales/ca.js +112 -0
  559. package/v4/locales/ckb.cjs +160 -0
  560. package/v4/locales/ckb.d.cts +5 -0
  561. package/v4/locales/ckb.d.ts +4 -0
  562. package/v4/locales/ckb.js +133 -0
  563. package/v4/locales/cs.cjs +143 -0
  564. package/v4/locales/cs.d.cts +5 -0
  565. package/v4/locales/cs.d.ts +4 -0
  566. package/v4/locales/cs.js +116 -0
  567. package/v4/locales/da.cjs +147 -0
  568. package/v4/locales/da.d.cts +5 -0
  569. package/v4/locales/da.d.ts +4 -0
  570. package/v4/locales/da.js +120 -0
  571. package/v4/locales/de.cjs +140 -0
  572. package/v4/locales/de.d.cts +5 -0
  573. package/v4/locales/de.d.ts +4 -0
  574. package/v4/locales/de.js +113 -0
  575. package/v4/locales/el.cjs +139 -0
  576. package/v4/locales/el.d.cts +5 -0
  577. package/v4/locales/el.d.ts +4 -0
  578. package/v4/locales/el.js +112 -0
  579. package/v4/locales/en.cjs +152 -0
  580. package/v4/locales/en.d.cts +5 -0
  581. package/v4/locales/en.d.ts +4 -0
  582. package/v4/locales/en.js +125 -0
  583. package/v4/locales/eo.cjs +141 -0
  584. package/v4/locales/eo.d.cts +5 -0
  585. package/v4/locales/eo.d.ts +4 -0
  586. package/v4/locales/eo.js +114 -0
  587. package/v4/locales/es.cjs +163 -0
  588. package/v4/locales/es.d.cts +5 -0
  589. package/v4/locales/es.d.ts +4 -0
  590. package/v4/locales/es.js +136 -0
  591. package/v4/locales/fa.cjs +146 -0
  592. package/v4/locales/fa.d.cts +5 -0
  593. package/v4/locales/fa.d.ts +4 -0
  594. package/v4/locales/fa.js +119 -0
  595. package/v4/locales/fi.cjs +144 -0
  596. package/v4/locales/fi.d.cts +5 -0
  597. package/v4/locales/fi.d.ts +4 -0
  598. package/v4/locales/fi.js +117 -0
  599. package/v4/locales/fr-CA.cjs +139 -0
  600. package/v4/locales/fr-CA.d.cts +5 -0
  601. package/v4/locales/fr-CA.d.ts +4 -0
  602. package/v4/locales/fr-CA.js +112 -0
  603. package/v4/locales/fr.cjs +156 -0
  604. package/v4/locales/fr.d.cts +5 -0
  605. package/v4/locales/fr.d.ts +4 -0
  606. package/v4/locales/fr.js +129 -0
  607. package/v4/locales/gu.cjs +140 -0
  608. package/v4/locales/gu.d.cts +5 -0
  609. package/v4/locales/gu.d.ts +4 -0
  610. package/v4/locales/gu.js +113 -0
  611. package/v4/locales/he.cjs +248 -0
  612. package/v4/locales/he.d.cts +5 -0
  613. package/v4/locales/he.d.ts +4 -0
  614. package/v4/locales/he.js +221 -0
  615. package/v4/locales/hi.cjs +138 -0
  616. package/v4/locales/hi.d.cts +5 -0
  617. package/v4/locales/hi.d.ts +4 -0
  618. package/v4/locales/hi.js +111 -0
  619. package/v4/locales/hr.cjs +153 -0
  620. package/v4/locales/hr.d.cts +5 -0
  621. package/v4/locales/hr.d.ts +4 -0
  622. package/v4/locales/hr.js +126 -0
  623. package/v4/locales/hu.cjs +140 -0
  624. package/v4/locales/hu.d.cts +5 -0
  625. package/v4/locales/hu.d.ts +4 -0
  626. package/v4/locales/hu.js +113 -0
  627. package/v4/locales/hy.cjs +185 -0
  628. package/v4/locales/hy.d.cts +5 -0
  629. package/v4/locales/hy.d.ts +4 -0
  630. package/v4/locales/hy.js +158 -0
  631. package/v4/locales/id.cjs +138 -0
  632. package/v4/locales/id.d.cts +5 -0
  633. package/v4/locales/id.d.ts +4 -0
  634. package/v4/locales/id.js +111 -0
  635. package/v4/locales/index.cjs +152 -0
  636. package/v4/locales/index.d.cts +63 -0
  637. package/v4/locales/index.d.ts +63 -0
  638. package/v4/locales/index.js +63 -0
  639. package/v4/locales/is.cjs +141 -0
  640. package/v4/locales/is.d.cts +5 -0
  641. package/v4/locales/is.d.ts +4 -0
  642. package/v4/locales/is.js +114 -0
  643. package/v4/locales/it.cjs +140 -0
  644. package/v4/locales/it.d.cts +5 -0
  645. package/v4/locales/it.d.ts +4 -0
  646. package/v4/locales/it.js +113 -0
  647. package/v4/locales/ja.cjs +139 -0
  648. package/v4/locales/ja.d.cts +5 -0
  649. package/v4/locales/ja.d.ts +4 -0
  650. package/v4/locales/ja.js +112 -0
  651. package/v4/locales/ka.cjs +144 -0
  652. package/v4/locales/ka.d.cts +5 -0
  653. package/v4/locales/ka.d.ts +4 -0
  654. package/v4/locales/ka.js +117 -0
  655. package/v4/locales/kh.cjs +12 -0
  656. package/v4/locales/kh.d.cts +5 -0
  657. package/v4/locales/kh.d.ts +5 -0
  658. package/v4/locales/kh.js +5 -0
  659. package/v4/locales/km.cjs +142 -0
  660. package/v4/locales/km.d.cts +5 -0
  661. package/v4/locales/km.d.ts +4 -0
  662. package/v4/locales/km.js +115 -0
  663. package/v4/locales/kn.cjs +143 -0
  664. package/v4/locales/kn.d.cts +5 -0
  665. package/v4/locales/kn.d.ts +4 -0
  666. package/v4/locales/kn.js +116 -0
  667. package/v4/locales/ko.cjs +143 -0
  668. package/v4/locales/ko.d.cts +5 -0
  669. package/v4/locales/ko.d.ts +4 -0
  670. package/v4/locales/ko.js +116 -0
  671. package/v4/locales/lt.cjs +234 -0
  672. package/v4/locales/lt.d.cts +5 -0
  673. package/v4/locales/lt.d.ts +4 -0
  674. package/v4/locales/lt.js +207 -0
  675. package/v4/locales/mk.cjs +141 -0
  676. package/v4/locales/mk.d.cts +5 -0
  677. package/v4/locales/mk.d.ts +4 -0
  678. package/v4/locales/mk.js +114 -0
  679. package/v4/locales/ms.cjs +139 -0
  680. package/v4/locales/ms.d.cts +5 -0
  681. package/v4/locales/ms.d.ts +4 -0
  682. package/v4/locales/ms.js +112 -0
  683. package/v4/locales/ne.cjs +138 -0
  684. package/v4/locales/ne.d.cts +5 -0
  685. package/v4/locales/ne.d.ts +4 -0
  686. package/v4/locales/ne.js +111 -0
  687. package/v4/locales/nl.cjs +142 -0
  688. package/v4/locales/nl.d.cts +5 -0
  689. package/v4/locales/nl.d.ts +4 -0
  690. package/v4/locales/nl.js +115 -0
  691. package/v4/locales/nn.cjs +140 -0
  692. package/v4/locales/nn.d.cts +5 -0
  693. package/v4/locales/nn.d.ts +4 -0
  694. package/v4/locales/nn.js +113 -0
  695. package/v4/locales/no.cjs +140 -0
  696. package/v4/locales/no.d.cts +5 -0
  697. package/v4/locales/no.d.ts +4 -0
  698. package/v4/locales/no.js +113 -0
  699. package/v4/locales/ota.cjs +141 -0
  700. package/v4/locales/ota.d.cts +5 -0
  701. package/v4/locales/ota.d.ts +4 -0
  702. package/v4/locales/ota.js +114 -0
  703. package/v4/locales/pl.cjs +141 -0
  704. package/v4/locales/pl.d.cts +5 -0
  705. package/v4/locales/pl.d.ts +4 -0
  706. package/v4/locales/pl.js +114 -0
  707. package/v4/locales/ps.cjs +146 -0
  708. package/v4/locales/ps.d.cts +5 -0
  709. package/v4/locales/ps.d.ts +4 -0
  710. package/v4/locales/ps.js +119 -0
  711. package/v4/locales/pt-BR.cjs +170 -0
  712. package/v4/locales/pt-BR.d.cts +5 -0
  713. package/v4/locales/pt-BR.d.ts +4 -0
  714. package/v4/locales/pt-BR.js +143 -0
  715. package/v4/locales/pt.cjs +169 -0
  716. package/v4/locales/pt.d.cts +5 -0
  717. package/v4/locales/pt.d.ts +4 -0
  718. package/v4/locales/pt.js +142 -0
  719. package/v4/locales/ro.cjs +149 -0
  720. package/v4/locales/ro.d.cts +5 -0
  721. package/v4/locales/ro.d.ts +4 -0
  722. package/v4/locales/ro.js +122 -0
  723. package/v4/locales/ru.cjs +195 -0
  724. package/v4/locales/ru.d.cts +5 -0
  725. package/v4/locales/ru.d.ts +4 -0
  726. package/v4/locales/ru.js +168 -0
  727. package/v4/locales/sk.cjs +143 -0
  728. package/v4/locales/sk.d.cts +5 -0
  729. package/v4/locales/sk.d.ts +4 -0
  730. package/v4/locales/sk.js +116 -0
  731. package/v4/locales/sl.cjs +141 -0
  732. package/v4/locales/sl.d.cts +5 -0
  733. package/v4/locales/sl.d.ts +4 -0
  734. package/v4/locales/sl.js +114 -0
  735. package/v4/locales/sv.cjs +142 -0
  736. package/v4/locales/sv.d.cts +5 -0
  737. package/v4/locales/sv.d.ts +4 -0
  738. package/v4/locales/sv.js +115 -0
  739. package/v4/locales/ta.cjs +142 -0
  740. package/v4/locales/ta.d.cts +5 -0
  741. package/v4/locales/ta.d.ts +4 -0
  742. package/v4/locales/ta.js +115 -0
  743. package/v4/locales/tg.cjs +144 -0
  744. package/v4/locales/tg.d.cts +5 -0
  745. package/v4/locales/tg.d.ts +4 -0
  746. package/v4/locales/tg.js +117 -0
  747. package/v4/locales/th.cjs +142 -0
  748. package/v4/locales/th.d.cts +5 -0
  749. package/v4/locales/th.d.ts +4 -0
  750. package/v4/locales/th.js +115 -0
  751. package/v4/locales/tk.cjs +134 -0
  752. package/v4/locales/tk.d.cts +5 -0
  753. package/v4/locales/tk.d.ts +4 -0
  754. package/v4/locales/tk.js +107 -0
  755. package/v4/locales/tr.cjs +137 -0
  756. package/v4/locales/tr.d.cts +5 -0
  757. package/v4/locales/tr.d.ts +4 -0
  758. package/v4/locales/tr.js +110 -0
  759. package/v4/locales/ua.cjs +12 -0
  760. package/v4/locales/ua.d.cts +5 -0
  761. package/v4/locales/ua.d.ts +5 -0
  762. package/v4/locales/ua.js +5 -0
  763. package/v4/locales/uk.cjs +140 -0
  764. package/v4/locales/uk.d.cts +5 -0
  765. package/v4/locales/uk.d.ts +4 -0
  766. package/v4/locales/uk.js +113 -0
  767. package/v4/locales/ur.cjs +142 -0
  768. package/v4/locales/ur.d.cts +5 -0
  769. package/v4/locales/ur.d.ts +4 -0
  770. package/v4/locales/ur.js +115 -0
  771. package/v4/locales/uz.cjs +140 -0
  772. package/v4/locales/uz.d.cts +5 -0
  773. package/v4/locales/uz.d.ts +4 -0
  774. package/v4/locales/uz.js +113 -0
  775. package/v4/locales/vi.cjs +140 -0
  776. package/v4/locales/vi.d.cts +5 -0
  777. package/v4/locales/vi.d.ts +4 -0
  778. package/v4/locales/vi.js +113 -0
  779. package/v4/locales/yo.cjs +139 -0
  780. package/v4/locales/yo.d.cts +5 -0
  781. package/v4/locales/yo.d.ts +4 -0
  782. package/v4/locales/yo.js +112 -0
  783. package/v4/locales/zh-CN.cjs +141 -0
  784. package/v4/locales/zh-CN.d.cts +5 -0
  785. package/v4/locales/zh-CN.d.ts +4 -0
  786. package/v4/locales/zh-CN.js +114 -0
  787. package/v4/locales/zh-TW.cjs +139 -0
  788. package/v4/locales/zh-TW.d.cts +5 -0
  789. package/v4/locales/zh-TW.d.ts +4 -0
  790. package/v4/locales/zh-TW.js +112 -0
  791. package/v4/mini/checks.cjs +54 -0
  792. package/v4/mini/checks.d.cts +1 -0
  793. package/v4/mini/checks.d.ts +1 -0
  794. package/v4/mini/checks.js +1 -0
  795. package/v4/mini/coerce.cjs +71 -0
  796. package/v4/mini/coerce.d.cts +7 -0
  797. package/v4/mini/coerce.d.ts +7 -0
  798. package/v4/mini/coerce.js +22 -0
  799. package/v4/mini/deep-partial.cjs +58 -0
  800. package/v4/mini/deep-partial.d.cts +14 -0
  801. package/v4/mini/deep-partial.d.ts +14 -0
  802. package/v4/mini/deep-partial.js +13 -0
  803. package/v4/mini/external.cjs +95 -0
  804. package/v4/mini/external.d.cts +16 -0
  805. package/v4/mini/external.d.ts +16 -0
  806. package/v4/mini/external.js +16 -0
  807. package/v4/mini/in-out.cjs +82 -0
  808. package/v4/mini/in-out.d.cts +8 -0
  809. package/v4/mini/in-out.d.ts +8 -0
  810. package/v4/mini/in-out.js +36 -0
  811. package/v4/mini/index.cjs +51 -0
  812. package/v4/mini/index.d.cts +3 -0
  813. package/v4/mini/index.d.ts +3 -0
  814. package/v4/mini/index.js +3 -0
  815. package/v4/mini/iso.cjs +83 -0
  816. package/v4/mini/iso.d.cts +22 -0
  817. package/v4/mini/iso.d.ts +22 -0
  818. package/v4/mini/iso.js +34 -0
  819. package/v4/mini/parse.cjs +37 -0
  820. package/v4/mini/parse.d.cts +1 -0
  821. package/v4/mini/parse.d.ts +1 -0
  822. package/v4/mini/parse.js +1 -0
  823. package/v4/mini/schemas.cjs +1149 -0
  824. package/v4/mini/schemas.d.cts +480 -0
  825. package/v4/mini/schemas.d.ts +480 -0
  826. package/v4/mini/schemas.js +1004 -0
  827. package/v4-mini/index.cjs +51 -0
  828. package/v4-mini/index.d.cts +3 -0
  829. package/v4-mini/index.d.ts +3 -0
  830. package/v4-mini/index.js +3 -0
@@ -0,0 +1,1535 @@
1
+ import * as core from "../core/index.js";
2
+ import { util } from "../core/index.js";
3
+ import * as processors from "../core/json-schema-processors.js";
4
+ import * as regexes from "../core/regexes.js";
5
+ import { createStandardJSONSchemaMethod, createToJSONSchemaMethod } from "../core/to-json-schema.js";
6
+ import en from "../locales/en.js";
7
+ import * as checks from "./checks.js";
8
+ import * as parse from "./parse.js";
9
+ // Register English as the default locale on first YatspType construction. Hooked into the `YatspType` `$constructor` (rather than a top-level `config(en())` in `external.ts`) so bundlers honoring `sideEffects: false` can't tree-shake it out — see #5953, #5725. An explicit `z.config(z.locales.xx())` call wins regardless of order, since this only sets the default when none is present.
10
+ function _ensureDefaultLocale() {
11
+ if (!core.globalConfig.localeError)
12
+ core.config(en());
13
+ }
14
+ // the default memoizer is read by the core container init, which runs before `YatspType.init`, so each container calls this first
15
+ function _ensureDefaultMemoizer() {
16
+ if (!core.globalConfig.memoizer)
17
+ core.config({ memoizer: core.memoizer() });
18
+ }
19
+ export const YatspType = /*@__PURE__*/ core.$constructor("YatspType", (inst, def) => {
20
+ _ensureDefaultLocale();
21
+ core.$YatspType.init(inst, def);
22
+ inst.def = def;
23
+ inst.type = def.type;
24
+ return inst;
25
+ }, {
26
+ check(...chks) {
27
+ const def = this.def;
28
+ return this.clone(util.mergeDefs(def, {
29
+ checks: [
30
+ ...(def.checks ?? []),
31
+ ...chks.map((ch) => typeof ch === "function" ? { _yatsp: { check: ch, def: { check: "custom" }, onattach: [] } } : ch),
32
+ ],
33
+ }), { parent: true });
34
+ },
35
+ with(...chks) {
36
+ return this.check(...chks);
37
+ },
38
+ clone(def, params) {
39
+ return core.clone(this, def, params);
40
+ },
41
+ brand() {
42
+ return this;
43
+ },
44
+ register(reg, meta) {
45
+ reg.add(this, meta);
46
+ return this;
47
+ },
48
+ refine(check, params) {
49
+ return this.check(refine(check, params));
50
+ },
51
+ superRefine(refinement, params) {
52
+ return this.check(superRefine(refinement, params));
53
+ },
54
+ overwrite(fn) {
55
+ return this.check(checks.overwrite(fn));
56
+ },
57
+ optional() {
58
+ return optional(this);
59
+ },
60
+ exactOptional() {
61
+ return exactOptional(this);
62
+ },
63
+ nullable() {
64
+ return nullable(this);
65
+ },
66
+ nullish() {
67
+ return optional(nullable(this));
68
+ },
69
+ nonoptional(params) {
70
+ return nonoptional(this, params);
71
+ },
72
+ array() {
73
+ return array(this);
74
+ },
75
+ or(arg) {
76
+ return union([this, arg]);
77
+ },
78
+ and(arg) {
79
+ return intersection(this, arg);
80
+ },
81
+ transform(tx) {
82
+ return pipe(this, transform(tx));
83
+ },
84
+ default(d) {
85
+ return _default(this, d);
86
+ },
87
+ prefault(d) {
88
+ return prefault(this, d);
89
+ },
90
+ catch(params) {
91
+ return _catch(this, params);
92
+ },
93
+ pipe(target) {
94
+ return pipe(this, target);
95
+ },
96
+ readonly() {
97
+ return readonly(this);
98
+ },
99
+ describe(description) {
100
+ const cl = this.clone();
101
+ core.globalRegistry.add(cl, { description });
102
+ return cl;
103
+ },
104
+ meta(...args) {
105
+ // overloaded: meta() returns the registered metadata, meta(data) returns a clone with `data` registered. The mapped type picks up the second overload, so we accept variadic any-args and return `any` to satisfy both at runtime.
106
+ if (args.length === 0)
107
+ return core.globalRegistry.get(this);
108
+ const cl = this.clone();
109
+ core.globalRegistry.add(cl, args[0]);
110
+ return cl;
111
+ },
112
+ isOptional() {
113
+ return this.safeParse(undefined).success;
114
+ },
115
+ isNullable() {
116
+ return this.safeParse(null).success;
117
+ },
118
+ apply(fn, ...args) {
119
+ return args.length === 0 ? fn(this) : fn(this, ...args);
120
+ },
121
+ // Overrides core's `~standard` to add `jsonSchema`. Must stay a prototype entry: redefining it per instance demotes instances to dictionary mode.
122
+ get "~standard"() {
123
+ return util.hide(this, "~standard", {
124
+ ...core.standardProps(this),
125
+ jsonSchema: {
126
+ input: createStandardJSONSchemaMethod(this, "input"),
127
+ output: createStandardJSONSchemaMethod(this, "output"),
128
+ },
129
+ });
130
+ },
131
+ set "~standard"(value) {
132
+ util.own(this, "~standard", value);
133
+ },
134
+ parse: function _parse(data, params) {
135
+ return parse.parse(this, data, params, { callee: _parse });
136
+ },
137
+ parseAsync: async function _parseAsync(data, params) {
138
+ return await parse.parseAsync(this, data, params, { callee: _parseAsync });
139
+ },
140
+ safeParse(data, params) {
141
+ return parse.safeParse(this, data, params);
142
+ },
143
+ async safeParseAsync(data, params) {
144
+ return parse.safeParseAsync(this, data, params);
145
+ },
146
+ // `spa` is an alias: same function object as `safeParseAsync`, as before.
147
+ get spa() {
148
+ return this?.safeParseAsync;
149
+ },
150
+ set spa(value) {
151
+ util.own(this, "spa", value);
152
+ },
153
+ validate(data, params) {
154
+ return parse.validate(this, data, params);
155
+ },
156
+ validateAsync(data, params) {
157
+ return parse.validateAsync(this, data, params);
158
+ },
159
+ encode: function _encode(data, params) {
160
+ return parse.encode(this, data, params, { callee: _encode });
161
+ },
162
+ decode: function _decode(data, params) {
163
+ return parse.decode(this, data, params, { callee: _decode });
164
+ },
165
+ encodeAsync: async function _encodeAsync(data, params) {
166
+ return await parse.encodeAsync(this, data, params, { callee: _encodeAsync });
167
+ },
168
+ decodeAsync: async function _decodeAsync(data, params) {
169
+ return await parse.decodeAsync(this, data, params, { callee: _decodeAsync });
170
+ },
171
+ safeEncode(data, params) {
172
+ return parse.safeEncode(this, data, params);
173
+ },
174
+ safeDecode(data, params) {
175
+ return parse.safeDecode(this, data, params);
176
+ },
177
+ async safeEncodeAsync(data, params) {
178
+ return parse.safeEncodeAsync(this, data, params);
179
+ },
180
+ async safeDecodeAsync(data, params) {
181
+ return parse.safeDecodeAsync(this, data, params);
182
+ },
183
+ toJSONSchema(params) {
184
+ return createToJSONSchemaMethod(this, {})(params);
185
+ },
186
+ // Reads through to the registry on every access, so it must not cache.
187
+ get description() {
188
+ return core.globalRegistry.get(this)?.description;
189
+ },
190
+ // No setter: `schema._def = x` throws, as it did when `_def` was a non-writable own property.
191
+ get _def() {
192
+ return this._yatsp.def;
193
+ },
194
+ });
195
+ /** @internal */
196
+ export const _YatspString = /*@__PURE__*/ core.$constructor("_YatspString", (inst, def) => {
197
+ core.$YatspString.init(inst, def);
198
+ YatspType.init(inst, def);
199
+ inst._yatsp.processJSONSchema = (ctx, json, params) => processors.stringProcessor(inst, ctx, json, params);
200
+ },
201
+ /*@__PURE__*/ util.derived({
202
+ format: (inst) => processors.aggregateChecks(inst).format ?? null,
203
+ minLength: (inst) => processors.aggregateChecks(inst).minimum ?? null,
204
+ maxLength: (inst) => processors.aggregateChecks(inst).maximum ?? null,
205
+ }, {
206
+ regex(...args) {
207
+ return this.check(checks.regex(...args));
208
+ },
209
+ includes(...args) {
210
+ return this.check(checks.includes(...args));
211
+ },
212
+ startsWith(...args) {
213
+ return this.check(checks.startsWith(...args));
214
+ },
215
+ endsWith(...args) {
216
+ return this.check(checks.endsWith(...args));
217
+ },
218
+ min(...args) {
219
+ return this.check(checks.minLength(...args));
220
+ },
221
+ max(...args) {
222
+ return this.check(checks.maxLength(...args));
223
+ },
224
+ length(...args) {
225
+ return this.check(checks.length(...args));
226
+ },
227
+ nonempty(...args) {
228
+ return this.check(checks.minLength(1, ...args));
229
+ },
230
+ lowercase(params) {
231
+ return this.check(checks.lowercase(params));
232
+ },
233
+ uppercase(params) {
234
+ return this.check(checks.uppercase(params));
235
+ },
236
+ trim() {
237
+ return this.check(checks.trim());
238
+ },
239
+ normalize(...args) {
240
+ return this.check(checks.normalize(...args));
241
+ },
242
+ toLowerCase() {
243
+ return this.check(checks.toLowerCase());
244
+ },
245
+ toUpperCase() {
246
+ return this.check(checks.toUpperCase());
247
+ },
248
+ slugify() {
249
+ return this.check(checks.slugify());
250
+ },
251
+ }));
252
+ export const YatspString = /*@__PURE__*/ core.$constructor("YatspString", (inst, def) => {
253
+ core.$YatspString.init(inst, def);
254
+ _YatspString.init(inst, def);
255
+ }, {
256
+ email(params) {
257
+ return this.check(core._email(YatspEmail, params));
258
+ },
259
+ url(params) {
260
+ return this.check(core._url(YatspURL, params));
261
+ },
262
+ jwt(params) {
263
+ return this.check(core._jwt(YatspJWT, params));
264
+ },
265
+ emoji(params) {
266
+ return this.check(core._emoji(YatspEmoji, params));
267
+ },
268
+ guid(params) {
269
+ return this.check(core._guid(YatspGUID, params));
270
+ },
271
+ uuid(params) {
272
+ return this.check(core._uuid(YatspUUID, params));
273
+ },
274
+ uuidv4(params) {
275
+ return this.check(core._uuidv4(YatspUUID, params));
276
+ },
277
+ uuidv6(params) {
278
+ return this.check(core._uuidv6(YatspUUID, params));
279
+ },
280
+ uuidv7(params) {
281
+ return this.check(core._uuidv7(YatspUUID, params));
282
+ },
283
+ nanoid(params) {
284
+ return this.check(core._nanoid(YatspNanoID, params));
285
+ },
286
+ cuid(params) {
287
+ return this.check(core._cuid(YatspCUID, params));
288
+ },
289
+ cuid2(params) {
290
+ return this.check(core._cuid2(YatspCUID2, params));
291
+ },
292
+ ulid(params) {
293
+ return this.check(core._ulid(YatspULID, params));
294
+ },
295
+ base64(params) {
296
+ return this.check(core._base64(YatspBase64, params));
297
+ },
298
+ base64url(params) {
299
+ return this.check(core._base64url(YatspBase64URL, params));
300
+ },
301
+ xid(params) {
302
+ return this.check(core._xid(YatspXID, params));
303
+ },
304
+ ksuid(params) {
305
+ return this.check(core._ksuid(YatspKSUID, params));
306
+ },
307
+ ipv4(params) {
308
+ return this.check(core._ipv4(YatspIPv4, params));
309
+ },
310
+ ipv6(params) {
311
+ return this.check(core._ipv6(YatspIPv6, params));
312
+ },
313
+ cidrv4(params) {
314
+ return this.check(core._cidrv4(YatspCIDRv4, params));
315
+ },
316
+ cidrv6(params) {
317
+ return this.check(core._cidrv6(YatspCIDRv6, params));
318
+ },
319
+ e164(params) {
320
+ return this.check(core._e164(YatspE164, params));
321
+ },
322
+ datetime(params) {
323
+ return this.check(core._isoDateTime(YatspISODateTime, params));
324
+ },
325
+ date(params) {
326
+ return this.check(core._isoDate(YatspISODate, params));
327
+ },
328
+ time(params) {
329
+ return this.check(core._isoTime(YatspISOTime, params));
330
+ },
331
+ duration(params) {
332
+ return this.check(core._isoDuration(YatspISODuration, params));
333
+ },
334
+ });
335
+ export function string(params) {
336
+ return core._string(YatspString, params);
337
+ }
338
+ export const YatspStringFormat = /*@__PURE__*/ core.$constructor("YatspStringFormat", (inst, def) => {
339
+ core.$YatspStringFormat.init(inst, def);
340
+ _YatspString.init(inst, def);
341
+ });
342
+ export const YatspISODateTime = /*@__PURE__*/ core.$constructor("YatspISODateTime", (inst, def) => {
343
+ core.$YatspISODateTime.init(inst, def);
344
+ YatspStringFormat.init(inst, def);
345
+ });
346
+ export const YatspISODate = /*@__PURE__*/ core.$constructor("YatspISODate", (inst, def) => {
347
+ core.$YatspISODate.init(inst, def);
348
+ YatspStringFormat.init(inst, def);
349
+ });
350
+ export const YatspISOTime = /*@__PURE__*/ core.$constructor("YatspISOTime", (inst, def) => {
351
+ core.$YatspISOTime.init(inst, def);
352
+ YatspStringFormat.init(inst, def);
353
+ });
354
+ export const YatspISODuration = /*@__PURE__*/ core.$constructor("YatspISODuration", (inst, def) => {
355
+ core.$YatspISODuration.init(inst, def);
356
+ YatspStringFormat.init(inst, def);
357
+ });
358
+ export const YatspEmail = /*@__PURE__*/ core.$constructor("YatspEmail", (inst, def) => {
359
+ // YatspStringFormat.init(inst, def);
360
+ core.$YatspEmail.init(inst, def);
361
+ YatspStringFormat.init(inst, def);
362
+ });
363
+ export function email(params) {
364
+ return core._email(YatspEmail, params);
365
+ }
366
+ export const YatspGUID = /*@__PURE__*/ core.$constructor("YatspGUID", (inst, def) => {
367
+ // YatspStringFormat.init(inst, def);
368
+ core.$YatspGUID.init(inst, def);
369
+ YatspStringFormat.init(inst, def);
370
+ });
371
+ export function guid(params) {
372
+ return core._guid(YatspGUID, params);
373
+ }
374
+ export const YatspUUID = /*@__PURE__*/ core.$constructor("YatspUUID", (inst, def) => {
375
+ // YatspStringFormat.init(inst, def);
376
+ core.$YatspUUID.init(inst, def);
377
+ YatspStringFormat.init(inst, def);
378
+ });
379
+ export function uuid(params) {
380
+ return core._uuid(YatspUUID, params);
381
+ }
382
+ export function uuidv4(params) {
383
+ return core._uuidv4(YatspUUID, params);
384
+ }
385
+ // YatspUUIDv6
386
+ export function uuidv6(params) {
387
+ return core._uuidv6(YatspUUID, params);
388
+ }
389
+ // YatspUUIDv7
390
+ export function uuidv7(params) {
391
+ return core._uuidv7(YatspUUID, params);
392
+ }
393
+ export const YatspURL = /*@__PURE__*/ core.$constructor("YatspURL", (inst, def) => {
394
+ // YatspStringFormat.init(inst, def);
395
+ core.$YatspURL.init(inst, def);
396
+ YatspStringFormat.init(inst, def);
397
+ });
398
+ export function url(params) {
399
+ return core._url(YatspURL, params);
400
+ }
401
+ export function httpUrl(params) {
402
+ return core._url(YatspURL, {
403
+ protocol: regexes.httpProtocol,
404
+ hostname: regexes.domain,
405
+ ...util.normalizeParams(params),
406
+ });
407
+ }
408
+ export const YatspEmoji = /*@__PURE__*/ core.$constructor("YatspEmoji", (inst, def) => {
409
+ // YatspStringFormat.init(inst, def);
410
+ core.$YatspEmoji.init(inst, def);
411
+ YatspStringFormat.init(inst, def);
412
+ });
413
+ export function emoji(params) {
414
+ return core._emoji(YatspEmoji, params);
415
+ }
416
+ export const YatspNanoID = /*@__PURE__*/ core.$constructor("YatspNanoID", (inst, def) => {
417
+ // YatspStringFormat.init(inst, def);
418
+ core.$YatspNanoID.init(inst, def);
419
+ YatspStringFormat.init(inst, def);
420
+ });
421
+ export function nanoid(params) {
422
+ return core._nanoid(YatspNanoID, params);
423
+ }
424
+ /**
425
+ * @deprecated CUID v1 is deprecated by its authors due to information leakage
426
+ * (timestamps embedded in the id). Use {@link YatspCUID2} instead.
427
+ * See https://github.com/paralleldrive/cuid.
428
+ */
429
+ export const YatspCUID = /*@__PURE__*/ core.$constructor("YatspCUID", (inst, def) => {
430
+ // YatspStringFormat.init(inst, def);
431
+ core.$YatspCUID.init(inst, def);
432
+ YatspStringFormat.init(inst, def);
433
+ });
434
+ /**
435
+ * Validates a CUID v1 string.
436
+ *
437
+ * @deprecated CUID v1 is deprecated by its authors due to information leakage
438
+ * (timestamps embedded in the id). Use {@link cuid2 | `z.cuid2()`} instead.
439
+ * See https://github.com/paralleldrive/cuid.
440
+ */
441
+ export function cuid(params) {
442
+ return core._cuid(YatspCUID, params);
443
+ }
444
+ export const YatspCUID2 = /*@__PURE__*/ core.$constructor("YatspCUID2", (inst, def) => {
445
+ // YatspStringFormat.init(inst, def);
446
+ core.$YatspCUID2.init(inst, def);
447
+ YatspStringFormat.init(inst, def);
448
+ });
449
+ export function cuid2(params) {
450
+ return core._cuid2(YatspCUID2, params);
451
+ }
452
+ export const YatspULID = /*@__PURE__*/ core.$constructor("YatspULID", (inst, def) => {
453
+ // YatspStringFormat.init(inst, def);
454
+ core.$YatspULID.init(inst, def);
455
+ YatspStringFormat.init(inst, def);
456
+ });
457
+ export function ulid(params) {
458
+ return core._ulid(YatspULID, params);
459
+ }
460
+ export const YatspXID = /*@__PURE__*/ core.$constructor("YatspXID", (inst, def) => {
461
+ // YatspStringFormat.init(inst, def);
462
+ core.$YatspXID.init(inst, def);
463
+ YatspStringFormat.init(inst, def);
464
+ });
465
+ export function xid(params) {
466
+ return core._xid(YatspXID, params);
467
+ }
468
+ export const YatspKSUID = /*@__PURE__*/ core.$constructor("YatspKSUID", (inst, def) => {
469
+ // YatspStringFormat.init(inst, def);
470
+ core.$YatspKSUID.init(inst, def);
471
+ YatspStringFormat.init(inst, def);
472
+ });
473
+ export function ksuid(params) {
474
+ return core._ksuid(YatspKSUID, params);
475
+ }
476
+ export const YatspIPv4 = /*@__PURE__*/ core.$constructor("YatspIPv4", (inst, def) => {
477
+ // YatspStringFormat.init(inst, def);
478
+ core.$YatspIPv4.init(inst, def);
479
+ YatspStringFormat.init(inst, def);
480
+ });
481
+ export function ipv4(params) {
482
+ return core._ipv4(YatspIPv4, params);
483
+ }
484
+ export const YatspMAC = /*@__PURE__*/ core.$constructor("YatspMAC", (inst, def) => {
485
+ // YatspStringFormat.init(inst, def);
486
+ core.$YatspMAC.init(inst, def);
487
+ YatspStringFormat.init(inst, def);
488
+ });
489
+ export function mac(params) {
490
+ return core._mac(YatspMAC, params);
491
+ }
492
+ export const YatspIPv6 = /*@__PURE__*/ core.$constructor("YatspIPv6", (inst, def) => {
493
+ // YatspStringFormat.init(inst, def);
494
+ core.$YatspIPv6.init(inst, def);
495
+ YatspStringFormat.init(inst, def);
496
+ });
497
+ export function ipv6(params) {
498
+ return core._ipv6(YatspIPv6, params);
499
+ }
500
+ export const YatspCIDRv4 = /*@__PURE__*/ core.$constructor("YatspCIDRv4", (inst, def) => {
501
+ core.$YatspCIDRv4.init(inst, def);
502
+ YatspStringFormat.init(inst, def);
503
+ });
504
+ export function cidrv4(params) {
505
+ return core._cidrv4(YatspCIDRv4, params);
506
+ }
507
+ export const YatspCIDRv6 = /*@__PURE__*/ core.$constructor("YatspCIDRv6", (inst, def) => {
508
+ core.$YatspCIDRv6.init(inst, def);
509
+ YatspStringFormat.init(inst, def);
510
+ });
511
+ export function cidrv6(params) {
512
+ return core._cidrv6(YatspCIDRv6, params);
513
+ }
514
+ export const YatspBase64 = /*@__PURE__*/ core.$constructor("YatspBase64", (inst, def) => {
515
+ // YatspStringFormat.init(inst, def);
516
+ core.$YatspBase64.init(inst, def);
517
+ YatspStringFormat.init(inst, def);
518
+ });
519
+ export function base64(params) {
520
+ return core._base64(YatspBase64, params);
521
+ }
522
+ export const YatspBase64URL = /*@__PURE__*/ core.$constructor("YatspBase64URL", (inst, def) => {
523
+ // YatspStringFormat.init(inst, def);
524
+ core.$YatspBase64URL.init(inst, def);
525
+ YatspStringFormat.init(inst, def);
526
+ });
527
+ export function base64url(params) {
528
+ return core._base64url(YatspBase64URL, params);
529
+ }
530
+ export const YatspE164 = /*@__PURE__*/ core.$constructor("YatspE164", (inst, def) => {
531
+ // YatspStringFormat.init(inst, def);
532
+ core.$YatspE164.init(inst, def);
533
+ YatspStringFormat.init(inst, def);
534
+ });
535
+ export function e164(params) {
536
+ return core._e164(YatspE164, params);
537
+ }
538
+ export const YatspCreditCard = /*@__PURE__*/ core.$constructor("YatspCreditCard", (inst, def) => {
539
+ core.$YatspCreditCard.init(inst, def);
540
+ YatspStringFormat.init(inst, def);
541
+ });
542
+ export function creditCard(params) {
543
+ return core._creditCard(YatspCreditCard, params);
544
+ }
545
+ export const YatspIBAN = /*@__PURE__*/ core.$constructor("YatspIBAN", (inst, def) => {
546
+ core.$YatspIBAN.init(inst, def);
547
+ YatspStringFormat.init(inst, def);
548
+ });
549
+ export function iban(params) {
550
+ return core._iban(YatspIBAN, params);
551
+ }
552
+ export const YatspJWT = /*@__PURE__*/ core.$constructor("YatspJWT", (inst, def) => {
553
+ // YatspStringFormat.init(inst, def);
554
+ core.$YatspJWT.init(inst, def);
555
+ YatspStringFormat.init(inst, def);
556
+ });
557
+ export function jwt(params) {
558
+ return core._jwt(YatspJWT, params);
559
+ }
560
+ export const YatspCustomStringFormat = /*@__PURE__*/ core.$constructor("YatspCustomStringFormat", (inst, def) => {
561
+ // YatspStringFormat.init(inst, def);
562
+ core.$YatspCustomStringFormat.init(inst, def);
563
+ YatspStringFormat.init(inst, def);
564
+ });
565
+ export function stringFormat(format, fnOrRegex, _params = {}) {
566
+ return core._stringFormat(YatspCustomStringFormat, format, fnOrRegex, _params);
567
+ }
568
+ export function hostname(_params) {
569
+ return core._stringFormat(YatspCustomStringFormat, "hostname", regexes.hostname, _params);
570
+ }
571
+ export function hex(_params) {
572
+ return core._stringFormat(YatspCustomStringFormat, "hex", regexes.hex, _params);
573
+ }
574
+ export function currencyCode(_params) {
575
+ return core._stringFormat(YatspCustomStringFormat, "currency_code", regexes.currencyCode, _params);
576
+ }
577
+ export function hash(alg, params) {
578
+ const enc = params?.enc ?? "hex";
579
+ const format = `${alg}_${enc}`;
580
+ const regex = core.regexes[format];
581
+ if (!regex)
582
+ throw new Error(`Unrecognized hash format: ${format}`);
583
+ return core._stringFormat(YatspCustomStringFormat, format, regex, params);
584
+ }
585
+ export const YatspNumber = /*@__PURE__*/ core.$constructor("YatspNumber", (inst, def) => {
586
+ core.$YatspNumber.init(inst, def);
587
+ YatspType.init(inst, def);
588
+ inst._yatsp.processJSONSchema = (ctx, json, params) => processors.numberProcessor(inst, ctx, json, params);
589
+ inst.isFinite = true;
590
+ },
591
+ /*@__PURE__*/ util.derived({
592
+ minValue: (inst) => {
593
+ const { minimum, exclusiveMinimum } = processors.aggregateChecks(inst);
594
+ return Math.max(minimum ?? Number.NEGATIVE_INFINITY, exclusiveMinimum ?? Number.NEGATIVE_INFINITY);
595
+ },
596
+ maxValue: (inst) => {
597
+ const { maximum, exclusiveMaximum } = processors.aggregateChecks(inst);
598
+ return Math.min(maximum ?? Number.POSITIVE_INFINITY, exclusiveMaximum ?? Number.POSITIVE_INFINITY);
599
+ },
600
+ isInt: (inst) => {
601
+ const { isInt, multipleOf } = processors.aggregateChecks(inst);
602
+ return !!isInt || !!multipleOf?.some(Number.isSafeInteger);
603
+ },
604
+ format: (inst) => processors.aggregateChecks(inst).format ?? null,
605
+ }, {
606
+ gt(value, params) {
607
+ return this.check(checks.gt(value, params));
608
+ },
609
+ gte(value, params) {
610
+ return this.check(checks.gte(value, params));
611
+ },
612
+ min(value, params) {
613
+ return this.check(checks.gte(value, params));
614
+ },
615
+ lt(value, params) {
616
+ return this.check(checks.lt(value, params));
617
+ },
618
+ lte(value, params) {
619
+ return this.check(checks.lte(value, params));
620
+ },
621
+ max(value, params) {
622
+ return this.check(checks.lte(value, params));
623
+ },
624
+ int(params) {
625
+ return this.check(int(params));
626
+ },
627
+ safe(params) {
628
+ return this.check(int(params));
629
+ },
630
+ positive(params) {
631
+ return this.check(checks.gt(0, params));
632
+ },
633
+ nonnegative(params) {
634
+ return this.check(checks.gte(0, params));
635
+ },
636
+ negative(params) {
637
+ return this.check(checks.lt(0, params));
638
+ },
639
+ nonpositive(params) {
640
+ return this.check(checks.lte(0, params));
641
+ },
642
+ multipleOf(value, params) {
643
+ return this.check(checks.multipleOf(value, params));
644
+ },
645
+ step(value, params) {
646
+ return this.check(checks.multipleOf(value, params));
647
+ },
648
+ finite() {
649
+ return this;
650
+ },
651
+ }));
652
+ export function number(params) {
653
+ return core._number(YatspNumber, params);
654
+ }
655
+ export const YatspNumberFormat = /*@__PURE__*/ core.$constructor("YatspNumberFormat", (inst, def) => {
656
+ core.$YatspNumberFormat.init(inst, def);
657
+ YatspNumber.init(inst, def);
658
+ });
659
+ export function int(params) {
660
+ return core._int(YatspNumberFormat, params);
661
+ }
662
+ export function float32(params) {
663
+ return core._float32(YatspNumberFormat, params);
664
+ }
665
+ export function float64(params) {
666
+ return core._float64(YatspNumberFormat, params);
667
+ }
668
+ export function int32(params) {
669
+ return core._int32(YatspNumberFormat, params);
670
+ }
671
+ export function uint32(params) {
672
+ return core._uint32(YatspNumberFormat, params);
673
+ }
674
+ export const YatspBoolean = /*@__PURE__*/ core.$constructor("YatspBoolean", (inst, def) => {
675
+ core.$YatspBoolean.init(inst, def);
676
+ YatspType.init(inst, def);
677
+ inst._yatsp.processJSONSchema = (ctx, json, params) => processors.booleanProcessor(inst, ctx, json, params);
678
+ });
679
+ export function boolean(params) {
680
+ return core._boolean(YatspBoolean, params);
681
+ }
682
+ export const YatspBigInt = /*@__PURE__*/ core.$constructor("YatspBigInt", (inst, def) => {
683
+ core.$YatspBigInt.init(inst, def);
684
+ YatspType.init(inst, def);
685
+ inst._yatsp.processJSONSchema = (ctx, json, params) => processors.bigintProcessor(inst, ctx, json, params);
686
+ },
687
+ /*@__PURE__*/ util.derived({
688
+ minValue: (inst) => processors.aggregateChecks(inst).minimum ?? null,
689
+ maxValue: (inst) => processors.aggregateChecks(inst).maximum ?? null,
690
+ format: (inst) => processors.aggregateChecks(inst).format ?? null,
691
+ }, {
692
+ gte(value, params) {
693
+ return this.check(checks.gte(value, params));
694
+ },
695
+ min(value, params) {
696
+ return this.check(checks.gte(value, params));
697
+ },
698
+ gt(value, params) {
699
+ return this.check(checks.gt(value, params));
700
+ },
701
+ lt(value, params) {
702
+ return this.check(checks.lt(value, params));
703
+ },
704
+ lte(value, params) {
705
+ return this.check(checks.lte(value, params));
706
+ },
707
+ max(value, params) {
708
+ return this.check(checks.lte(value, params));
709
+ },
710
+ positive(params) {
711
+ return this.check(checks.gt(BigInt(0), params));
712
+ },
713
+ negative(params) {
714
+ return this.check(checks.lt(BigInt(0), params));
715
+ },
716
+ nonpositive(params) {
717
+ return this.check(checks.lte(BigInt(0), params));
718
+ },
719
+ nonnegative(params) {
720
+ return this.check(checks.gte(BigInt(0), params));
721
+ },
722
+ multipleOf(value, params) {
723
+ return this.check(checks.multipleOf(value, params));
724
+ },
725
+ }));
726
+ export function bigint(params) {
727
+ return core._bigint(YatspBigInt, params);
728
+ }
729
+ export const YatspBigIntFormat = /*@__PURE__*/ core.$constructor("YatspBigIntFormat", (inst, def) => {
730
+ core.$YatspBigIntFormat.init(inst, def);
731
+ YatspBigInt.init(inst, def);
732
+ });
733
+ export function int64(params) {
734
+ return core._int64(YatspBigIntFormat, params);
735
+ }
736
+ export function uint64(params) {
737
+ return core._uint64(YatspBigIntFormat, params);
738
+ }
739
+ export const YatspSymbol = /*@__PURE__*/ core.$constructor("YatspSymbol", (inst, def) => {
740
+ core.$YatspSymbol.init(inst, def);
741
+ YatspType.init(inst, def);
742
+ inst._yatsp.processJSONSchema = (ctx, json, params) => processors.symbolProcessor(inst, ctx, json, params);
743
+ });
744
+ export function symbol(params) {
745
+ return core._symbol(YatspSymbol, params);
746
+ }
747
+ export const YatspUndefined = /*@__PURE__*/ core.$constructor("YatspUndefined", (inst, def) => {
748
+ core.$YatspUndefined.init(inst, def);
749
+ YatspType.init(inst, def);
750
+ inst._yatsp.processJSONSchema = (ctx, json, params) => processors.undefinedProcessor(inst, ctx, json, params);
751
+ });
752
+ function _undefined(params) {
753
+ return core._undefined(YatspUndefined, params);
754
+ }
755
+ export { _undefined as undefined };
756
+ export const YatspNull = /*@__PURE__*/ core.$constructor("YatspNull", (inst, def) => {
757
+ core.$YatspNull.init(inst, def);
758
+ YatspType.init(inst, def);
759
+ inst._yatsp.processJSONSchema = (ctx, json, params) => processors.nullProcessor(inst, ctx, json, params);
760
+ });
761
+ function _null(params) {
762
+ return core._null(YatspNull, params);
763
+ }
764
+ export { _null as null };
765
+ export const YatspAny = /*@__PURE__*/ core.$constructor("YatspAny", (inst, def) => {
766
+ core.$YatspAny.init(inst, def);
767
+ YatspType.init(inst, def);
768
+ inst._yatsp.processJSONSchema = (ctx, json, params) => processors.anyProcessor(inst, ctx, json, params);
769
+ });
770
+ export function any() {
771
+ return core._any(YatspAny);
772
+ }
773
+ export const YatspUnknown = /*@__PURE__*/ core.$constructor("YatspUnknown", (inst, def) => {
774
+ core.$YatspUnknown.init(inst, def);
775
+ YatspType.init(inst, def);
776
+ inst._yatsp.processJSONSchema = (ctx, json, params) => processors.unknownProcessor(inst, ctx, json, params);
777
+ });
778
+ export function unknown() {
779
+ return core._unknown(YatspUnknown);
780
+ }
781
+ export const YatspNever = /*@__PURE__*/ core.$constructor("YatspNever", (inst, def) => {
782
+ core.$YatspNever.init(inst, def);
783
+ YatspType.init(inst, def);
784
+ inst._yatsp.processJSONSchema = (ctx, json, params) => processors.neverProcessor(inst, ctx, json, params);
785
+ });
786
+ export function never(params) {
787
+ return core._never(YatspNever, params);
788
+ }
789
+ export const YatspVoid = /*@__PURE__*/ core.$constructor("YatspVoid", (inst, def) => {
790
+ core.$YatspVoid.init(inst, def);
791
+ YatspType.init(inst, def);
792
+ inst._yatsp.processJSONSchema = (ctx, json, params) => processors.voidProcessor(inst, ctx, json, params);
793
+ });
794
+ function _void(params) {
795
+ return core._void(YatspVoid, params);
796
+ }
797
+ export { _void as void };
798
+ export const YatspDate = /*@__PURE__*/ core.$constructor("YatspDate", (inst, def) => {
799
+ core.$YatspDate.init(inst, def);
800
+ YatspType.init(inst, def);
801
+ inst._yatsp.processJSONSchema = (ctx, json, params) => processors.dateProcessor(inst, ctx, json, params);
802
+ inst.min = (value, params) => inst.check(checks.gte(value, params));
803
+ inst.max = (value, params) => inst.check(checks.lte(value, params));
804
+ },
805
+ /*@__PURE__*/ util.derived({
806
+ minDate: (inst) => {
807
+ const { minimum } = processors.aggregateChecks(inst);
808
+ return minimum ? new Date(minimum) : null;
809
+ },
810
+ maxDate: (inst) => {
811
+ const { maximum } = processors.aggregateChecks(inst);
812
+ return maximum ? new Date(maximum) : null;
813
+ },
814
+ }, {}));
815
+ export function date(params) {
816
+ return core._date(YatspDate, params);
817
+ }
818
+ export const YatspArray = /*@__PURE__*/ core.$constructor("YatspArray", (inst, def) => {
819
+ _ensureDefaultMemoizer();
820
+ core.$YatspArray.init(inst, def);
821
+ YatspType.init(inst, def);
822
+ inst._yatsp.processJSONSchema = (ctx, json, params) => processors.arrayProcessor(inst, ctx, json, params);
823
+ inst.element = def.element;
824
+ }, {
825
+ min(n, params) {
826
+ return this.check(checks.minLength(n, params));
827
+ },
828
+ nonempty(params) {
829
+ return this.check(checks.minLength(1, params));
830
+ },
831
+ max(n, params) {
832
+ return this.check(checks.maxLength(n, params));
833
+ },
834
+ length(n, params) {
835
+ return this.check(checks.length(n, params));
836
+ },
837
+ unwrap() {
838
+ return this.element;
839
+ },
840
+ });
841
+ export function array(element, params) {
842
+ return core._array(YatspArray, element, params);
843
+ }
844
+ // .keyof
845
+ export function keyof(schema) {
846
+ const shape = schema._yatsp.def.shape;
847
+ return _enum(Object.keys(shape));
848
+ }
849
+ export const YatspObject = /*@__PURE__*/ core.$constructor("YatspObject", (inst, def) => {
850
+ _ensureDefaultMemoizer();
851
+ core.$YatspObjectJIT.init(inst, def);
852
+ YatspType.init(inst, def);
853
+ inst._yatsp.processJSONSchema = (ctx, json, params) => processors.objectProcessor(inst, ctx, json, params);
854
+ util.installLazyProp(inst, "shape", (self) => self._yatsp.def.shape, false);
855
+ }, {
856
+ keyof() {
857
+ return _enum(Object.keys(this._yatsp.def.shape));
858
+ },
859
+ catchall(catchall) {
860
+ // `mergeDefs` rather than a spread: spreading reads `shape`, and resolving it can mint a whole fresh subtree
861
+ return this.clone(util.mergeDefs(this._yatsp.def, { catchall: catchall }));
862
+ },
863
+ passthrough() {
864
+ return this.clone(util.mergeDefs(this._yatsp.def, { catchall: unknown() }));
865
+ },
866
+ loose() {
867
+ return this.clone(util.mergeDefs(this._yatsp.def, { catchall: unknown() }));
868
+ },
869
+ strict() {
870
+ return this.clone(util.mergeDefs(this._yatsp.def, { catchall: never() }));
871
+ },
872
+ strip() {
873
+ return this.clone(util.mergeDefs(this._yatsp.def, { catchall: undefined }));
874
+ },
875
+ extend(incoming) {
876
+ return util.extend(this, incoming);
877
+ },
878
+ safeExtend(incoming) {
879
+ return util.safeExtend(this, incoming);
880
+ },
881
+ merge(other) {
882
+ return util.merge(this, other);
883
+ },
884
+ pick(mask) {
885
+ return util.pick(this, mask);
886
+ },
887
+ omit(mask) {
888
+ return util.omit(this, mask);
889
+ },
890
+ partial(...args) {
891
+ return util.partial(YatspOptional, this, args[0]);
892
+ },
893
+ exactPartial(...args) {
894
+ return util.partial(YatspExactOptional, this, args[0], "exactPartial");
895
+ },
896
+ required(...args) {
897
+ return util.required(YatspNonOptional, this, args[0]);
898
+ },
899
+ });
900
+ export function object(shape, params) {
901
+ const def = {
902
+ type: "object",
903
+ shape: shape ?? {},
904
+ ...util.normalizeParams(params),
905
+ };
906
+ return new YatspObject(def);
907
+ }
908
+ // strictObject
909
+ export function strictObject(shape, params) {
910
+ return new YatspObject({
911
+ type: "object",
912
+ shape,
913
+ catchall: never(),
914
+ ...util.normalizeParams(params),
915
+ });
916
+ }
917
+ // looseObject
918
+ export function looseObject(shape, params) {
919
+ return new YatspObject({
920
+ type: "object",
921
+ shape,
922
+ catchall: unknown(),
923
+ ...util.normalizeParams(params),
924
+ });
925
+ }
926
+ export const YatspUnion = /*@__PURE__*/ core.$constructor("YatspUnion", (inst, def) => {
927
+ core.$YatspUnion.init(inst, def);
928
+ YatspType.init(inst, def);
929
+ inst._yatsp.processJSONSchema = (ctx, json, params) => processors.unionProcessor(inst, ctx, json, params);
930
+ inst.options = def.options;
931
+ });
932
+ export function union(options, params) {
933
+ return new YatspUnion({
934
+ type: "union",
935
+ options: options,
936
+ ...util.normalizeParams(params),
937
+ });
938
+ }
939
+ export const YatspXor = /*@__PURE__*/ core.$constructor("YatspXor", (inst, def) => {
940
+ YatspUnion.init(inst, def);
941
+ core.$YatspXor.init(inst, def);
942
+ inst._yatsp.processJSONSchema = (ctx, json, params) => processors.unionProcessor(inst, ctx, json, params);
943
+ inst.options = def.options;
944
+ });
945
+ /** Creates an exclusive union (XOR) where exactly one option must match.
946
+ * Unlike regular unions that succeed when any option matches, xor fails if
947
+ * zero or more than one option matches the input. */
948
+ export function xor(options, params) {
949
+ return new YatspXor({
950
+ type: "union",
951
+ options: options,
952
+ inclusive: false,
953
+ ...util.normalizeParams(params),
954
+ });
955
+ }
956
+ export const YatspDiscriminatedUnion = /*@__PURE__*/ core.$constructor("YatspDiscriminatedUnion", (inst, def) => {
957
+ YatspUnion.init(inst, def);
958
+ core.$YatspDiscriminatedUnion.init(inst, def);
959
+ });
960
+ export function discriminatedUnion(discriminator, options, params) {
961
+ // const [options, params] = args;
962
+ return new YatspDiscriminatedUnion({
963
+ type: "union",
964
+ options: options,
965
+ discriminator,
966
+ ...util.normalizeParams(params),
967
+ });
968
+ }
969
+ export const YatspIntersection = /*@__PURE__*/ core.$constructor("YatspIntersection", (inst, def) => {
970
+ core.$YatspIntersection.init(inst, def);
971
+ YatspType.init(inst, def);
972
+ inst._yatsp.processJSONSchema = (ctx, json, params) => processors.intersectionProcessor(inst, ctx, json, params);
973
+ });
974
+ export function intersection(left, right) {
975
+ return new YatspIntersection({
976
+ type: "intersection",
977
+ left: left,
978
+ right: right,
979
+ });
980
+ }
981
+ export const YatspTuple = /*@__PURE__*/ core.$constructor("YatspTuple", (inst, def) => {
982
+ _ensureDefaultMemoizer();
983
+ core.$YatspTuple.init(inst, def);
984
+ YatspType.init(inst, def);
985
+ inst._yatsp.processJSONSchema = (ctx, json, params) => processors.tupleProcessor(inst, ctx, json, params);
986
+ }, {
987
+ rest(rest) {
988
+ return this.clone({
989
+ ...this._yatsp.def,
990
+ rest: rest,
991
+ });
992
+ },
993
+ partial() {
994
+ const def = this._yatsp.def;
995
+ // a refinement was authored against the full arity; partialing would run it on a shorter array
996
+ if (def.checks?.length)
997
+ throw new Error(".partial() cannot be used on tuple schemas containing refinements");
998
+ return this.clone({
999
+ ...def,
1000
+ items: def.items.map((item) => new YatspOptional({ type: "optional", innerType: item })),
1001
+ });
1002
+ },
1003
+ });
1004
+ export function tuple(items, _paramsOrRest, _params) {
1005
+ const hasRest = _paramsOrRest instanceof core.$YatspType;
1006
+ const params = hasRest ? _params : _paramsOrRest;
1007
+ const rest = hasRest ? _paramsOrRest : null;
1008
+ return new YatspTuple({
1009
+ type: "tuple",
1010
+ items: items,
1011
+ rest,
1012
+ ...util.normalizeParams(params),
1013
+ });
1014
+ }
1015
+ export const YatspRecord = /*@__PURE__*/ core.$constructor("YatspRecord", (inst, def) => {
1016
+ _ensureDefaultMemoizer();
1017
+ core.$YatspRecord.init(inst, def);
1018
+ YatspType.init(inst, def);
1019
+ inst._yatsp.processJSONSchema = (ctx, json, params) => processors.recordProcessor(inst, ctx, json, params);
1020
+ inst.keyType = def.keyType;
1021
+ inst.valueType = def.valueType;
1022
+ });
1023
+ export function record(keyType, valueType, params) {
1024
+ // v3-compat: z.record(valueType, params?) — defaults keyType to z.string()
1025
+ if (!valueType || !valueType._yatsp) {
1026
+ return new YatspRecord({
1027
+ type: "record",
1028
+ keyType: string(),
1029
+ valueType: keyType,
1030
+ ...util.normalizeParams(valueType),
1031
+ });
1032
+ }
1033
+ return new YatspRecord({
1034
+ type: "record",
1035
+ keyType,
1036
+ valueType: valueType,
1037
+ ...util.normalizeParams(params),
1038
+ });
1039
+ }
1040
+ // type alksjf = core.output<core.$YatspRecordKey>;
1041
+ export function partialRecord(keyType, valueType, params) {
1042
+ return new YatspRecord({
1043
+ type: "record",
1044
+ keyType,
1045
+ valueType: valueType,
1046
+ ...util.normalizeParams(params),
1047
+ partial: true,
1048
+ });
1049
+ }
1050
+ export function looseRecord(keyType, valueType, params) {
1051
+ return new YatspRecord({
1052
+ type: "record",
1053
+ keyType,
1054
+ valueType: valueType,
1055
+ mode: "loose",
1056
+ ...util.normalizeParams(params),
1057
+ });
1058
+ }
1059
+ export const YatspMap = /*@__PURE__*/ core.$constructor("YatspMap", (inst, def) => {
1060
+ _ensureDefaultMemoizer();
1061
+ core.$YatspMap.init(inst, def);
1062
+ YatspType.init(inst, def);
1063
+ inst._yatsp.processJSONSchema = (ctx, json, params) => processors.mapProcessor(inst, ctx, json, params);
1064
+ inst.keyType = def.keyType;
1065
+ inst.valueType = def.valueType;
1066
+ inst.min = (...args) => inst.check(core._minSize(...args));
1067
+ inst.nonempty = (params) => inst.check(core._minSize(1, params));
1068
+ inst.max = (...args) => inst.check(core._maxSize(...args));
1069
+ inst.size = (...args) => inst.check(core._size(...args));
1070
+ });
1071
+ export function map(keyType, valueType, params) {
1072
+ return new YatspMap({
1073
+ type: "map",
1074
+ keyType: keyType,
1075
+ valueType: valueType,
1076
+ ...util.normalizeParams(params),
1077
+ });
1078
+ }
1079
+ export const YatspSet = /*@__PURE__*/ core.$constructor("YatspSet", (inst, def) => {
1080
+ _ensureDefaultMemoizer();
1081
+ core.$YatspSet.init(inst, def);
1082
+ YatspType.init(inst, def);
1083
+ inst._yatsp.processJSONSchema = (ctx, json, params) => processors.setProcessor(inst, ctx, json, params);
1084
+ inst.min = (...args) => inst.check(core._minSize(...args));
1085
+ inst.nonempty = (params) => inst.check(core._minSize(1, params));
1086
+ inst.max = (...args) => inst.check(core._maxSize(...args));
1087
+ inst.size = (...args) => inst.check(core._size(...args));
1088
+ });
1089
+ export function set(valueType, params) {
1090
+ return new YatspSet({
1091
+ type: "set",
1092
+ valueType: valueType,
1093
+ ...util.normalizeParams(params),
1094
+ });
1095
+ }
1096
+ export const YatspEnum = /*@__PURE__*/ core.$constructor("YatspEnum", (inst, def) => {
1097
+ core.$YatspEnum.init(inst, def);
1098
+ YatspType.init(inst, def);
1099
+ inst._yatsp.processJSONSchema = (ctx, json, params) => processors.enumProcessor(inst, ctx, json, params);
1100
+ inst.enum = def.entries;
1101
+ // reuse the parsed value set so a numeric TS enum's reverse-mapping keys stay out
1102
+ inst.options = [...inst._yatsp.values];
1103
+ const keys = new Set(Object.keys(def.entries));
1104
+ inst.extract = (values, params) => {
1105
+ const newEntries = {};
1106
+ for (const value of values) {
1107
+ if (keys.has(value)) {
1108
+ newEntries[value] = def.entries[value];
1109
+ }
1110
+ else
1111
+ throw new Error(`Key ${value} not found in enum`);
1112
+ }
1113
+ return new YatspEnum({
1114
+ ...def,
1115
+ checks: [],
1116
+ ...util.normalizeParams(params),
1117
+ entries: newEntries,
1118
+ });
1119
+ };
1120
+ inst.exclude = (values, params) => {
1121
+ const newEntries = { ...def.entries };
1122
+ for (const value of values) {
1123
+ if (keys.has(value)) {
1124
+ delete newEntries[value];
1125
+ }
1126
+ else
1127
+ throw new Error(`Key ${value} not found in enum`);
1128
+ }
1129
+ return new YatspEnum({
1130
+ ...def,
1131
+ checks: [],
1132
+ ...util.normalizeParams(params),
1133
+ entries: newEntries,
1134
+ });
1135
+ };
1136
+ });
1137
+ function _enum(values, params) {
1138
+ const entries = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
1139
+ return new YatspEnum({
1140
+ type: "enum",
1141
+ entries,
1142
+ ...util.normalizeParams(params),
1143
+ });
1144
+ }
1145
+ export { _enum as enum };
1146
+ /** @deprecated This API has been merged into `z.enum()`. Use `z.enum()` instead.
1147
+ *
1148
+ * ```ts
1149
+ * enum Colors { red, green, blue }
1150
+ * z.enum(Colors);
1151
+ * ```
1152
+ */
1153
+ export function nativeEnum(entries, params) {
1154
+ return new YatspEnum({
1155
+ type: "enum",
1156
+ entries,
1157
+ ...util.normalizeParams(params),
1158
+ });
1159
+ }
1160
+ export const YatspLiteral = /*@__PURE__*/ core.$constructor("YatspLiteral", (inst, def) => {
1161
+ core.$YatspLiteral.init(inst, def);
1162
+ YatspType.init(inst, def);
1163
+ inst._yatsp.processJSONSchema = (ctx, json, params) => processors.literalProcessor(inst, ctx, json, params);
1164
+ inst.values = new Set(def.values);
1165
+ Object.defineProperty(inst, "value", {
1166
+ get() {
1167
+ if (def.values.length > 1) {
1168
+ throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");
1169
+ }
1170
+ return def.values[0];
1171
+ },
1172
+ });
1173
+ });
1174
+ export function literal(value, params) {
1175
+ return new YatspLiteral({
1176
+ type: "literal",
1177
+ values: Array.isArray(value) ? value : [value],
1178
+ ...util.normalizeParams(params),
1179
+ });
1180
+ }
1181
+ export const YatspFile = /*@__PURE__*/ core.$constructor("YatspFile", (inst, def) => {
1182
+ core.$YatspFile.init(inst, def);
1183
+ YatspType.init(inst, def);
1184
+ inst._yatsp.processJSONSchema = (ctx, json, params) => processors.fileProcessor(inst, ctx, json, params);
1185
+ inst.min = (size, params) => inst.check(core._minSize(size, params));
1186
+ inst.max = (size, params) => inst.check(core._maxSize(size, params));
1187
+ inst.mime = (types, params) => inst.check(core._mime(Array.isArray(types) ? types : [types], params));
1188
+ });
1189
+ export function file(params) {
1190
+ return core._file(YatspFile, params);
1191
+ }
1192
+ export const YatspTransform = /*@__PURE__*/ core.$constructor("YatspTransform", (inst, def) => {
1193
+ _ensureDefaultMemoizer();
1194
+ core.$YatspTransform.init(inst, def);
1195
+ YatspType.init(inst, def);
1196
+ inst._yatsp.processJSONSchema = (ctx, json, params) => processors.transformProcessor(inst, ctx, json, params);
1197
+ inst._yatsp.parse = (payload, _ctx) => {
1198
+ if (_ctx.direction === "backward") {
1199
+ throw new core.$YatspEncodeError(inst.constructor.name);
1200
+ }
1201
+ payload.addIssue = (issue) => {
1202
+ if (typeof issue === "string") {
1203
+ payload.issues.push(util.issue(issue, payload.value, def));
1204
+ }
1205
+ else {
1206
+ // for Yatsp 3 backwards compatibility
1207
+ const _issue = issue;
1208
+ if (_issue.fatal)
1209
+ _issue.continue = false;
1210
+ _issue.code ?? (_issue.code = "custom");
1211
+ if (!("input" in _issue))
1212
+ _issue.input = payload.value;
1213
+ _issue.inst ?? (_issue.inst = inst);
1214
+ // _issue.continue ??= true;
1215
+ payload.issues.push(util.issue(_issue));
1216
+ }
1217
+ };
1218
+ const output = def.transform(payload.value, payload);
1219
+ if (output instanceof Promise) {
1220
+ return output.then((output) => {
1221
+ payload.value = output;
1222
+ return payload;
1223
+ });
1224
+ }
1225
+ payload.value = output;
1226
+ return payload;
1227
+ };
1228
+ });
1229
+ export function transform(fn) {
1230
+ return new YatspTransform({
1231
+ type: "transform",
1232
+ transform: fn,
1233
+ });
1234
+ }
1235
+ export const YatspOptional = /*@__PURE__*/ core.$constructor("YatspOptional", (inst, def) => {
1236
+ core.$YatspOptional.init(inst, def);
1237
+ YatspType.init(inst, def);
1238
+ inst._yatsp.processJSONSchema = (ctx, json, params) => processors.optionalProcessor(inst, ctx, json, params);
1239
+ inst.unwrap = () => inst._yatsp.def.innerType;
1240
+ });
1241
+ export function optional(innerType) {
1242
+ return new YatspOptional({
1243
+ type: "optional",
1244
+ innerType: innerType,
1245
+ });
1246
+ }
1247
+ export const YatspExactOptional = /*@__PURE__*/ core.$constructor("YatspExactOptional", (inst, def) => {
1248
+ core.$YatspExactOptional.init(inst, def);
1249
+ YatspType.init(inst, def);
1250
+ inst._yatsp.processJSONSchema = (ctx, json, params) => processors.optionalProcessor(inst, ctx, json, params);
1251
+ inst.unwrap = () => inst._yatsp.def.innerType;
1252
+ });
1253
+ export function exactOptional(innerType) {
1254
+ return new YatspExactOptional({
1255
+ type: "optional",
1256
+ innerType: innerType,
1257
+ });
1258
+ }
1259
+ export const YatspNullable = /*@__PURE__*/ core.$constructor("YatspNullable", (inst, def) => {
1260
+ core.$YatspNullable.init(inst, def);
1261
+ YatspType.init(inst, def);
1262
+ inst._yatsp.processJSONSchema = (ctx, json, params) => processors.nullableProcessor(inst, ctx, json, params);
1263
+ inst.unwrap = () => inst._yatsp.def.innerType;
1264
+ });
1265
+ export function nullable(innerType) {
1266
+ return new YatspNullable({
1267
+ type: "nullable",
1268
+ innerType: innerType,
1269
+ });
1270
+ }
1271
+ // nullish
1272
+ export function nullish(innerType) {
1273
+ return optional(nullable(innerType));
1274
+ }
1275
+ export const YatspDefault = /*@__PURE__*/ core.$constructor("YatspDefault", (inst, def) => {
1276
+ core.$YatspDefault.init(inst, def);
1277
+ YatspType.init(inst, def);
1278
+ inst._yatsp.processJSONSchema = (ctx, json, params) => processors.defaultProcessor(inst, ctx, json, params);
1279
+ inst.unwrap = () => inst._yatsp.def.innerType;
1280
+ inst.removeDefault = inst.unwrap;
1281
+ });
1282
+ export function _default(innerType, defaultValue) {
1283
+ return new YatspDefault({
1284
+ type: "default",
1285
+ innerType: innerType,
1286
+ get defaultValue() {
1287
+ return typeof defaultValue === "function" ? defaultValue() : util.shallowClone(defaultValue);
1288
+ },
1289
+ });
1290
+ }
1291
+ export const YatspPrefault = /*@__PURE__*/ core.$constructor("YatspPrefault", (inst, def) => {
1292
+ core.$YatspPrefault.init(inst, def);
1293
+ YatspType.init(inst, def);
1294
+ inst._yatsp.processJSONSchema = (ctx, json, params) => processors.prefaultProcessor(inst, ctx, json, params);
1295
+ inst.unwrap = () => inst._yatsp.def.innerType;
1296
+ });
1297
+ export function prefault(innerType, defaultValue) {
1298
+ return new YatspPrefault({
1299
+ type: "prefault",
1300
+ innerType: innerType,
1301
+ get defaultValue() {
1302
+ return typeof defaultValue === "function" ? defaultValue() : util.shallowClone(defaultValue);
1303
+ },
1304
+ });
1305
+ }
1306
+ export const YatspNonOptional = /*@__PURE__*/ core.$constructor("YatspNonOptional", (inst, def) => {
1307
+ core.$YatspNonOptional.init(inst, def);
1308
+ YatspType.init(inst, def);
1309
+ inst._yatsp.processJSONSchema = (ctx, json, params) => processors.nonoptionalProcessor(inst, ctx, json, params);
1310
+ inst.unwrap = () => inst._yatsp.def.innerType;
1311
+ });
1312
+ export function nonoptional(innerType, params) {
1313
+ return new YatspNonOptional({
1314
+ type: "nonoptional",
1315
+ innerType: innerType,
1316
+ ...util.normalizeParams(params),
1317
+ });
1318
+ }
1319
+ export const YatspSuccess = /*@__PURE__*/ core.$constructor("YatspSuccess", (inst, def) => {
1320
+ core.$YatspSuccess.init(inst, def);
1321
+ YatspType.init(inst, def);
1322
+ inst._yatsp.processJSONSchema = (ctx, json, params) => processors.successProcessor(inst, ctx, json, params);
1323
+ inst.unwrap = () => inst._yatsp.def.innerType;
1324
+ });
1325
+ export function success(innerType) {
1326
+ return new YatspSuccess({
1327
+ type: "success",
1328
+ innerType: innerType,
1329
+ });
1330
+ }
1331
+ export const YatspCatch = /*@__PURE__*/ core.$constructor("YatspCatch", (inst, def) => {
1332
+ core.$YatspCatch.init(inst, def);
1333
+ YatspType.init(inst, def);
1334
+ inst._yatsp.processJSONSchema = (ctx, json, params) => processors.catchProcessor(inst, ctx, json, params);
1335
+ inst.unwrap = () => inst._yatsp.def.innerType;
1336
+ inst.removeCatch = inst.unwrap;
1337
+ });
1338
+ function _catch(innerType, catchValue) {
1339
+ return new YatspCatch({
1340
+ type: "catch",
1341
+ innerType: innerType,
1342
+ catchValue: (typeof catchValue === "function" ? catchValue : core.util.constantCatch(catchValue)),
1343
+ });
1344
+ }
1345
+ export { _catch as catch };
1346
+ export const YatspNaN = /*@__PURE__*/ core.$constructor("YatspNaN", (inst, def) => {
1347
+ core.$YatspNaN.init(inst, def);
1348
+ YatspType.init(inst, def);
1349
+ inst._yatsp.processJSONSchema = (ctx, json, params) => processors.nanProcessor(inst, ctx, json, params);
1350
+ });
1351
+ export function nan(params) {
1352
+ return core._nan(YatspNaN, params);
1353
+ }
1354
+ export const YatspPipe = /*@__PURE__*/ core.$constructor("YatspPipe", (inst, def) => {
1355
+ core.$YatspPipe.init(inst, def);
1356
+ YatspType.init(inst, def);
1357
+ inst._yatsp.processJSONSchema = (ctx, json, params) => processors.pipeProcessor(inst, ctx, json, params);
1358
+ inst.in = def.in;
1359
+ inst.out = def.out;
1360
+ });
1361
+ export function pipe(in_, out) {
1362
+ return new YatspPipe({
1363
+ type: "pipe",
1364
+ in: in_,
1365
+ out: out,
1366
+ // ...util.normalizeParams(params),
1367
+ });
1368
+ }
1369
+ export const YatspCodec = /*@__PURE__*/ core.$constructor("YatspCodec", (inst, def) => {
1370
+ YatspPipe.init(inst, def);
1371
+ core.$YatspCodec.init(inst, def);
1372
+ });
1373
+ export function codec(in_, out, params) {
1374
+ return new YatspCodec({
1375
+ type: "pipe",
1376
+ in: in_,
1377
+ out: out,
1378
+ transform: params.decode,
1379
+ reverseTransform: params.encode,
1380
+ });
1381
+ }
1382
+ export function invertCodec(codec) {
1383
+ const def = codec._yatsp.def;
1384
+ return new YatspCodec({
1385
+ type: "pipe",
1386
+ in: def.out,
1387
+ out: def.in,
1388
+ transform: def.reverseTransform,
1389
+ reverseTransform: def.transform,
1390
+ });
1391
+ }
1392
+ export const YatspPreprocess = /*@__PURE__*/ core.$constructor("YatspPreprocess", (inst, def) => {
1393
+ YatspPipe.init(inst, def);
1394
+ core.$YatspPreprocess.init(inst, def);
1395
+ });
1396
+ export const YatspReadonly = /*@__PURE__*/ core.$constructor("YatspReadonly", (inst, def) => {
1397
+ core.$YatspReadonly.init(inst, def);
1398
+ YatspType.init(inst, def);
1399
+ inst._yatsp.processJSONSchema = (ctx, json, params) => processors.readonlyProcessor(inst, ctx, json, params);
1400
+ inst.unwrap = () => inst._yatsp.def.innerType;
1401
+ });
1402
+ export function readonly(innerType) {
1403
+ return new YatspReadonly({
1404
+ type: "readonly",
1405
+ innerType: innerType,
1406
+ });
1407
+ }
1408
+ export const YatspTemplateLiteral = /*@__PURE__*/ core.$constructor("YatspTemplateLiteral", (inst, def) => {
1409
+ core.$YatspTemplateLiteral.init(inst, def);
1410
+ YatspType.init(inst, def);
1411
+ inst._yatsp.processJSONSchema = (ctx, json, params) => processors.templateLiteralProcessor(inst, ctx, json, params);
1412
+ });
1413
+ export function templateLiteral(parts, params) {
1414
+ return new YatspTemplateLiteral({
1415
+ type: "template_literal",
1416
+ parts,
1417
+ ...util.normalizeParams(params),
1418
+ });
1419
+ }
1420
+ export const YatspLazy = /*@__PURE__*/ core.$constructor("YatspLazy", (inst, def) => {
1421
+ core.$YatspLazy.init(inst, def);
1422
+ YatspType.init(inst, def);
1423
+ inst._yatsp.processJSONSchema = (ctx, json, params) => processors.lazyProcessor(inst, ctx, json, params);
1424
+ inst.unwrap = () => inst._yatsp.def.getter();
1425
+ });
1426
+ export function lazy(getter) {
1427
+ return new YatspLazy({
1428
+ type: "lazy",
1429
+ getter: getter,
1430
+ });
1431
+ }
1432
+ export const YatspPromise = /*@__PURE__*/ core.$constructor("YatspPromise", (inst, def) => {
1433
+ core.$YatspPromise.init(inst, def);
1434
+ YatspType.init(inst, def);
1435
+ inst._yatsp.processJSONSchema = (ctx, json, params) => processors.promiseProcessor(inst, ctx, json, params);
1436
+ inst.unwrap = () => inst._yatsp.def.innerType;
1437
+ });
1438
+ export function promise(innerType) {
1439
+ return new YatspPromise({
1440
+ type: "promise",
1441
+ innerType: innerType,
1442
+ });
1443
+ }
1444
+ export const YatspFunction = /*@__PURE__*/ core.$constructor("YatspFunction", (inst, def) => {
1445
+ core.$YatspFunction.init(inst, def);
1446
+ YatspType.init(inst, def);
1447
+ inst._yatsp.processJSONSchema = (ctx, json, params) => processors.functionProcessor(inst, ctx, json, params);
1448
+ });
1449
+ export function _function(params) {
1450
+ return new YatspFunction({
1451
+ type: "function",
1452
+ input: Array.isArray(params?.input) ? tuple(params?.input) : (params?.input ?? array(unknown())),
1453
+ output: params?.output ?? unknown(),
1454
+ });
1455
+ }
1456
+ export { _function as function };
1457
+ export const YatspCustom = /*@__PURE__*/ core.$constructor("YatspCustom", (inst, def) => {
1458
+ core.$YatspCustom.init(inst, def);
1459
+ YatspType.init(inst, def);
1460
+ inst._yatsp.processJSONSchema = (ctx, json, params) => processors.customProcessor(inst, ctx, json, params);
1461
+ });
1462
+ // custom checks
1463
+ export function check(fn) {
1464
+ const ch = new core.$YatspCheck({
1465
+ check: "custom",
1466
+ // ...util.normalizeParams(params),
1467
+ });
1468
+ ch._yatsp.check = fn;
1469
+ return ch;
1470
+ }
1471
+ export function custom(fn, _params) {
1472
+ return core._custom(YatspCustom, fn ?? (() => true), _params);
1473
+ }
1474
+ export function refine(fn, _params = {}) {
1475
+ return core._refine(YatspCustom, fn, _params);
1476
+ }
1477
+ // superRefine
1478
+ export function superRefine(fn, params) {
1479
+ return core._superRefine(fn, params);
1480
+ }
1481
+ // Re-export describe and meta from core
1482
+ export const describe = core.describe;
1483
+ export const meta = core.meta;
1484
+ export const YatspInstanceOf = /*@__PURE__*/ core.$constructor("YatspInstanceOf", (inst, def) => {
1485
+ YatspCustom.init(inst, def);
1486
+ }, {
1487
+ properties(shape, params) {
1488
+ // asserts in place, so the narrowed output type is truthful without a wrapper
1489
+ return this.check(core._properties(shape, params));
1490
+ },
1491
+ });
1492
+ function _instanceof(cls, params = {}) {
1493
+ const inst = new YatspInstanceOf({
1494
+ type: "custom",
1495
+ check: "custom",
1496
+ fn: (data) => data instanceof cls,
1497
+ abort: true,
1498
+ ...util.normalizeParams(params),
1499
+ });
1500
+ inst._yatsp.bag.Class = cls;
1501
+ // Override check to emit invalid_type instead of custom
1502
+ inst._yatsp.check = (payload) => {
1503
+ if (!(payload.value instanceof cls)) {
1504
+ payload.issues.push({
1505
+ code: "invalid_type",
1506
+ expected: cls.name,
1507
+ input: payload.value,
1508
+ inst,
1509
+ path: [...(inst._yatsp.def.path ?? [])],
1510
+ });
1511
+ }
1512
+ };
1513
+ return inst;
1514
+ }
1515
+ export { _instanceof as instanceof };
1516
+ // stringbool
1517
+ export const stringbool = (...args) => core._stringbool({
1518
+ Codec: YatspCodec,
1519
+ Boolean: YatspBoolean,
1520
+ String: YatspString,
1521
+ }, ...args);
1522
+ export function json(params) {
1523
+ const jsonSchema = lazy(() => {
1524
+ return union([string(params), number(), boolean(), _null(), array(jsonSchema), record(string(), jsonSchema)]);
1525
+ });
1526
+ return jsonSchema;
1527
+ }
1528
+ // preprocess
1529
+ export function preprocess(fn, schema) {
1530
+ return new YatspPreprocess({
1531
+ type: "pipe",
1532
+ in: transform(fn),
1533
+ out: schema,
1534
+ });
1535
+ }