@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,1913 @@
1
+ import * as checks from "./checks.js";
2
+ import type * as core from "./core.js";
3
+ import type * as errors from "./errors.js";
4
+ import * as registries from "./registries.js";
5
+ import * as schemas from "./schemas.js";
6
+ import * as util from "./util.js";
7
+
8
+ export type Params<
9
+ T extends schemas.$YatspType | checks.$YatspCheck,
10
+ IssueTypes extends errors.$YatspIssueBase,
11
+ OmitKeys extends keyof T["_yatsp"]["def"] = never,
12
+ > = util.Flatten<
13
+ Partial<
14
+ util.EmptyToNever<
15
+ Omit<T["_yatsp"]["def"], OmitKeys> &
16
+ ([IssueTypes] extends [never]
17
+ ? {} // unknown
18
+ : {
19
+ error?: string | errors.$YatspErrorMap<IssueTypes> | undefined;
20
+ /** @deprecated This parameter is deprecated. Use `error` instead. */
21
+ message?: string | undefined; // supported in Yatsp 3
22
+ })
23
+ >
24
+ >
25
+ >;
26
+
27
+ export type TypeParams<
28
+ T extends schemas.$YatspType = schemas.$YatspType & { _isst: never },
29
+ AlsoOmit extends Exclude<keyof T["_yatsp"]["def"], "type" | "checks" | "error"> = never,
30
+ > = Params<T, NonNullable<T["_yatsp"]["isst"]>, "type" | "checks" | "error" | AlsoOmit>;
31
+
32
+ // strips types that are not exposed in the public factory
33
+ // incl. `error`, `check`
34
+ export type CheckParams<
35
+ T extends checks.$YatspCheck = checks.$YatspCheck, // & { _issc: never },
36
+ AlsoOmit extends Exclude<keyof T["_yatsp"]["def"], "check" | "error"> = never,
37
+ > = Params<T, NonNullable<T["_yatsp"]["issc"]>, "check" | "error" | AlsoOmit>;
38
+
39
+ // strips types that are not exposed in the public factory
40
+ // incl. `type`, `checks`, `error`, `check`, `format`
41
+ export type StringFormatParams<
42
+ T extends schemas.$YatspStringFormat = schemas.$YatspStringFormat,
43
+ AlsoOmit extends Exclude<
44
+ keyof T["_yatsp"]["def"],
45
+ "type" | "coerce" | "checks" | "error" | "check" | "format"
46
+ > = never,
47
+ > = Params<
48
+ T,
49
+ NonNullable<T["_yatsp"]["isst"] | T["_yatsp"]["issc"]>,
50
+ "type" | "coerce" | "checks" | "error" | "check" | "format" | AlsoOmit
51
+ >;
52
+
53
+ export type CheckStringFormatParams<
54
+ T extends schemas.$YatspStringFormat = schemas.$YatspStringFormat,
55
+ AlsoOmit extends Exclude<
56
+ keyof T["_yatsp"]["def"],
57
+ "type" | "coerce" | "checks" | "error" | "check" | "format"
58
+ > = never,
59
+ > = Params<T, NonNullable<T["_yatsp"]["issc"]>, "type" | "coerce" | "checks" | "error" | "check" | "format" | AlsoOmit>;
60
+
61
+ export type CheckTypeParams<
62
+ T extends schemas.$YatspType & checks.$YatspCheck = schemas.$YatspType & checks.$YatspCheck,
63
+ AlsoOmit extends Exclude<keyof T["_yatsp"]["def"], "type" | "checks" | "error" | "check"> = never,
64
+ > = Params<T, NonNullable<T["_yatsp"]["isst"] | T["_yatsp"]["issc"]>, "type" | "checks" | "error" | "check" | AlsoOmit>;
65
+
66
+ // String
67
+ export type $YatspStringParams = TypeParams<schemas.$YatspString<string>, "coerce"> & {
68
+ checks?: readonly checks.$YatspCheck<string>[];
69
+ };
70
+
71
+ function snapshotChecks<T extends { checks?: readonly checks.$YatspCheck<never>[] }>(def: T) {
72
+ if (def.checks) def.checks = [...def.checks];
73
+ return def as T & { checks?: NonNullable<T["checks"]>[number][] };
74
+ }
75
+ // @__NO_SIDE_EFFECTS__
76
+ export function _string<T extends schemas.$YatspString>(
77
+ Class: util.SchemaClass<T>,
78
+ params?: string | $YatspStringParams
79
+ ): T {
80
+ return new Class(snapshotChecks({ type: "string" as const, ...util.normalizeParams(params) }));
81
+ }
82
+
83
+ // @__NO_SIDE_EFFECTS__
84
+ export function _coercedString<T extends schemas.$YatspString>(
85
+ Class: util.SchemaClass<T>,
86
+ params?: string | $YatspStringParams
87
+ ): T {
88
+ return new Class(snapshotChecks({ type: "string" as const, coerce: true, ...util.normalizeParams(params) }));
89
+ }
90
+
91
+ export type $YatspStringFormatParams = CheckTypeParams<
92
+ schemas.$YatspStringFormat,
93
+ "format" | "coerce" | "when" | "pattern"
94
+ >;
95
+ export type $YatspCheckStringFormatParams = CheckParams<checks.$YatspCheckStringFormat, "format">;
96
+ // custom format
97
+
98
+ // Email
99
+ export type $YatspEmailParams = StringFormatParams<schemas.$YatspEmail, "when">;
100
+ export type $YatspCheckEmailParams = CheckStringFormatParams<schemas.$YatspEmail, "when">;
101
+ // @__NO_SIDE_EFFECTS__
102
+ export function _email<T extends schemas.$YatspEmail>(
103
+ Class: util.SchemaClass<T>,
104
+ params?: string | $YatspEmailParams | $YatspCheckEmailParams
105
+ ): T {
106
+ return new Class({
107
+ type: "string",
108
+ format: "email",
109
+ check: "string_format",
110
+ abort: false,
111
+ ...util.normalizeParams(params),
112
+ });
113
+ }
114
+
115
+ // GUID
116
+ export type $YatspGUIDParams = StringFormatParams<schemas.$YatspGUID, "pattern" | "when">;
117
+ export type $YatspCheckGUIDParams = CheckStringFormatParams<schemas.$YatspGUID, "pattern" | "when">;
118
+ // @__NO_SIDE_EFFECTS__
119
+ export function _guid<T extends schemas.$YatspGUID>(
120
+ Class: util.SchemaClass<T>,
121
+ params?: string | $YatspGUIDParams | $YatspCheckGUIDParams
122
+ ): T {
123
+ return new Class({
124
+ type: "string",
125
+ format: "guid",
126
+ check: "string_format",
127
+ abort: false,
128
+ ...util.normalizeParams(params),
129
+ });
130
+ }
131
+
132
+ // UUID
133
+ export type $YatspUUIDParams = StringFormatParams<schemas.$YatspUUID, "pattern" | "when">;
134
+ export type $YatspCheckUUIDParams = CheckStringFormatParams<schemas.$YatspUUID, "pattern" | "when">;
135
+ // @__NO_SIDE_EFFECTS__
136
+ export function _uuid<T extends schemas.$YatspUUID>(
137
+ Class: util.SchemaClass<T>,
138
+ params?: string | $YatspUUIDParams | $YatspCheckUUIDParams
139
+ ): T {
140
+ return new Class({
141
+ type: "string",
142
+ format: "uuid",
143
+ check: "string_format",
144
+ abort: false,
145
+ ...util.normalizeParams(params),
146
+ });
147
+ }
148
+
149
+ // UUIDv4
150
+ export type $YatspUUIDv4Params = StringFormatParams<schemas.$YatspUUID, "pattern" | "when">;
151
+ export type $YatspCheckUUIDv4Params = CheckStringFormatParams<schemas.$YatspUUID, "pattern" | "when">;
152
+ // @__NO_SIDE_EFFECTS__
153
+ export function _uuidv4<T extends schemas.$YatspUUID>(
154
+ Class: util.SchemaClass<T>,
155
+ params?: string | $YatspUUIDv4Params | $YatspCheckUUIDv4Params
156
+ ): T {
157
+ return new Class({
158
+ type: "string",
159
+ format: "uuid",
160
+ check: "string_format",
161
+ abort: false,
162
+ version: "v4",
163
+ ...util.normalizeParams(params),
164
+ });
165
+ }
166
+
167
+ // UUIDv6
168
+ export type $YatspUUIDv6Params = StringFormatParams<schemas.$YatspUUID, "pattern" | "when">;
169
+ export type $YatspCheckUUIDv6Params = CheckStringFormatParams<schemas.$YatspUUID, "pattern" | "when">;
170
+ // @__NO_SIDE_EFFECTS__
171
+ export function _uuidv6<T extends schemas.$YatspUUID>(
172
+ Class: util.SchemaClass<T>,
173
+ params?: string | $YatspUUIDv6Params | $YatspCheckUUIDv6Params
174
+ ): T {
175
+ return new Class({
176
+ type: "string",
177
+ format: "uuid",
178
+ check: "string_format",
179
+ abort: false,
180
+ version: "v6",
181
+ ...util.normalizeParams(params),
182
+ });
183
+ }
184
+
185
+ // UUIDv7
186
+ export type $YatspUUIDv7Params = StringFormatParams<schemas.$YatspUUID, "pattern" | "when">;
187
+ export type $YatspCheckUUIDv7Params = CheckStringFormatParams<schemas.$YatspUUID, "pattern" | "when">;
188
+ // @__NO_SIDE_EFFECTS__
189
+ export function _uuidv7<T extends schemas.$YatspUUID>(
190
+ Class: util.SchemaClass<T>,
191
+ params?: string | $YatspUUIDv7Params | $YatspCheckUUIDv7Params
192
+ ): T {
193
+ return new Class({
194
+ type: "string",
195
+ format: "uuid",
196
+ check: "string_format",
197
+ abort: false,
198
+ version: "v7",
199
+ ...util.normalizeParams(params),
200
+ });
201
+ }
202
+
203
+ // URL
204
+ export type $YatspURLParams = StringFormatParams<schemas.$YatspURL, "when">;
205
+ export type $YatspCheckURLParams = CheckStringFormatParams<schemas.$YatspURL, "when">;
206
+ // @__NO_SIDE_EFFECTS__
207
+ export function _url<T extends schemas.$YatspURL>(
208
+ Class: util.SchemaClass<T>,
209
+ params?: string | $YatspURLParams | $YatspCheckURLParams
210
+ ): T {
211
+ return new Class({
212
+ type: "string",
213
+ format: "url",
214
+ check: "string_format",
215
+ abort: false,
216
+ ...util.normalizeParams(params),
217
+ });
218
+ }
219
+
220
+ // Emoji
221
+ export type $YatspEmojiParams = StringFormatParams<schemas.$YatspEmoji, "when">;
222
+ export type $YatspCheckEmojiParams = CheckStringFormatParams<schemas.$YatspEmoji, "when">;
223
+ // @__NO_SIDE_EFFECTS__
224
+ export function _emoji<T extends schemas.$YatspEmoji>(
225
+ Class: util.SchemaClass<T>,
226
+ params?: string | $YatspEmojiParams | $YatspCheckEmojiParams
227
+ ): T {
228
+ return new Class({
229
+ type: "string",
230
+ format: "emoji",
231
+ check: "string_format",
232
+ abort: false,
233
+ ...util.normalizeParams(params),
234
+ });
235
+ }
236
+
237
+ // NanoID
238
+ export type $YatspNanoIDParams = StringFormatParams<schemas.$YatspNanoID, "when" | "pattern">;
239
+ export type $YatspCheckNanoIDParams = CheckStringFormatParams<schemas.$YatspNanoID, "when" | "pattern">;
240
+ // @__NO_SIDE_EFFECTS__
241
+ export function _nanoid<T extends schemas.$YatspNanoID>(
242
+ Class: util.SchemaClass<T>,
243
+ params?: string | $YatspNanoIDParams | $YatspCheckNanoIDParams
244
+ ): T {
245
+ return new Class({
246
+ type: "string",
247
+ format: "nanoid",
248
+ check: "string_format",
249
+ abort: false,
250
+ ...util.normalizeParams(params),
251
+ });
252
+ }
253
+
254
+ // CUID
255
+ /**
256
+ * @deprecated CUID v1 is deprecated by its authors due to information leakage
257
+ * (timestamps embedded in the id). Use {@link _cuid2} instead.
258
+ * See https://github.com/paralleldrive/cuid.
259
+ */
260
+ export type $YatspCUIDParams = StringFormatParams<schemas.$YatspCUID, "when">;
261
+ /**
262
+ * @deprecated CUID v1 is deprecated by its authors due to information leakage
263
+ * (timestamps embedded in the id). Use {@link _cuid2} instead.
264
+ * See https://github.com/paralleldrive/cuid.
265
+ */
266
+ export type $YatspCheckCUIDParams = CheckStringFormatParams<schemas.$YatspCUID, "when">;
267
+ /**
268
+ * @deprecated CUID v1 is deprecated by its authors due to information leakage
269
+ * (timestamps embedded in the id). Use {@link _cuid2} instead.
270
+ * See https://github.com/paralleldrive/cuid.
271
+ */
272
+ // @__NO_SIDE_EFFECTS__
273
+ export function _cuid<T extends schemas.$YatspCUID>(
274
+ Class: util.SchemaClass<T>,
275
+ params?: string | $YatspCUIDParams | $YatspCheckCUIDParams
276
+ ): T {
277
+ return new Class({
278
+ type: "string",
279
+ format: "cuid",
280
+ check: "string_format",
281
+ abort: false,
282
+ ...util.normalizeParams(params),
283
+ });
284
+ }
285
+
286
+ // CUID2
287
+ export type $YatspCUID2Params = StringFormatParams<schemas.$YatspCUID2, "when">;
288
+ export type $YatspCheckCUID2Params = CheckStringFormatParams<schemas.$YatspCUID2, "when">;
289
+ // @__NO_SIDE_EFFECTS__
290
+ export function _cuid2<T extends schemas.$YatspCUID2>(
291
+ Class: util.SchemaClass<T>,
292
+ params?: string | $YatspCUID2Params | $YatspCheckCUID2Params
293
+ ): T {
294
+ return new Class({
295
+ type: "string",
296
+ format: "cuid2",
297
+ check: "string_format",
298
+ abort: false,
299
+ ...util.normalizeParams(params),
300
+ });
301
+ }
302
+
303
+ // ULID
304
+ export type $YatspULIDParams = StringFormatParams<schemas.$YatspULID, "when">;
305
+ export type $YatspCheckULIDParams = CheckStringFormatParams<schemas.$YatspULID, "when">;
306
+ // @__NO_SIDE_EFFECTS__
307
+ export function _ulid<T extends schemas.$YatspULID>(
308
+ Class: util.SchemaClass<T>,
309
+ params?: string | $YatspULIDParams | $YatspCheckULIDParams
310
+ ): T {
311
+ return new Class({
312
+ type: "string",
313
+ format: "ulid",
314
+ check: "string_format",
315
+ abort: false,
316
+ ...util.normalizeParams(params),
317
+ });
318
+ }
319
+
320
+ // XID
321
+ export type $YatspXIDParams = StringFormatParams<schemas.$YatspXID, "when">;
322
+ export type $YatspCheckXIDParams = CheckStringFormatParams<schemas.$YatspXID, "when">;
323
+ // @__NO_SIDE_EFFECTS__
324
+ export function _xid<T extends schemas.$YatspXID>(
325
+ Class: util.SchemaClass<T>,
326
+ params?: string | $YatspXIDParams | $YatspCheckXIDParams
327
+ ): T {
328
+ return new Class({
329
+ type: "string",
330
+ format: "xid",
331
+ check: "string_format",
332
+ abort: false,
333
+ ...util.normalizeParams(params),
334
+ });
335
+ }
336
+
337
+ // KSUID
338
+ export type $YatspKSUIDParams = StringFormatParams<schemas.$YatspKSUID, "when">;
339
+ export type $YatspCheckKSUIDParams = CheckStringFormatParams<schemas.$YatspKSUID, "when">;
340
+ // @__NO_SIDE_EFFECTS__
341
+ export function _ksuid<T extends schemas.$YatspKSUID>(
342
+ Class: util.SchemaClass<T>,
343
+ params?: string | $YatspKSUIDParams | $YatspCheckKSUIDParams
344
+ ): T {
345
+ return new Class({
346
+ type: "string",
347
+ format: "ksuid",
348
+ check: "string_format",
349
+ abort: false,
350
+ ...util.normalizeParams(params),
351
+ });
352
+ }
353
+
354
+ // IPv4
355
+ export type $YatspIPv4Params = StringFormatParams<schemas.$YatspIPv4, "pattern" | "when" | "version">;
356
+ export type $YatspCheckIPv4Params = CheckStringFormatParams<schemas.$YatspIPv4, "pattern" | "when" | "version">;
357
+ // @__NO_SIDE_EFFECTS__
358
+ export function _ipv4<T extends schemas.$YatspIPv4>(
359
+ Class: util.SchemaClass<T>,
360
+ params?: string | $YatspIPv4Params | $YatspCheckIPv4Params
361
+ ): T {
362
+ return new Class({
363
+ type: "string",
364
+ format: "ipv4",
365
+ check: "string_format",
366
+ abort: false,
367
+ ...util.normalizeParams(params),
368
+ });
369
+ }
370
+
371
+ // IPv6
372
+ export type $YatspIPv6Params = StringFormatParams<schemas.$YatspIPv6, "pattern" | "when" | "version">;
373
+ export type $YatspCheckIPv6Params = CheckStringFormatParams<schemas.$YatspIPv6, "pattern" | "when" | "version">;
374
+ // @__NO_SIDE_EFFECTS__
375
+ export function _ipv6<T extends schemas.$YatspIPv6>(
376
+ Class: util.SchemaClass<T>,
377
+ params?: string | $YatspIPv6Params | $YatspCheckIPv6Params
378
+ ): T {
379
+ return new Class({
380
+ type: "string",
381
+ format: "ipv6",
382
+ check: "string_format",
383
+ abort: false,
384
+ ...util.normalizeParams(params),
385
+ });
386
+ }
387
+
388
+ // MAC
389
+ export type $YatspMACParams = StringFormatParams<schemas.$YatspMAC, "pattern" | "when">;
390
+ export type $YatspCheckMACParams = CheckStringFormatParams<schemas.$YatspMAC, "pattern" | "when">;
391
+ // @__NO_SIDE_EFFECTS__
392
+ export function _mac<T extends schemas.$YatspMAC>(
393
+ Class: util.SchemaClass<T>,
394
+ params?: string | $YatspMACParams | $YatspCheckMACParams
395
+ ): T {
396
+ return new Class({
397
+ type: "string",
398
+ format: "mac",
399
+ check: "string_format",
400
+ abort: false,
401
+ ...util.normalizeParams(params),
402
+ });
403
+ }
404
+
405
+ // CIDRv4
406
+ export type $YatspCIDRv4Params = StringFormatParams<schemas.$YatspCIDRv4, "pattern" | "when">;
407
+ export type $YatspCheckCIDRv4Params = CheckStringFormatParams<schemas.$YatspCIDRv4, "pattern" | "when">;
408
+ // @__NO_SIDE_EFFECTS__
409
+ export function _cidrv4<T extends schemas.$YatspCIDRv4>(
410
+ Class: util.SchemaClass<T>,
411
+ params?: string | $YatspCIDRv4Params | $YatspCheckCIDRv4Params
412
+ ): T {
413
+ return new Class({
414
+ type: "string",
415
+ format: "cidrv4",
416
+ check: "string_format",
417
+ abort: false,
418
+ ...util.normalizeParams(params),
419
+ });
420
+ }
421
+
422
+ // CIDRv6
423
+ export type $YatspCIDRv6Params = StringFormatParams<schemas.$YatspCIDRv6, "pattern" | "when">;
424
+ export type $YatspCheckCIDRv6Params = CheckStringFormatParams<schemas.$YatspCIDRv6, "pattern" | "when">;
425
+ // @__NO_SIDE_EFFECTS__
426
+ export function _cidrv6<T extends schemas.$YatspCIDRv6>(
427
+ Class: util.SchemaClass<T>,
428
+ params?: string | $YatspCIDRv6Params | $YatspCheckCIDRv6Params
429
+ ): T {
430
+ return new Class({
431
+ type: "string",
432
+ format: "cidrv6",
433
+ check: "string_format",
434
+ abort: false,
435
+ ...util.normalizeParams(params),
436
+ });
437
+ }
438
+
439
+ // Base64
440
+ export type $YatspBase64Params = StringFormatParams<schemas.$YatspBase64, "pattern" | "when">;
441
+ export type $YatspCheckBase64Params = CheckStringFormatParams<schemas.$YatspBase64, "pattern" | "when">;
442
+ // @__NO_SIDE_EFFECTS__
443
+ export function _base64<T extends schemas.$YatspBase64>(
444
+ Class: util.SchemaClass<T>,
445
+ params?: string | $YatspBase64Params | $YatspCheckBase64Params
446
+ ): T {
447
+ return new Class({
448
+ type: "string",
449
+ format: "base64",
450
+ check: "string_format",
451
+ abort: false,
452
+ ...util.normalizeParams(params),
453
+ });
454
+ }
455
+
456
+ // base64url
457
+ export type $YatspBase64URLParams = StringFormatParams<schemas.$YatspBase64URL, "pattern" | "when">;
458
+ export type $YatspCheckBase64URLParams = CheckStringFormatParams<schemas.$YatspBase64URL, "pattern" | "when">;
459
+ // @__NO_SIDE_EFFECTS__
460
+ export function _base64url<T extends schemas.$YatspBase64URL>(
461
+ Class: util.SchemaClass<T>,
462
+ params?: string | $YatspBase64URLParams | $YatspCheckBase64URLParams
463
+ ): T {
464
+ return new Class({
465
+ type: "string",
466
+ format: "base64url",
467
+ check: "string_format",
468
+ abort: false,
469
+ ...util.normalizeParams(params),
470
+ });
471
+ }
472
+
473
+ // E164
474
+ export type $YatspE164Params = StringFormatParams<schemas.$YatspE164, "when">;
475
+ export type $YatspCheckE164Params = CheckStringFormatParams<schemas.$YatspE164, "when">;
476
+ // @__NO_SIDE_EFFECTS__
477
+ export function _e164<T extends schemas.$YatspE164>(
478
+ Class: util.SchemaClass<T>,
479
+ params?: string | $YatspE164Params | $YatspCheckE164Params
480
+ ): T {
481
+ return new Class({
482
+ type: "string",
483
+ format: "e164",
484
+ check: "string_format",
485
+ abort: false,
486
+ ...util.normalizeParams(params),
487
+ });
488
+ }
489
+
490
+ // CreditCard
491
+ export type $YatspCreditCardParams = StringFormatParams<schemas.$YatspCreditCard, "pattern" | "when">;
492
+ export type $YatspCheckCreditCardParams = CheckStringFormatParams<schemas.$YatspCreditCard, "pattern" | "when">;
493
+ // @__NO_SIDE_EFFECTS__
494
+ export function _creditCard<T extends schemas.$YatspCreditCard>(
495
+ Class: util.SchemaClass<T>,
496
+ params?: string | $YatspCreditCardParams | $YatspCheckCreditCardParams
497
+ ): T {
498
+ return new Class({
499
+ type: "string",
500
+ format: "credit_card",
501
+ check: "string_format",
502
+ abort: false,
503
+ ...util.normalizeParams(params),
504
+ });
505
+ }
506
+
507
+ // IBAN
508
+ export type $YatspIBANParams = StringFormatParams<schemas.$YatspIBAN, "pattern" | "when">;
509
+ export type $YatspCheckIBANParams = CheckStringFormatParams<schemas.$YatspIBAN, "pattern" | "when">;
510
+ // @__NO_SIDE_EFFECTS__
511
+ export function _iban<T extends schemas.$YatspIBAN>(
512
+ Class: util.SchemaClass<T>,
513
+ params?: string | $YatspIBANParams | $YatspCheckIBANParams
514
+ ): T {
515
+ return new Class({
516
+ type: "string",
517
+ format: "iban",
518
+ check: "string_format",
519
+ abort: false,
520
+ ...util.normalizeParams(params),
521
+ });
522
+ }
523
+
524
+ // JWT
525
+ export type $YatspJWTParams = StringFormatParams<schemas.$YatspJWT, "pattern" | "when">;
526
+ export type $YatspCheckJWTParams = CheckStringFormatParams<schemas.$YatspJWT, "pattern" | "when">;
527
+ // @__NO_SIDE_EFFECTS__
528
+ export function _jwt<T extends schemas.$YatspJWT>(
529
+ Class: util.SchemaClass<T>,
530
+ params?: string | $YatspJWTParams | $YatspCheckJWTParams
531
+ ): T {
532
+ return new Class({
533
+ type: "string",
534
+ format: "jwt",
535
+ check: "string_format",
536
+ abort: false,
537
+ ...util.normalizeParams(params),
538
+ });
539
+ }
540
+
541
+ export const TimePrecision = {
542
+ Any: null,
543
+ Minute: -1,
544
+ Second: 0,
545
+ Millisecond: 3,
546
+ Microsecond: 6,
547
+ } as const;
548
+ // ISODateTime
549
+ export type $YatspISODateTimeParams = StringFormatParams<schemas.$YatspISODateTime, "pattern" | "when">;
550
+ export type $YatspCheckISODateTimeParams = CheckStringFormatParams<schemas.$YatspISODateTime, "pattern" | "when">;
551
+ // @__NO_SIDE_EFFECTS__
552
+ export function _isoDateTime<T extends schemas.$YatspISODateTime>(
553
+ Class: util.SchemaClass<T>,
554
+ params?: string | $YatspISODateTimeParams | $YatspCheckISODateTimeParams
555
+ ): T {
556
+ return new Class({
557
+ type: "string",
558
+ format: "datetime",
559
+ check: "string_format",
560
+ offset: false,
561
+ local: false,
562
+ precision: null,
563
+ ...util.normalizeParams(params),
564
+ });
565
+ }
566
+
567
+ // ISODate
568
+ export type $YatspISODateParams = StringFormatParams<schemas.$YatspISODate, "pattern" | "when">;
569
+ export type $YatspCheckISODateParams = CheckStringFormatParams<schemas.$YatspISODate, "pattern" | "when">;
570
+ // @__NO_SIDE_EFFECTS__
571
+ export function _isoDate<T extends schemas.$YatspISODate>(
572
+ Class: util.SchemaClass<T>,
573
+ params?: string | $YatspISODateParams | $YatspCheckISODateParams
574
+ ): T {
575
+ return new Class({
576
+ type: "string",
577
+ format: "date",
578
+ check: "string_format",
579
+ ...util.normalizeParams(params),
580
+ });
581
+ }
582
+
583
+ // ISOTime
584
+ export type $YatspISOTimeParams = StringFormatParams<schemas.$YatspISOTime, "pattern" | "when">;
585
+ export type $YatspCheckISOTimeParams = CheckStringFormatParams<schemas.$YatspISOTime, "pattern" | "when">;
586
+ // @__NO_SIDE_EFFECTS__
587
+ export function _isoTime<T extends schemas.$YatspISOTime>(
588
+ Class: util.SchemaClass<T>,
589
+ params?: string | $YatspISOTimeParams | $YatspCheckISOTimeParams
590
+ ): T {
591
+ return new Class({
592
+ type: "string",
593
+ format: "time",
594
+ check: "string_format",
595
+ precision: null,
596
+ ...util.normalizeParams(params),
597
+ });
598
+ }
599
+
600
+ // ISODuration
601
+ export type $YatspISODurationParams = StringFormatParams<schemas.$YatspISODuration, "when">;
602
+ export type $YatspCheckISODurationParams = CheckStringFormatParams<schemas.$YatspISODuration, "when">;
603
+ // @__NO_SIDE_EFFECTS__
604
+ export function _isoDuration<T extends schemas.$YatspISODuration>(
605
+ Class: util.SchemaClass<T>,
606
+ params?: string | $YatspISODurationParams | $YatspCheckISODurationParams
607
+ ): T {
608
+ return new Class({
609
+ type: "string",
610
+ format: "duration",
611
+ check: "string_format",
612
+ ...util.normalizeParams(params),
613
+ });
614
+ }
615
+
616
+ // Number
617
+ export type $YatspNumberParams = TypeParams<schemas.$YatspNumber<number>, "coerce"> & {
618
+ checks?: readonly checks.$YatspCheck<number>[];
619
+ };
620
+ export type $YatspNumberFormatParams = CheckTypeParams<schemas.$YatspNumberFormat, "format" | "coerce">;
621
+ export type $YatspCheckNumberFormatParams = CheckParams<checks.$YatspCheckNumberFormat, "format" | "when">;
622
+ // @__NO_SIDE_EFFECTS__
623
+ export function _number<T extends schemas.$YatspNumber>(
624
+ Class: util.SchemaClass<T>,
625
+ params?: string | $YatspNumberParams
626
+ ): T {
627
+ return new Class(snapshotChecks({ type: "number" as const, checks: [], ...util.normalizeParams(params) }));
628
+ }
629
+
630
+ // @__NO_SIDE_EFFECTS__
631
+ export function _coercedNumber<T extends schemas.$YatspNumber>(
632
+ Class: util.SchemaClass<T>,
633
+ params?: string | $YatspNumberParams
634
+ ): T {
635
+ return new Class(
636
+ snapshotChecks({ type: "number" as const, coerce: true, checks: [], ...util.normalizeParams(params) })
637
+ );
638
+ }
639
+
640
+ // @__NO_SIDE_EFFECTS__
641
+ export function _int<T extends schemas.$YatspNumberFormat>(
642
+ Class: util.SchemaClass<T>,
643
+ params?: string | $YatspCheckNumberFormatParams
644
+ ): T {
645
+ return new Class({
646
+ type: "number",
647
+ check: "number_format",
648
+ abort: false,
649
+ format: "safeint",
650
+ ...util.normalizeParams(params),
651
+ });
652
+ }
653
+ // @__NO_SIDE_EFFECTS__
654
+ export function _float32<T extends schemas.$YatspNumberFormat>(
655
+ Class: util.SchemaClass<T>,
656
+ params?: string | $YatspCheckNumberFormatParams
657
+ ): T {
658
+ return new Class({
659
+ type: "number",
660
+ check: "number_format",
661
+ abort: false,
662
+ format: "float32",
663
+ ...util.normalizeParams(params),
664
+ });
665
+ }
666
+ // @__NO_SIDE_EFFECTS__
667
+ export function _float64<T extends schemas.$YatspNumberFormat>(
668
+ Class: util.SchemaClass<T>,
669
+ params?: string | $YatspCheckNumberFormatParams
670
+ ): T {
671
+ return new Class({
672
+ type: "number",
673
+ check: "number_format",
674
+ abort: false,
675
+ format: "float64",
676
+ ...util.normalizeParams(params),
677
+ });
678
+ }
679
+ // @__NO_SIDE_EFFECTS__
680
+ export function _int32<T extends schemas.$YatspNumberFormat>(
681
+ Class: util.SchemaClass<T>,
682
+ params?: string | $YatspCheckNumberFormatParams
683
+ ): T {
684
+ return new Class({
685
+ type: "number",
686
+ check: "number_format",
687
+ abort: false,
688
+ format: "int32",
689
+ ...util.normalizeParams(params),
690
+ });
691
+ }
692
+ // @__NO_SIDE_EFFECTS__
693
+ export function _uint32<T extends schemas.$YatspNumberFormat>(
694
+ Class: util.SchemaClass<T>,
695
+ params?: string | $YatspCheckNumberFormatParams
696
+ ): T {
697
+ return new Class({
698
+ type: "number",
699
+ check: "number_format",
700
+ abort: false,
701
+ format: "uint32",
702
+ ...util.normalizeParams(params),
703
+ });
704
+ }
705
+
706
+ // Boolean
707
+ export type $YatspBooleanParams = TypeParams<schemas.$YatspBoolean<boolean>, "coerce">;
708
+ // @__NO_SIDE_EFFECTS__
709
+ export function _boolean<T extends schemas.$YatspBoolean>(
710
+ Class: util.SchemaClass<T>,
711
+ params?: string | $YatspBooleanParams
712
+ ): T {
713
+ return new Class({
714
+ type: "boolean",
715
+ ...util.normalizeParams(params),
716
+ });
717
+ }
718
+ // @__NO_SIDE_EFFECTS__
719
+ export function _coercedBoolean<T extends schemas.$YatspBoolean>(
720
+ Class: util.SchemaClass<T>,
721
+ params?: string | $YatspBooleanParams
722
+ ): T {
723
+ return new Class({
724
+ type: "boolean",
725
+ coerce: true,
726
+ ...util.normalizeParams(params),
727
+ });
728
+ }
729
+
730
+ // BigInt
731
+ export type $YatspBigIntParams = TypeParams<schemas.$YatspBigInt<bigint>>;
732
+ export type $YatspBigIntFormatParams = CheckTypeParams<schemas.$YatspBigIntFormat, "format" | "coerce">;
733
+ export type $YatspCheckBigIntFormatParams = CheckParams<checks.$YatspCheckBigIntFormat, "format" | "when">;
734
+ // @__NO_SIDE_EFFECTS__
735
+ export function _bigint<T extends schemas.$YatspBigInt>(
736
+ Class: util.SchemaClass<T>,
737
+ params?: string | $YatspBigIntParams
738
+ ): T {
739
+ return new Class({
740
+ type: "bigint",
741
+ ...util.normalizeParams(params),
742
+ });
743
+ }
744
+ // @__NO_SIDE_EFFECTS__
745
+ export function _coercedBigint<T extends schemas.$YatspBigInt>(
746
+ Class: util.SchemaClass<T>,
747
+ params?: string | $YatspBigIntParams
748
+ ): T {
749
+ return new Class({
750
+ type: "bigint",
751
+ coerce: true,
752
+ ...util.normalizeParams(params),
753
+ });
754
+ }
755
+
756
+ // @__NO_SIDE_EFFECTS__
757
+ export function _int64<T extends schemas.$YatspBigIntFormat>(
758
+ Class: util.SchemaClass<T>,
759
+ params?: string | $YatspBigIntFormatParams
760
+ ): T {
761
+ return new Class({
762
+ type: "bigint",
763
+ check: "bigint_format",
764
+ abort: false,
765
+ format: "int64",
766
+ ...util.normalizeParams(params),
767
+ });
768
+ }
769
+ // @__NO_SIDE_EFFECTS__
770
+ export function _uint64<T extends schemas.$YatspBigIntFormat>(
771
+ Class: util.SchemaClass<T>,
772
+ params?: string | $YatspBigIntFormatParams
773
+ ): T {
774
+ return new Class({
775
+ type: "bigint",
776
+ check: "bigint_format",
777
+ abort: false,
778
+ format: "uint64",
779
+ ...util.normalizeParams(params),
780
+ });
781
+ }
782
+
783
+ // Symbol
784
+ export type $YatspSymbolParams = TypeParams<schemas.$YatspSymbol>;
785
+ // @__NO_SIDE_EFFECTS__
786
+ export function _symbol<T extends schemas.$YatspSymbol>(
787
+ Class: util.SchemaClass<T>,
788
+ params?: string | $YatspSymbolParams
789
+ ): T {
790
+ return new Class({
791
+ type: "symbol",
792
+ ...util.normalizeParams(params),
793
+ });
794
+ }
795
+
796
+ // Undefined
797
+ export type $YatspUndefinedParams = TypeParams<schemas.$YatspUndefined>;
798
+ // @__NO_SIDE_EFFECTS__
799
+ export function _undefined<T extends schemas.$YatspUndefined>(
800
+ Class: util.SchemaClass<T>,
801
+ params?: string | $YatspUndefinedParams
802
+ ): T {
803
+ return new Class({
804
+ type: "undefined",
805
+ ...util.normalizeParams(params),
806
+ });
807
+ }
808
+
809
+ // Null
810
+ export type $YatspNullParams = TypeParams<schemas.$YatspNull>;
811
+ // @__NO_SIDE_EFFECTS__
812
+ export function _null<T extends schemas.$YatspNull>(Class: util.SchemaClass<T>, params?: string | $YatspNullParams): T {
813
+ return new Class({
814
+ type: "null",
815
+ ...util.normalizeParams(params),
816
+ });
817
+ }
818
+
819
+ // Any
820
+ export type $YatspAnyParams = TypeParams<schemas.$YatspAny>;
821
+ // @__NO_SIDE_EFFECTS__
822
+ export function _any<T extends schemas.$YatspAny>(Class: util.SchemaClass<T>): T {
823
+ return new Class({
824
+ type: "any",
825
+ });
826
+ }
827
+
828
+ // Unknown
829
+ export type $YatspUnknownParams = TypeParams<schemas.$YatspUnknown>;
830
+ // @__NO_SIDE_EFFECTS__
831
+ export function _unknown<T extends schemas.$YatspUnknown>(Class: util.SchemaClass<T>): T {
832
+ return new Class({
833
+ type: "unknown",
834
+ });
835
+ }
836
+
837
+ // Never
838
+ export type $YatspNeverParams = TypeParams<schemas.$YatspNever>;
839
+ // @__NO_SIDE_EFFECTS__
840
+ export function _never<T extends schemas.$YatspNever>(
841
+ Class: util.SchemaClass<T>,
842
+ params?: string | $YatspNeverParams
843
+ ): T {
844
+ return new Class({
845
+ type: "never",
846
+ ...util.normalizeParams(params),
847
+ });
848
+ }
849
+
850
+ // Void
851
+ export type $YatspVoidParams = TypeParams<schemas.$YatspVoid>;
852
+ // @__NO_SIDE_EFFECTS__
853
+ export function _void<T extends schemas.$YatspVoid>(Class: util.SchemaClass<T>, params?: string | $YatspVoidParams): T {
854
+ return new Class({
855
+ type: "void",
856
+ ...util.normalizeParams(params),
857
+ });
858
+ }
859
+
860
+ // Date
861
+ export type $YatspDateParams = TypeParams<schemas.$YatspDate, "coerce">;
862
+ // @__NO_SIDE_EFFECTS__
863
+ export function _date<T extends schemas.$YatspDate>(Class: util.SchemaClass<T>, params?: string | $YatspDateParams): T {
864
+ return new Class({
865
+ type: "date",
866
+ ...util.normalizeParams(params),
867
+ });
868
+ }
869
+ // @__NO_SIDE_EFFECTS__
870
+ export function _coercedDate<T extends schemas.$YatspDate>(
871
+ Class: util.SchemaClass<T>,
872
+ params?: string | $YatspDateParams
873
+ ): T {
874
+ return new Class({
875
+ type: "date",
876
+ coerce: true,
877
+ ...util.normalizeParams(params),
878
+ });
879
+ }
880
+
881
+ // NaN
882
+ export type $YatspNaNParams = TypeParams<schemas.$YatspNaN>;
883
+ // @__NO_SIDE_EFFECTS__
884
+ export function _nan<T extends schemas.$YatspNaN>(Class: util.SchemaClass<T>, params?: string | $YatspNaNParams): T {
885
+ return new Class({
886
+ type: "nan",
887
+ ...util.normalizeParams(params),
888
+ });
889
+ }
890
+
891
+ // export type $YatspCheckParams = CheckParams<checks.$YatspCheck, "abort" | "when">;
892
+
893
+ export type $YatspCheckLessThanParams = CheckParams<checks.$YatspCheckLessThan, "inclusive" | "value" | "when">;
894
+ // @__NO_SIDE_EFFECTS__
895
+ export function _lt(
896
+ value: util.Numeric,
897
+ params?: string | $YatspCheckLessThanParams
898
+ ): checks.$YatspCheckLessThan<util.Numeric> {
899
+ return new checks.$YatspCheckLessThan({
900
+ check: "less_than",
901
+ ...util.normalizeParams(params),
902
+ value,
903
+ inclusive: false,
904
+ });
905
+ }
906
+
907
+ // @__NO_SIDE_EFFECTS__
908
+ export function _lte(
909
+ value: util.Numeric,
910
+ params?: string | $YatspCheckLessThanParams
911
+ ): checks.$YatspCheckLessThan<util.Numeric> {
912
+ return new checks.$YatspCheckLessThan({
913
+ check: "less_than",
914
+
915
+ ...util.normalizeParams(params),
916
+ value,
917
+ inclusive: true,
918
+ });
919
+ }
920
+ export {
921
+ /** @deprecated Use `z.lte()` instead. */
922
+ _lte as _max,
923
+ };
924
+
925
+ // YatspCheckGreaterThan
926
+ export type $YatspCheckGreaterThanParams = CheckParams<checks.$YatspCheckGreaterThan, "inclusive" | "value" | "when">;
927
+ // @__NO_SIDE_EFFECTS__
928
+ export function _gt(
929
+ value: util.Numeric,
930
+ params?: string | $YatspCheckGreaterThanParams
931
+ ): checks.$YatspCheckGreaterThan {
932
+ return new checks.$YatspCheckGreaterThan({
933
+ check: "greater_than",
934
+
935
+ ...util.normalizeParams(params),
936
+ value,
937
+ inclusive: false,
938
+ });
939
+ }
940
+
941
+ // @__NO_SIDE_EFFECTS__
942
+ export function _gte(
943
+ value: util.Numeric,
944
+ params?: string | $YatspCheckGreaterThanParams
945
+ ): checks.$YatspCheckGreaterThan {
946
+ return new checks.$YatspCheckGreaterThan({
947
+ check: "greater_than",
948
+ ...util.normalizeParams(params),
949
+ value,
950
+ inclusive: true,
951
+ });
952
+ }
953
+
954
+ export {
955
+ /** @deprecated Use `z.gte()` instead. */
956
+ _gte as _min,
957
+ };
958
+
959
+ // @__NO_SIDE_EFFECTS__
960
+ export function _positive(params?: string | $YatspCheckGreaterThanParams): checks.$YatspCheckGreaterThan {
961
+ return _gt(0, params);
962
+ }
963
+
964
+ // negative
965
+ // @__NO_SIDE_EFFECTS__
966
+ export function _negative(params?: string | $YatspCheckLessThanParams): checks.$YatspCheckLessThan {
967
+ return _lt(0, params);
968
+ }
969
+
970
+ // nonpositive
971
+ // @__NO_SIDE_EFFECTS__
972
+ export function _nonpositive(params?: string | $YatspCheckLessThanParams): checks.$YatspCheckLessThan {
973
+ return _lte(0, params);
974
+ }
975
+
976
+ // nonnegative
977
+ // @__NO_SIDE_EFFECTS__
978
+ export function _nonnegative(params?: string | $YatspCheckGreaterThanParams): checks.$YatspCheckGreaterThan {
979
+ return _gte(0, params);
980
+ }
981
+
982
+ export type $YatspCheckMultipleOfParams = CheckParams<checks.$YatspCheckMultipleOf, "value" | "when">;
983
+ // @__NO_SIDE_EFFECTS__
984
+ export function _multipleOf(
985
+ value: number | bigint,
986
+ params?: string | $YatspCheckMultipleOfParams
987
+ ): checks.$YatspCheckMultipleOf {
988
+ return new checks.$YatspCheckMultipleOf({
989
+ check: "multiple_of",
990
+ ...util.normalizeParams(params),
991
+ value,
992
+ });
993
+ }
994
+
995
+ export type $YatspCheckMaxSizeParams = CheckParams<checks.$YatspCheckMaxSize, "maximum" | "when">;
996
+ // @__NO_SIDE_EFFECTS__
997
+ export function _maxSize(
998
+ maximum: number,
999
+ params?: string | $YatspCheckMaxSizeParams
1000
+ ): checks.$YatspCheckMaxSize<util.HasSize> {
1001
+ return new checks.$YatspCheckMaxSize({
1002
+ check: "max_size",
1003
+ ...util.normalizeParams(params),
1004
+ maximum,
1005
+ });
1006
+ }
1007
+
1008
+ export type $YatspCheckMinSizeParams = CheckParams<checks.$YatspCheckMinSize, "minimum" | "when">;
1009
+ // @__NO_SIDE_EFFECTS__
1010
+ export function _minSize(
1011
+ minimum: number,
1012
+ params?: string | $YatspCheckMinSizeParams
1013
+ ): checks.$YatspCheckMinSize<util.HasSize> {
1014
+ return new checks.$YatspCheckMinSize({
1015
+ check: "min_size",
1016
+ ...util.normalizeParams(params),
1017
+ minimum,
1018
+ });
1019
+ }
1020
+
1021
+ export type $YatspCheckSizeEqualsParams = CheckParams<checks.$YatspCheckSizeEquals, "size" | "when">;
1022
+ // @__NO_SIDE_EFFECTS__
1023
+ export function _size(
1024
+ size: number,
1025
+ params?: string | $YatspCheckSizeEqualsParams
1026
+ ): checks.$YatspCheckSizeEquals<util.HasSize> {
1027
+ return new checks.$YatspCheckSizeEquals({
1028
+ check: "size_equals",
1029
+ ...util.normalizeParams(params),
1030
+ size,
1031
+ });
1032
+ }
1033
+
1034
+ export type $YatspCheckMaxLengthParams = CheckParams<checks.$YatspCheckMaxLength, "maximum" | "when">;
1035
+ // @__NO_SIDE_EFFECTS__
1036
+ export function _maxLength(
1037
+ maximum: number,
1038
+ params?: string | $YatspCheckMaxLengthParams
1039
+ ): checks.$YatspCheckMaxLength<util.HasLength> {
1040
+ const ch = new checks.$YatspCheckMaxLength({
1041
+ check: "max_length",
1042
+ ...util.normalizeParams(params),
1043
+ maximum,
1044
+ });
1045
+ return ch;
1046
+ }
1047
+
1048
+ export type $YatspCheckMinLengthParams = CheckParams<checks.$YatspCheckMinLength, "minimum" | "when">;
1049
+ // @__NO_SIDE_EFFECTS__
1050
+ export function _minLength(
1051
+ minimum: number,
1052
+ params?: string | $YatspCheckMinLengthParams
1053
+ ): checks.$YatspCheckMinLength<util.HasLength> {
1054
+ return new checks.$YatspCheckMinLength({
1055
+ check: "min_length",
1056
+ ...util.normalizeParams(params),
1057
+ minimum,
1058
+ });
1059
+ }
1060
+
1061
+ export type $YatspCheckLengthEqualsParams = CheckParams<checks.$YatspCheckLengthEquals, "length" | "when">;
1062
+ // @__NO_SIDE_EFFECTS__
1063
+ export function _length(
1064
+ length: number,
1065
+ params?: string | $YatspCheckLengthEqualsParams
1066
+ ): checks.$YatspCheckLengthEquals<util.HasLength> {
1067
+ return new checks.$YatspCheckLengthEquals({
1068
+ check: "length_equals",
1069
+ ...util.normalizeParams(params),
1070
+ length,
1071
+ });
1072
+ }
1073
+
1074
+ export type $YatspCheckRegexParams = CheckParams<checks.$YatspCheckRegex, "format" | "pattern" | "when">;
1075
+ // @__NO_SIDE_EFFECTS__
1076
+ export function _regex(pattern: RegExp, params?: string | $YatspCheckRegexParams): checks.$YatspCheckRegex {
1077
+ return new checks.$YatspCheckRegex({
1078
+ check: "string_format",
1079
+ format: "regex",
1080
+ ...util.normalizeParams(params),
1081
+ pattern,
1082
+ });
1083
+ }
1084
+
1085
+ export type $YatspCheckLowerCaseParams = CheckParams<checks.$YatspCheckLowerCase, "format" | "when">;
1086
+ // @__NO_SIDE_EFFECTS__
1087
+ export function _lowercase(params?: string | $YatspCheckLowerCaseParams): checks.$YatspCheckLowerCase {
1088
+ return new checks.$YatspCheckLowerCase({
1089
+ check: "string_format",
1090
+ format: "lowercase",
1091
+ ...util.normalizeParams(params),
1092
+ });
1093
+ }
1094
+
1095
+ export type $YatspCheckUpperCaseParams = CheckParams<checks.$YatspCheckUpperCase, "format" | "when">;
1096
+
1097
+ // @__NO_SIDE_EFFECTS__
1098
+ export function _uppercase(params?: string | $YatspCheckUpperCaseParams): checks.$YatspCheckUpperCase {
1099
+ return new checks.$YatspCheckUpperCase({
1100
+ check: "string_format",
1101
+ format: "uppercase",
1102
+ ...util.normalizeParams(params),
1103
+ });
1104
+ }
1105
+
1106
+ export type $YatspCheckIncludesParams = CheckParams<
1107
+ checks.$YatspCheckIncludes,
1108
+ "includes" | "format" | "when" | "pattern"
1109
+ >;
1110
+ // @__NO_SIDE_EFFECTS__
1111
+ export function _includes(includes: string, params?: string | $YatspCheckIncludesParams): checks.$YatspCheckIncludes {
1112
+ return new checks.$YatspCheckIncludes({
1113
+ check: "string_format",
1114
+ format: "includes",
1115
+ ...util.normalizeParams(params),
1116
+ includes,
1117
+ });
1118
+ }
1119
+ export type $YatspCheckStartsWithParams = CheckParams<
1120
+ checks.$YatspCheckStartsWith,
1121
+ "prefix" | "format" | "when" | "pattern"
1122
+ >;
1123
+ // @__NO_SIDE_EFFECTS__
1124
+ export function _startsWith(
1125
+ prefix: string,
1126
+ params?: string | $YatspCheckStartsWithParams
1127
+ ): checks.$YatspCheckStartsWith {
1128
+ return new checks.$YatspCheckStartsWith({
1129
+ check: "string_format",
1130
+ format: "starts_with",
1131
+ ...util.normalizeParams(params),
1132
+ prefix,
1133
+ });
1134
+ }
1135
+
1136
+ export type $YatspCheckEndsWithParams = CheckParams<
1137
+ checks.$YatspCheckEndsWith,
1138
+ "suffix" | "format" | "pattern" | "when"
1139
+ >;
1140
+
1141
+ // @__NO_SIDE_EFFECTS__
1142
+ export function _endsWith(suffix: string, params?: string | $YatspCheckEndsWithParams): checks.$YatspCheckEndsWith {
1143
+ return new checks.$YatspCheckEndsWith({
1144
+ check: "string_format",
1145
+ format: "ends_with",
1146
+ ...util.normalizeParams(params),
1147
+ suffix,
1148
+ });
1149
+ }
1150
+
1151
+ export type $YatspCheckPropertyParams = CheckParams<checks.$YatspCheckProperty, "property" | "schema" | "when">;
1152
+ // @__NO_SIDE_EFFECTS__
1153
+ export function _property<K extends string, T extends schemas.$YatspType>(
1154
+ property: K,
1155
+ schema: T,
1156
+ params?: string | $YatspCheckPropertyParams
1157
+ ): checks.$YatspCheckProperty<{ [k in K]: util.Widen<core.input<T>> }> {
1158
+ return new checks.$YatspCheckProperty({
1159
+ check: "property",
1160
+ property,
1161
+ schema,
1162
+ ...util.normalizeParams(params),
1163
+ });
1164
+ }
1165
+
1166
+ export type $YatspCheckPropertiesParams = CheckParams<checks.$YatspCheckProperties, "shape" | "when">;
1167
+ // @__NO_SIDE_EFFECTS__
1168
+ export function _properties<Shape extends schemas.$YatspShape>(
1169
+ shape: Shape,
1170
+ params?: string | $YatspCheckPropertiesParams
1171
+ ): checks.$YatspCheckProperties<Shape> {
1172
+ return new checks.$YatspCheckProperties({
1173
+ check: "properties",
1174
+ shape,
1175
+ ...util.normalizeParams(params),
1176
+ }) as any;
1177
+ }
1178
+
1179
+ export type $YatspCheckMimeTypeParams = CheckParams<checks.$YatspCheckMimeType, "mime" | "when">;
1180
+ // @__NO_SIDE_EFFECTS__
1181
+ export function _mime(
1182
+ types: util.MimeTypes[],
1183
+ params?: string | $YatspCheckMimeTypeParams
1184
+ ): checks.$YatspCheckMimeType {
1185
+ return new checks.$YatspCheckMimeType({
1186
+ check: "mime_type",
1187
+ mime: types,
1188
+ ...util.normalizeParams(params),
1189
+ });
1190
+ }
1191
+
1192
+ // @__NO_SIDE_EFFECTS__
1193
+ export function _overwrite<T>(tx: (input: T) => T): checks.$YatspCheckOverwrite<T> {
1194
+ return new checks.$YatspCheckOverwrite({
1195
+ check: "overwrite",
1196
+ tx,
1197
+ }) as checks.$YatspCheckOverwrite<T>;
1198
+ }
1199
+ // normalize
1200
+ // @__NO_SIDE_EFFECTS__
1201
+ export function _normalize(
1202
+ form?: "NFC" | "NFD" | "NFKC" | "NFKD" | (string & {})
1203
+ ): checks.$YatspCheckOverwrite<string> {
1204
+ return _overwrite((input) => input.normalize(form));
1205
+ }
1206
+
1207
+ // trim
1208
+ // @__NO_SIDE_EFFECTS__
1209
+ export function _trim(): checks.$YatspCheckOverwrite<string> {
1210
+ return _overwrite((input) => input.trim());
1211
+ }
1212
+ // toLowerCase
1213
+ // @__NO_SIDE_EFFECTS__
1214
+ export function _toLowerCase(): checks.$YatspCheckOverwrite<string> {
1215
+ return _overwrite((input) => input.toLowerCase());
1216
+ }
1217
+ // toUpperCase
1218
+ // @__NO_SIDE_EFFECTS__
1219
+ export function _toUpperCase(): checks.$YatspCheckOverwrite<string> {
1220
+ return _overwrite((input) => input.toUpperCase());
1221
+ }
1222
+ // slugify
1223
+ // @__NO_SIDE_EFFECTS__
1224
+ export function _slugify(): checks.$YatspCheckOverwrite<string> {
1225
+ return _overwrite((input) => util.slugify(input));
1226
+ }
1227
+
1228
+ /////// collections ///////
1229
+
1230
+ // Array
1231
+ export type $YatspArrayParams = TypeParams<schemas.$YatspArray, "element">;
1232
+ // @__NO_SIDE_EFFECTS__
1233
+ export function _array<T extends schemas.$YatspType>(
1234
+ Class: util.SchemaClass<schemas.$YatspArray>,
1235
+ element: T,
1236
+ params?: string | $YatspArrayParams
1237
+ ): schemas.$YatspArray<T> {
1238
+ return new Class({
1239
+ type: "array",
1240
+ element,
1241
+ // get element() {
1242
+ // return element;
1243
+ // },
1244
+ ...util.normalizeParams(params),
1245
+ }) as any;
1246
+ }
1247
+
1248
+ export type $YatspObjectParams = TypeParams<schemas.$YatspObject, "shape" | "catchall">;
1249
+
1250
+ // YatspUnion
1251
+ export type $YatspUnionParams = TypeParams<schemas.$YatspUnion, "options">;
1252
+ // @__NO_SIDE_EFFECTS__
1253
+ export function _union<const T extends readonly schemas.$YatspObject[]>(
1254
+ Class: util.SchemaClass<schemas.$YatspUnion>,
1255
+ options: T,
1256
+ params?: string | $YatspUnionParams
1257
+ ): schemas.$YatspUnion<T> {
1258
+ return new Class({
1259
+ type: "union",
1260
+ options,
1261
+ ...util.normalizeParams(params),
1262
+ }) as any;
1263
+ }
1264
+
1265
+ // YatspXor
1266
+ export type $YatspXorParams = TypeParams<schemas.$YatspXor, "options">;
1267
+ export function _xor<const T extends readonly schemas.$YatspObject[]>(
1268
+ Class: util.SchemaClass<schemas.$YatspXor>,
1269
+ options: T,
1270
+ params?: string | $YatspXorParams
1271
+ ): schemas.$YatspXor<T> {
1272
+ return new Class({
1273
+ type: "union",
1274
+ options,
1275
+ inclusive: false,
1276
+ ...util.normalizeParams(params),
1277
+ }) as any;
1278
+ }
1279
+
1280
+ // YatspDiscriminatedUnion
1281
+
1282
+ // The bound stops at `propValues`; it deliberately does not check that the option carries the discriminator. Any such check has to name the option's `input`, and constraining `input` in argument position forces TypeScript to resolve it while checking the call — circular for an option whose input references the union, which collapses the whole union to `any`. `$YatspDiscriminatedUnion` validates the discriminator lazily instead, when it builds its lookup map.
1283
+ //
1284
+ // Validating eagerly through `propValues` is not available: reading it runs the option's shape getters, and for a recursive option that getter references the union whose initializer is still running, so it throws `ReferenceError: Cannot access '...' before initialization`.
1285
+ //
1286
+ // `Object.keys` on the shape is recursion-safe by contrast — it lists the keys without invoking them — so an eager check is reachable. It was tried and reverted: a key list derived from the shape cannot be kept in agreement with `shape` itself, which resolves lazily over the object the caller passed and then freezes to a copy, and it charged every object schema construction time and memory for a check only this one type reads.
1287
+ //
1288
+ // `_Disc` is unused and retained only so `$YatspTypeDiscriminable<"kind">` keeps compiling for external callers.
1289
+ export interface $YatspTypeDiscriminableInternals<_Disc extends string = string> extends schemas._$YatspTypeInternals {
1290
+ propValues: util.PropValues;
1291
+ }
1292
+
1293
+ export interface $YatspTypeDiscriminable<_Disc extends string = string> extends schemas.SomeType {
1294
+ _yatsp: $YatspTypeDiscriminableInternals;
1295
+ }
1296
+
1297
+ export type $YatspDiscriminatedUnionParams = TypeParams<schemas.$YatspDiscriminatedUnion, "options" | "discriminator">;
1298
+ // @__NO_SIDE_EFFECTS__
1299
+ export function _discriminatedUnion<
1300
+ Types extends [$YatspTypeDiscriminable, ...$YatspTypeDiscriminable[]],
1301
+ Disc extends string,
1302
+ >(
1303
+ Class: util.SchemaClass<schemas.$YatspDiscriminatedUnion>,
1304
+ discriminator: Disc,
1305
+ options: Types,
1306
+ params?: string | $YatspDiscriminatedUnionParams
1307
+ ): schemas.$YatspDiscriminatedUnion<Types, Disc> {
1308
+ return new Class({
1309
+ type: "union",
1310
+ options: options as any as schemas.$YatspType[],
1311
+ discriminator,
1312
+ ...util.normalizeParams(params),
1313
+ }) as any;
1314
+ }
1315
+
1316
+ // YatspIntersection
1317
+ export type $YatspIntersectionParams = TypeParams<schemas.$YatspIntersection, "left" | "right">;
1318
+ // @__NO_SIDE_EFFECTS__
1319
+ export function _intersection<T extends schemas.$YatspObject, U extends schemas.$YatspObject>(
1320
+ Class: util.SchemaClass<schemas.$YatspIntersection>,
1321
+ left: T,
1322
+ right: U
1323
+ ): schemas.$YatspIntersection<T, U> {
1324
+ return new Class({
1325
+ type: "intersection",
1326
+ left,
1327
+ right,
1328
+ }) as any;
1329
+ }
1330
+
1331
+ // YatspTuple
1332
+ export type $YatspTupleParams = TypeParams<schemas.$YatspTuple, "items" | "rest">;
1333
+ // @__NO_SIDE_EFFECTS__
1334
+ export function _tuple<T extends readonly [schemas.$YatspType, ...schemas.$YatspType[]]>(
1335
+ Class: util.SchemaClass<schemas.$YatspTuple>,
1336
+ items: T,
1337
+ params?: string | $YatspTupleParams
1338
+ ): schemas.$YatspTuple<T, null>;
1339
+ // @__NO_SIDE_EFFECTS__
1340
+ export function _tuple<
1341
+ T extends readonly [schemas.$YatspType, ...schemas.$YatspType[]],
1342
+ Rest extends schemas.$YatspType,
1343
+ >(
1344
+ Class: util.SchemaClass<schemas.$YatspTuple>,
1345
+ items: T,
1346
+ rest: Rest,
1347
+ params?: string | $YatspTupleParams
1348
+ ): schemas.$YatspTuple<T, Rest>;
1349
+ // export function _tuple(
1350
+ // Class: util.SchemaClass<schemas.$YatspTuple>,
1351
+ // items: [],
1352
+ // params?: string | $YatspTupleParams
1353
+ // ): schemas.$YatspTuple<[], null>;
1354
+ // @__NO_SIDE_EFFECTS__
1355
+ export function _tuple(
1356
+ Class: util.SchemaClass<schemas.$YatspTuple>,
1357
+ items: schemas.$YatspType[],
1358
+ _paramsOrRest?: string | $YatspTupleParams | schemas.$YatspType,
1359
+ _params?: string | $YatspTupleParams
1360
+ ) {
1361
+ const hasRest = _paramsOrRest instanceof schemas.$YatspType;
1362
+ const params = hasRest ? _params : _paramsOrRest;
1363
+ const rest = hasRest ? _paramsOrRest : null;
1364
+ return new Class({
1365
+ type: "tuple",
1366
+ items,
1367
+ rest,
1368
+ ...util.normalizeParams(params),
1369
+ });
1370
+ }
1371
+
1372
+ // YatspRecord
1373
+ export type $YatspRecordParams = TypeParams<schemas.$YatspRecord, "keyType" | "valueType" | "partial">;
1374
+ // @__NO_SIDE_EFFECTS__
1375
+ export function _record<Key extends schemas.$YatspRecordKey, Value extends schemas.$YatspObject>(
1376
+ Class: util.SchemaClass<schemas.$YatspRecord>,
1377
+ keyType: Key,
1378
+ valueType: Value,
1379
+ params?: string | $YatspRecordParams
1380
+ ): schemas.$YatspRecord<Key, Value> {
1381
+ return new Class({
1382
+ type: "record",
1383
+ keyType,
1384
+ valueType,
1385
+ ...util.normalizeParams(params),
1386
+ }) as any;
1387
+ }
1388
+
1389
+ // YatspMap
1390
+ export type $YatspMapParams = TypeParams<schemas.$YatspMap, "keyType" | "valueType">;
1391
+ // @__NO_SIDE_EFFECTS__
1392
+ export function _map<Key extends schemas.$YatspObject, Value extends schemas.$YatspObject>(
1393
+ Class: util.SchemaClass<schemas.$YatspMap>,
1394
+ keyType: Key,
1395
+ valueType: Value,
1396
+ params?: string | $YatspMapParams
1397
+ ): schemas.$YatspMap<Key, Value> {
1398
+ return new Class({
1399
+ type: "map",
1400
+ keyType,
1401
+ valueType,
1402
+ ...util.normalizeParams(params),
1403
+ }) as any;
1404
+ }
1405
+
1406
+ // YatspSet
1407
+ export type $YatspSetParams = TypeParams<schemas.$YatspSet, "valueType">;
1408
+ // @__NO_SIDE_EFFECTS__
1409
+ export function _set<Value extends schemas.$YatspObject>(
1410
+ Class: util.SchemaClass<schemas.$YatspSet>,
1411
+ valueType: Value,
1412
+ params?: string | $YatspSetParams
1413
+ ): schemas.$YatspSet<Value> {
1414
+ return new Class({
1415
+ type: "set",
1416
+ valueType,
1417
+ ...util.normalizeParams(params),
1418
+ }) as any;
1419
+ }
1420
+
1421
+ // YatspEnum
1422
+ export type $YatspEnumParams = TypeParams<schemas.$YatspEnum, "entries">;
1423
+ // @__NO_SIDE_EFFECTS__
1424
+ export function _enum<const T extends string[]>(
1425
+ Class: util.SchemaClass<schemas.$YatspEnum>,
1426
+ values: T,
1427
+ params?: string | $YatspEnumParams
1428
+ ): schemas.$YatspEnum<util.ToEnum<T[number]>>;
1429
+ // @__NO_SIDE_EFFECTS__
1430
+ export function _enum<T extends util.EnumLike>(
1431
+ Class: util.SchemaClass<schemas.$YatspEnum>,
1432
+ entries: T,
1433
+ params?: string | $YatspEnumParams
1434
+ ): schemas.$YatspEnum<T>;
1435
+ // @__NO_SIDE_EFFECTS__
1436
+ export function _enum(Class: util.SchemaClass<schemas.$YatspEnum>, values: any, params?: string | $YatspEnumParams) {
1437
+ const entries: any = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
1438
+ // if (Array.isArray(values)) {
1439
+ // for (const value of values) {
1440
+ // entries[value] = value;
1441
+ // }
1442
+ // } else {
1443
+ // Object.assign(entries, values);
1444
+ // }
1445
+ // const entries: util.EnumLike = {};
1446
+ // for (const val of values) {
1447
+ // entries[val] = val;
1448
+ // }
1449
+
1450
+ return new Class({
1451
+ type: "enum",
1452
+ entries,
1453
+ ...util.normalizeParams(params),
1454
+ }) as any;
1455
+ }
1456
+
1457
+ // @__NO_SIDE_EFFECTS__
1458
+ /** @deprecated This API has been merged into `z.enum()`. Use `z.enum()` instead.
1459
+ *
1460
+ * ```ts
1461
+ * enum Colors { red, green, blue }
1462
+ * z.enum(Colors);
1463
+ * ```
1464
+ */
1465
+ export function _nativeEnum<T extends util.EnumLike>(
1466
+ Class: util.SchemaClass<schemas.$YatspEnum>,
1467
+ entries: T,
1468
+ params?: string | $YatspEnumParams
1469
+ ): schemas.$YatspEnum<T> {
1470
+ return new Class({
1471
+ type: "enum",
1472
+ entries,
1473
+ ...util.normalizeParams(params),
1474
+ }) as any;
1475
+ }
1476
+
1477
+ // YatspLiteral
1478
+ export type $YatspLiteralParams = TypeParams<schemas.$YatspLiteral, "values">;
1479
+ export function _literal<const T extends Array<util.Literal>>(
1480
+ Class: util.SchemaClass<schemas.$YatspLiteral>,
1481
+ value: T,
1482
+ params?: string | $YatspLiteralParams
1483
+ ): schemas.$YatspLiteral<T[number]>;
1484
+ export function _literal<const T extends util.Literal>(
1485
+ Class: util.SchemaClass<schemas.$YatspLiteral>,
1486
+ value: T,
1487
+ params?: string | $YatspLiteralParams
1488
+ ): schemas.$YatspLiteral<T>;
1489
+ // @__NO_SIDE_EFFECTS__
1490
+ export function _literal(Class: util.SchemaClass<schemas.$YatspLiteral>, value: any, params: any) {
1491
+ return new Class({
1492
+ type: "literal",
1493
+ values: Array.isArray(value) ? value : [value],
1494
+ ...util.normalizeParams(params),
1495
+ });
1496
+ }
1497
+
1498
+ // YatspFile
1499
+ export type $YatspFileParams = TypeParams<schemas.$YatspFile>;
1500
+ // @__NO_SIDE_EFFECTS__
1501
+ export function _file(
1502
+ Class: util.SchemaClass<schemas.$YatspFile>,
1503
+ params?: string | $YatspFileParams
1504
+ ): schemas.$YatspFile {
1505
+ return new Class({
1506
+ type: "file",
1507
+ ...util.normalizeParams(params),
1508
+ });
1509
+ }
1510
+
1511
+ // YatspTransform
1512
+ export type $YatspTransformParams = TypeParams<schemas.$YatspTransform, "transform">;
1513
+ // @__NO_SIDE_EFFECTS__
1514
+ export function _transform<I = unknown, O = I>(
1515
+ Class: util.SchemaClass<schemas.$YatspTransform>,
1516
+ fn: (input: I, ctx?: schemas.ParsePayload) => O
1517
+ ): schemas.$YatspTransform<Awaited<O>, I> {
1518
+ return new Class({
1519
+ type: "transform",
1520
+ transform: fn as any,
1521
+ }) as any;
1522
+ }
1523
+
1524
+ // YatspOptional
1525
+ export type $YatspOptionalParams = TypeParams<schemas.$YatspOptional, "innerType">;
1526
+ // @__NO_SIDE_EFFECTS__
1527
+ export function _optional<T extends schemas.$YatspObject>(
1528
+ Class: util.SchemaClass<schemas.$YatspOptional>,
1529
+ innerType: T
1530
+ ): schemas.$YatspOptional<T> {
1531
+ return new Class({
1532
+ type: "optional",
1533
+ innerType,
1534
+ }) as any;
1535
+ }
1536
+
1537
+ // YatspNullable
1538
+ export type $YatspNullableParams = TypeParams<schemas.$YatspNullable, "innerType">;
1539
+ // @__NO_SIDE_EFFECTS__
1540
+ export function _nullable<T extends schemas.$YatspObject>(
1541
+ Class: util.SchemaClass<schemas.$YatspNullable>,
1542
+ innerType: T
1543
+ ): schemas.$YatspNullable<T> {
1544
+ return new Class({
1545
+ type: "nullable",
1546
+ innerType,
1547
+ }) as any;
1548
+ }
1549
+
1550
+ // YatspDefault
1551
+ export type $YatspDefaultParams = TypeParams<schemas.$YatspDefault, "innerType" | "defaultValue">;
1552
+ // @__NO_SIDE_EFFECTS__
1553
+ export function _default<T extends schemas.$YatspObject>(
1554
+ Class: util.SchemaClass<schemas.$YatspDefault>,
1555
+ innerType: T,
1556
+ defaultValue: util.NoUndefined<core.output<T>> | (() => util.NoUndefined<core.output<T>>)
1557
+ ): schemas.$YatspDefault<T> {
1558
+ return new Class({
1559
+ type: "default",
1560
+ innerType,
1561
+ get defaultValue() {
1562
+ return typeof defaultValue === "function" ? (defaultValue as Function)() : util.shallowClone(defaultValue);
1563
+ },
1564
+ }) as any;
1565
+ }
1566
+
1567
+ // YatspNonOptional
1568
+ export type $YatspNonOptionalParams = TypeParams<schemas.$YatspNonOptional, "innerType">;
1569
+ // @__NO_SIDE_EFFECTS__
1570
+ export function _nonoptional<T extends schemas.$YatspObject>(
1571
+ Class: util.SchemaClass<schemas.$YatspNonOptional>,
1572
+ innerType: T,
1573
+ params?: string | $YatspNonOptionalParams
1574
+ ): schemas.$YatspNonOptional<T> {
1575
+ return new Class({
1576
+ type: "nonoptional",
1577
+ innerType,
1578
+ ...util.normalizeParams(params),
1579
+ }) as any;
1580
+ }
1581
+
1582
+ // YatspSuccess
1583
+ export type $YatspSuccessParams = TypeParams<schemas.$YatspSuccess, "innerType">;
1584
+ // @__NO_SIDE_EFFECTS__
1585
+ export function _success<T extends schemas.$YatspObject>(
1586
+ Class: util.SchemaClass<schemas.$YatspSuccess>,
1587
+ innerType: T
1588
+ ): schemas.$YatspSuccess<T> {
1589
+ return new Class({
1590
+ type: "success",
1591
+ innerType,
1592
+ }) as any;
1593
+ }
1594
+
1595
+ // YatspCatch
1596
+ export type $YatspCatchParams = TypeParams<schemas.$YatspCatch, "innerType" | "catchValue">;
1597
+ // @__NO_SIDE_EFFECTS__
1598
+ export function _catch<T extends schemas.$YatspObject>(
1599
+ Class: util.SchemaClass<schemas.$YatspCatch>,
1600
+ innerType: T,
1601
+ catchValue: core.output<T> | ((ctx: schemas.$YatspCatchCtx) => core.output<T>)
1602
+ ): schemas.$YatspCatch<T> {
1603
+ return new Class({
1604
+ type: "catch",
1605
+ innerType,
1606
+ catchValue: (typeof catchValue === "function" ? catchValue : util.constantCatch(catchValue)) as any,
1607
+ }) as any;
1608
+ }
1609
+
1610
+ // YatspPipe
1611
+ export type $YatspPipeParams = TypeParams<schemas.$YatspPipe, "in" | "out">;
1612
+ // @__NO_SIDE_EFFECTS__
1613
+ export function _pipe<
1614
+ const A extends schemas.$YatspType,
1615
+ B extends schemas.$YatspType<unknown, core.output<A>> = schemas.$YatspType<unknown, core.output<A>>,
1616
+ >(
1617
+ Class: util.SchemaClass<schemas.$YatspPipe>,
1618
+ in_: A,
1619
+ out: B | schemas.$YatspType<unknown, core.output<A>>
1620
+ ): schemas.$YatspPipe<A, B> {
1621
+ return new Class({
1622
+ type: "pipe",
1623
+ in: in_,
1624
+ out,
1625
+ }) as any;
1626
+ }
1627
+
1628
+ // YatspReadonly
1629
+ export type $YatspReadonlyParams = TypeParams<schemas.$YatspReadonly, "innerType">;
1630
+ // @__NO_SIDE_EFFECTS__
1631
+ export function _readonly<T extends schemas.$YatspObject>(
1632
+ Class: util.SchemaClass<schemas.$YatspReadonly>,
1633
+ innerType: T
1634
+ ): schemas.$YatspReadonly<T> {
1635
+ return new Class({
1636
+ type: "readonly",
1637
+ innerType,
1638
+ }) as any;
1639
+ }
1640
+
1641
+ // YatspTemplateLiteral
1642
+ export type $YatspTemplateLiteralParams = TypeParams<schemas.$YatspTemplateLiteral, "parts">;
1643
+ // @__NO_SIDE_EFFECTS__
1644
+ export function _templateLiteral<const Parts extends schemas.$YatspTemplateLiteralPart[]>(
1645
+ Class: util.SchemaClass<schemas.$YatspTemplateLiteral>,
1646
+ parts: Parts,
1647
+ params?: string | $YatspTemplateLiteralParams
1648
+ ): schemas.$YatspTemplateLiteral<schemas.$PartsToTemplateLiteral<Parts>> {
1649
+ return new Class({
1650
+ type: "template_literal",
1651
+ parts,
1652
+ ...util.normalizeParams(params),
1653
+ }) as any;
1654
+ }
1655
+
1656
+ // YatspLazy
1657
+ export type $YatspLazyParams = TypeParams<schemas.$YatspLazy, "getter">;
1658
+ // @__NO_SIDE_EFFECTS__
1659
+ export function _lazy<T extends schemas.$YatspType>(
1660
+ Class: util.SchemaClass<schemas.$YatspLazy>,
1661
+ getter: () => T
1662
+ ): schemas.$YatspLazy<T> {
1663
+ return new Class({
1664
+ type: "lazy",
1665
+ getter,
1666
+ }) as any;
1667
+ }
1668
+
1669
+ // YatspPromise
1670
+ export type $YatspPromiseParams = TypeParams<schemas.$YatspPromise, "innerType">;
1671
+ // @__NO_SIDE_EFFECTS__
1672
+ export function _promise<T extends schemas.$YatspObject>(
1673
+ Class: util.SchemaClass<schemas.$YatspPromise>,
1674
+ innerType: T
1675
+ ): schemas.$YatspPromise<T> {
1676
+ return new Class({
1677
+ type: "promise",
1678
+ innerType,
1679
+ }) as any;
1680
+ }
1681
+
1682
+ // YatspCustom
1683
+ export type $YatspCustomParams = CheckTypeParams<schemas.$YatspCustom, "fn">;
1684
+ // @__NO_SIDE_EFFECTS__
1685
+ export function _custom<O = unknown, I = O>(
1686
+ Class: util.SchemaClass<schemas.$YatspCustom>,
1687
+ fn: (data: O) => unknown,
1688
+ _params: string | $YatspCustomParams | undefined
1689
+ ): schemas.$YatspCustom<O, I> {
1690
+ const norm = util.normalizeParams(_params);
1691
+ norm.abort ??= true; // default to abort:false
1692
+ const schema = new Class({
1693
+ type: "custom",
1694
+ check: "custom",
1695
+ fn: fn as any,
1696
+ ...norm,
1697
+ });
1698
+
1699
+ return schema as any;
1700
+ }
1701
+
1702
+ // same as _custom but defaults to abort:false
1703
+ // @__NO_SIDE_EFFECTS__
1704
+ export function _refine<O = unknown, I = O>(
1705
+ Class: util.SchemaClass<schemas.$YatspCustom>,
1706
+ fn: (data: O) => unknown,
1707
+ _params: string | $YatspCustomParams | undefined
1708
+ ): schemas.$YatspCustom<O, I> {
1709
+ const schema = new Class({
1710
+ type: "custom",
1711
+ check: "custom",
1712
+ fn: fn as any,
1713
+ ...util.normalizeParams(_params),
1714
+ });
1715
+
1716
+ return schema as any;
1717
+ }
1718
+
1719
+ export type $YatspSuperRefineIssue<T extends errors.$YatspIssueBase = errors.$YatspIssue> = T extends any
1720
+ ? RawIssue<T>
1721
+ : never;
1722
+ type RawIssue<T extends errors.$YatspIssueBase> = T extends any
1723
+ ? util.Flatten<
1724
+ util.MakePartial<T, "message" | "path"> & {
1725
+ /** The schema or check that originated this issue. */
1726
+ readonly inst?: schemas.$YatspType | checks.$YatspCheck;
1727
+ /** If `true`, Yatsp will execute subsequent checks/refinements instead of immediately aborting */
1728
+ readonly continue?: boolean | undefined;
1729
+ } & Record<string, unknown>
1730
+ >
1731
+ : never;
1732
+
1733
+ export interface $RefinementCtx<T = unknown> extends schemas.ParsePayload<T> {
1734
+ addIssue(arg: string | $YatspSuperRefineIssue): void;
1735
+ }
1736
+
1737
+ export interface $YatspSuperRefineParams {
1738
+ /** If provided, the refinement runs only when this returns `true`. By default, it is skipped if prior parsing produced aborting issues. */
1739
+ when?: ((payload: schemas.ParsePayload) => boolean) | undefined;
1740
+ }
1741
+
1742
+ // @__NO_SIDE_EFFECTS__
1743
+ export function _superRefine<T>(
1744
+ fn: (arg: T, payload: $RefinementCtx<T>) => void | Promise<void>,
1745
+ params?: $YatspSuperRefineParams
1746
+ ): checks.$YatspCheck<T> {
1747
+ const ch = _check<T>((payload) => {
1748
+ (payload as $RefinementCtx).addIssue = (issue) => {
1749
+ if (typeof issue === "string") {
1750
+ payload.issues.push(util.issue(issue, payload.value, ch._yatsp.def));
1751
+ } else {
1752
+ // for Yatsp 3 backwards compatibility
1753
+ const _issue: any = issue;
1754
+ if (_issue.fatal) _issue.continue = false;
1755
+ _issue.code ??= "custom";
1756
+ if (!("input" in _issue)) _issue.input = payload.value;
1757
+ _issue.inst ??= ch;
1758
+ _issue.continue ??= !ch._yatsp.def.abort; // abort is always undefined, so this is always true...
1759
+ payload.issues.push(util.issue(_issue));
1760
+ }
1761
+ };
1762
+
1763
+ return fn(payload.value, payload as $RefinementCtx<T>);
1764
+ }, params);
1765
+ return ch;
1766
+ }
1767
+
1768
+ // @__NO_SIDE_EFFECTS__
1769
+ export function _check<O = unknown>(
1770
+ fn: schemas.CheckFn<O>,
1771
+ params?: string | $YatspCustomParams
1772
+ ): checks.$YatspCheck<O> {
1773
+ const ch = new checks.$YatspCheck({
1774
+ check: "custom",
1775
+ ...util.normalizeParams(params),
1776
+ });
1777
+
1778
+ ch._yatsp.check = fn;
1779
+ return ch;
1780
+ }
1781
+
1782
+ // @__NO_SIDE_EFFECTS__
1783
+ export function describe<T>(description: string): checks.$YatspCheck<T> {
1784
+ const ch = new checks.$YatspCheck({ check: "describe" });
1785
+ ch._yatsp.onattach = [
1786
+ (inst) => {
1787
+ const existing = registries.globalRegistry.get(inst) ?? {};
1788
+ registries.globalRegistry.add(inst, { ...existing, description });
1789
+ },
1790
+ ];
1791
+ ch._yatsp.check = () => {}; // no-op check
1792
+ return ch;
1793
+ }
1794
+
1795
+ // @__NO_SIDE_EFFECTS__
1796
+ export function meta<T>(metadata: registries.GlobalMeta): checks.$YatspCheck<T> {
1797
+ const ch = new checks.$YatspCheck({ check: "meta" });
1798
+ ch._yatsp.onattach = [
1799
+ (inst) => {
1800
+ const existing = registries.globalRegistry.get(inst) ?? {};
1801
+ registries.globalRegistry.add(inst, { ...existing, ...metadata });
1802
+ },
1803
+ ];
1804
+ ch._yatsp.check = () => {}; // no-op check
1805
+ return ch;
1806
+ }
1807
+
1808
+ // export type $YatspCustomParams = CheckTypeParams<schemas.$YatspCustom, "fn">
1809
+
1810
+ ///////// STRINGBOOL /////////
1811
+
1812
+ // stringbool
1813
+ export interface $YatspStringBoolParams extends TypeParams {
1814
+ truthy?: string[];
1815
+ falsy?: string[];
1816
+ /**
1817
+ * Options: `"sensitive"`, `"insensitive"`
1818
+ *
1819
+ * @default `"insensitive"`
1820
+ */
1821
+ case?: "sensitive" | "insensitive" | undefined;
1822
+ }
1823
+
1824
+ // @__NO_SIDE_EFFECTS__
1825
+ export function _stringbool(
1826
+ Classes: {
1827
+ Codec?: typeof schemas.$YatspCodec;
1828
+ Boolean?: typeof schemas.$YatspBoolean;
1829
+ String?: typeof schemas.$YatspString;
1830
+ },
1831
+ _params?: string | $YatspStringBoolParams
1832
+ ): schemas.$YatspCodec<schemas.$YatspString, schemas.$YatspBoolean> {
1833
+ const params = util.normalizeParams(_params);
1834
+
1835
+ let truthyArray = params.truthy ?? ["true", "1", "yes", "on", "y", "enabled"];
1836
+ let falsyArray = params.falsy ?? ["false", "0", "no", "off", "n", "disabled"];
1837
+ if (params.case !== "sensitive") {
1838
+ truthyArray = truthyArray.map((v) => (typeof v === "string" ? v.toLowerCase() : v));
1839
+ falsyArray = falsyArray.map((v) => (typeof v === "string" ? v.toLowerCase() : v));
1840
+ }
1841
+
1842
+ const truthySet = new Set(truthyArray);
1843
+ const falsySet = new Set(falsyArray);
1844
+
1845
+ const _Codec = Classes.Codec ?? schemas.$YatspCodec;
1846
+ const _Boolean = Classes.Boolean ?? schemas.$YatspBoolean;
1847
+ const _String = Classes.String ?? schemas.$YatspString;
1848
+
1849
+ const stringSchema = new _String({ type: "string", error: params.error });
1850
+ const booleanSchema = new _Boolean({ type: "boolean", error: params.error });
1851
+
1852
+ const codec = new _Codec({
1853
+ type: "pipe",
1854
+ in: stringSchema as any,
1855
+ out: booleanSchema as any,
1856
+ transform: ((input: string, payload: schemas.ParsePayload<string>) => {
1857
+ let data: string = input;
1858
+ if (params.case !== "sensitive") data = data.toLowerCase();
1859
+ if (truthySet.has(data)) {
1860
+ return true;
1861
+ } else if (falsySet.has(data)) {
1862
+ return false;
1863
+ } else {
1864
+ payload.issues.push({
1865
+ code: "invalid_value",
1866
+ expected: "stringbool",
1867
+ values: [...truthySet, ...falsySet],
1868
+ input: payload.value,
1869
+ inst: codec,
1870
+ continue: false,
1871
+ });
1872
+ return {} as never;
1873
+ }
1874
+ }) as any,
1875
+ reverseTransform: ((input: boolean, _payload: schemas.ParsePayload<boolean>) => {
1876
+ if (input === true) {
1877
+ return truthyArray[0] || "true";
1878
+ } else {
1879
+ return falsyArray[0] || "false";
1880
+ }
1881
+ }) as any,
1882
+ error: params.error,
1883
+ }) as any;
1884
+
1885
+ codec._yatsp.bag.truthy = truthyArray;
1886
+ codec._yatsp.bag.falsy = falsyArray;
1887
+ codec._yatsp.bag.case = params.case ?? "insensitive";
1888
+
1889
+ return codec;
1890
+ }
1891
+
1892
+ // @__NO_SIDE_EFFECTS__
1893
+ export function _stringFormat<Format extends string>(
1894
+ Class: typeof schemas.$YatspCustomStringFormat,
1895
+ format: Format,
1896
+ fnOrRegex: ((arg: string) => util.MaybeAsync<unknown>) | RegExp,
1897
+ _params: string | $YatspStringFormatParams = {}
1898
+ ): schemas.$YatspCustomStringFormat<Format> {
1899
+ const params = util.normalizeParams(_params);
1900
+ const def: schemas.$YatspCustomStringFormatDef = {
1901
+ check: "string_format",
1902
+ type: "string",
1903
+ format,
1904
+ fn: typeof fnOrRegex === "function" ? fnOrRegex : (val) => fnOrRegex.test(val),
1905
+ ...params,
1906
+ };
1907
+ if (fnOrRegex instanceof RegExp) {
1908
+ def.pattern = fnOrRegex;
1909
+ }
1910
+
1911
+ const inst = new Class(def);
1912
+ return inst as any;
1913
+ }