@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,1440 @@
1
+ import { randomBytes } from "node:crypto";
2
+ import { expect, expectTypeOf, test } from "vitest";
3
+
4
+ import * as z from "yatsp/v4";
5
+
6
+ const minFive = z.string().min(5, "min5");
7
+ const maxFive = z.string().max(5, "max5");
8
+ const justFive = z.string().length(5);
9
+ const nonempty = z.string().min(1, "nonempty");
10
+ const includes = z.string().includes("includes");
11
+ const includesFromIndex2 = z.string().includes("includes", { position: 2 });
12
+ const startsWith = z.string().startsWith("startsWith");
13
+ const endsWith = z.string().endsWith("endsWith");
14
+
15
+ test("string factory checks", async () => {
16
+ const schema = z.string({ checks: [z.minLength(1), z.maxLength(3)] as const });
17
+ const chained = z.string().min(1).max(3);
18
+ expectTypeOf<z.output<typeof schema>>().toEqualTypeOf<string>();
19
+ for (const value of ["", "ab", "abcd", 1, undefined]) {
20
+ expect(z.validate(schema, value)).toBe(z.validate(chained, value));
21
+ expect(schema.safeParse(value)).toEqual(chained.safeParse(value));
22
+ }
23
+ expect(z.toJSONSchema(schema)).toEqual(z.toJSONSchema(chained));
24
+ expect(schema.minLength).toBe(1);
25
+ expect(schema.maxLength).toBe(3);
26
+ expect(schema._yatsp.parent).toBeUndefined();
27
+ expect([...schema._yatsp.traits]).toEqual([...chained._yatsp.traits]);
28
+ const extended = schema.max(2);
29
+ expect(extended._yatsp.parent).toBe(schema);
30
+ expect(z.validate(schema, "abc")).toBe(true);
31
+ expect(z.validate(extended, "abc")).toBe(false);
32
+ const coerce = z.coerce.string({ checks: [z.minLength(2)] });
33
+ expect(coerce.parse(12)).toBe("12");
34
+ expect(z.validate(coerce, 1)).toBe(false);
35
+ const asyncSchema = z.string({
36
+ checks: [
37
+ z.check<string>(async (ctx) => {
38
+ if (ctx.value !== "ok") ctx.issues.push({ code: "custom", input: ctx.value });
39
+ }),
40
+ ],
41
+ });
42
+ expect(await asyncSchema.safeParseAsync("ok")).toEqual({ success: true, data: "ok" });
43
+ expect((await asyncSchema.safeParseAsync("bad")).success).toBe(false);
44
+ // @ts-expect-error numeric checks cannot validate strings
45
+ z.string({ checks: [z.gte(1)] });
46
+ });
47
+
48
+ test("factory checks snapshot caller arrays", () => {
49
+ for (const factory of [z.string, z.coerce.string]) {
50
+ for (const initial of [[], [z.minLength(1)]]) {
51
+ const schema = factory({ checks: initial });
52
+ let reads = 0;
53
+ const getterSchema = factory({
54
+ get checks() {
55
+ if (++reads > 1) throw new Error("checks read twice");
56
+ return initial;
57
+ },
58
+ });
59
+ expect(reads).toBe(1);
60
+ expect(z.validate(getterSchema, "long")).toBe(true);
61
+ const before = z.toJSONSchema(schema);
62
+ initial.push(z.minLength(10));
63
+ expect(schema._yatsp.def.checks).not.toBe(initial);
64
+ expect(z.validate(schema, "long")).toBe(true);
65
+ expect(z.validate(z.compile(schema), "long")).toBe(true);
66
+ expect(z.toJSONSchema(schema)).toEqual(before);
67
+ expect(z.validate(schema.check(z.minLength(2)), "long")).toBe(true);
68
+ }
69
+ }
70
+ });
71
+
72
+ test("length checks", () => {
73
+ minFive.parse("12345");
74
+ minFive.parse("123456");
75
+ maxFive.parse("12345");
76
+ maxFive.parse("1234");
77
+ nonempty.parse("1");
78
+ justFive.parse("12345");
79
+
80
+ expect(() => minFive.parse("1234")).toThrow();
81
+ expect(() => maxFive.parse("123456")).toThrow();
82
+ expect(() => nonempty.parse("")).toThrow();
83
+ expect(() => justFive.parse("1234")).toThrow();
84
+ expect(() => justFive.parse("123456")).toThrow();
85
+ });
86
+
87
+ test("includes", () => {
88
+ includes.parse("XincludesXX");
89
+ includesFromIndex2.parse("XXXincludesXX");
90
+
91
+ expect(() => includes.parse("XincludeXX")).toThrow();
92
+ expect(() => includesFromIndex2.parse("XincludesXX")).toThrow();
93
+ });
94
+
95
+ test("includes with string error message", () => {
96
+ const schema = z.string().includes("test", "must contain test");
97
+ schema.parse("this is a test");
98
+
99
+ expect(schema.safeParse("this is invalid")).toMatchInlineSnapshot(`
100
+ {
101
+ "error": [YatspError: [
102
+ {
103
+ "origin": "string",
104
+ "code": "invalid_format",
105
+ "format": "includes",
106
+ "includes": "test",
107
+ "path": [],
108
+ "message": "must contain test"
109
+ }
110
+ ]],
111
+ "success": false,
112
+ }
113
+ `);
114
+ });
115
+
116
+ test("startswith/endswith", () => {
117
+ startsWith.parse("startsWithX");
118
+ endsWith.parse("XendsWith");
119
+
120
+ expect(() => startsWith.parse("x")).toThrow();
121
+ expect(() => endsWith.parse("x")).toThrow();
122
+ });
123
+
124
+ test("email validations", () => {
125
+ const validEmails = [
126
+ `email@domain.com`,
127
+ `firstname.lastname@domain.com`,
128
+ `email@subdomain.domain.com`,
129
+ `firstname+lastname@domain.com`,
130
+ `1234567890@domain.com`,
131
+ `email@domain-one.com`,
132
+ `_______@domain.com`,
133
+ `email@domain.name`,
134
+ `email@domain.co.jp`,
135
+ `firstname-lastname@domain.com`,
136
+ `very.common@example.com`,
137
+ `disposable.style.email.with+symbol@example.com`,
138
+ `other.email-with-hyphen@example.com`,
139
+ `fully-qualified-domain@example.com`,
140
+ `user.name+tag+sorting@example.com`,
141
+ `x@example.com`,
142
+ `mojojojo@asdf.example.com`,
143
+ `example-indeed@strange-example.com`,
144
+ `example@s.example`,
145
+ `user-@example.org`,
146
+ `user@my-example.com`,
147
+ `a@b.cd`,
148
+ `work+user@mail.com`,
149
+ `tom@test.te-st.com`,
150
+ `something@subdomain.domain-with-hyphens.tld`,
151
+ `common'name@domain.com`,
152
+ `francois@etu.inp-n7.fr`,
153
+ ];
154
+ const invalidEmails = [
155
+ // no "printable characters"
156
+ // `user%example.com@example.org`,
157
+ // `mailhost!username@example.org`,
158
+ // `test/test@test.com`,
159
+
160
+ // double @
161
+ `francois@@etu.inp-n7.fr`,
162
+ // do not support quotes
163
+ `"email"@domain.com`,
164
+ `"e asdf sadf ?<>ail"@domain.com`,
165
+ `" "@example.org`,
166
+ `"john..doe"@example.org`,
167
+ `"very.(),:;<>[]\".VERY.\"very@\\ \"very\".unusual"@strange.example.com`,
168
+ // do not support comma
169
+ `a,b@domain.com`,
170
+
171
+ // do not support IPv4
172
+ `email@123.123.123.123`,
173
+ `email@[123.123.123.123]`,
174
+ `postmaster@123.123.123.123`,
175
+ `user@[68.185.127.196]`,
176
+ `ipv4@[85.129.96.247]`,
177
+ `valid@[79.208.229.53]`,
178
+ `valid@[255.255.255.255]`,
179
+ `valid@[255.0.55.2]`,
180
+ `valid@[255.0.55.2]`,
181
+
182
+ // do not support ipv6
183
+ `hgrebert0@[IPv6:4dc8:ac7:ce79:8878:1290:6098:5c50:1f25]`,
184
+ `bshapiro4@[IPv6:3669:c709:e981:4884:59a3:75d1:166b:9ae]`,
185
+ `jsmith@[IPv6:2001:db8::1]`,
186
+ `postmaster@[IPv6:2001:0db8:85a3:0000:0000:8a2e:0370:7334]`,
187
+ `postmaster@[IPv6:2001:0db8:85a3:0000:0000:8a2e:0370:192.168.1.1]`,
188
+
189
+ // microsoft test cases
190
+ `plainaddress`,
191
+ `#@%^%#$@#$@#.com`,
192
+ `@domain.com`,
193
+ `Joe Smith &lt;email@domain.com&gt;`,
194
+ `email.domain.com`,
195
+ `email@domain@domain.com`,
196
+ `.email@domain.com`,
197
+ `email.@domain.com`,
198
+ `email..email@domain.com`,
199
+ `あいうえお@domain.com`,
200
+ `email@domain.com (Joe Smith)`,
201
+ `email@domain`,
202
+ `email@-domain.com`,
203
+ `email@111.222.333.44444`,
204
+ `email@domain..com`,
205
+ `Abc.example.com`,
206
+ `A@b@c@example.com`,
207
+ `colin..hacks@domain.com`,
208
+ `a"b(c)d,e:f;g<h>i[j\k]l@example.com`,
209
+ `just"not"right@example.com`,
210
+ `this is"not\allowed@example.com`,
211
+ `this\ still\"not\\allowed@example.com`,
212
+
213
+ // random
214
+ `i_like_underscore@but_its_not_allowed_in_this_part.example.com`,
215
+ `QA[icon]CHOCOLATE[icon]@test.com`,
216
+ `invalid@-start.com`,
217
+ `invalid@end.com-`,
218
+ `a.b@c.d`,
219
+ `invalid@[1.1.1.-1]`,
220
+ `invalid@[68.185.127.196.55]`,
221
+ `temp@[192.168.1]`,
222
+ `temp@[9.18.122.]`,
223
+ `double..point@test.com`,
224
+ `asdad@test..com`,
225
+ `asdad@hghg...sd...au`,
226
+ `asdad@hghg........au`,
227
+ `invalid@[256.2.2.48]`,
228
+ `invalid@[256.2.2.48]`,
229
+ `invalid@[999.465.265.1]`,
230
+ `jkibbey4@[IPv6:82c4:19a8::70a9:2aac:557::ea69:d985:28d]`,
231
+ `mlivesay3@[9952:143f:b4df:2179:49a1:5e82:b92e:6b6]`,
232
+ `gbacher0@[IPv6:bc37:4d3f:5048:2e26:37cc:248e:df8e:2f7f:af]`,
233
+ `invalid@[IPv6:5348:4ed3:5d38:67fb:e9b:acd2:c13:192.168.256.1]`,
234
+ `test@.com`,
235
+ `aaaaaaaaaaaaaaalongemailthatcausesregexDoSvulnerability@test.c`,
236
+ ];
237
+ const emailSchema = z.string().email();
238
+
239
+ expect(
240
+ validEmails.every((email) => {
241
+ return emailSchema.safeParse(email).success;
242
+ })
243
+ ).toBe(true);
244
+ expect(
245
+ invalidEmails.every((email) => {
246
+ return emailSchema.safeParse(email).success === false;
247
+ })
248
+ ).toBe(true);
249
+ });
250
+
251
+ test("base64 validations", () => {
252
+ const validBase64Strings = [
253
+ "SGVsbG8gV29ybGQ=", // "Hello World"
254
+ "VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw==", // "This is an encoded string"
255
+ "TWFueSBoYW5kcyBtYWtlIGxpZ2h0IHdvcms=", // "Many hands make light work"
256
+ "UGF0aWVuY2UgaXMgdGhlIGtleSB0byBzdWNjZXNz", // "Patience is the key to success"
257
+ "QmFzZTY0IGVuY29kaW5nIGlzIGZ1bg==", // "Base64 encoding is fun"
258
+ "MTIzNDU2Nzg5MA==", // "1234567890"
259
+ "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXo=", // "abcdefghijklmnopqrstuvwxyz"
260
+ "QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVo=", // "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
261
+ "ISIkJSMmJyonKCk=", // "!\"#$%&'()*"
262
+ "", // Empty string is technically a valid base64
263
+ ];
264
+
265
+ for (const str of validBase64Strings) {
266
+ expect(str + z.string().base64().safeParse(str).success).toBe(`${str}true`);
267
+ }
268
+
269
+ const invalidBase64Strings = [
270
+ "12345", // Not padded correctly, not a multiple of 4 characters
271
+ "SGVsbG8gV29ybGQ", // Missing padding
272
+ "VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw", // Missing padding
273
+ "!UGF0aWVuY2UgaXMgdGhlIGtleSB0byBzdWNjZXNz", // Invalid character '!'
274
+ "?QmFzZTY0IGVuY29kaW5nIGlzIGZ1bg==", // Invalid character '?'
275
+ ".MTIzND2Nzg5MC4=", // Invalid character '.'
276
+ "QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVo", // Missing padding
277
+ // Whitespace is not part of canonical base64 (RFC 4648 §3.3) — atob() strips whitespace internally before validating, so the length check alone would accept "123 " etc.
278
+ "123 ", // bypasses length-mod-4 via trailing whitespace
279
+ "SGVsbG8gV29ybGQ= ", // trailing space
280
+ " SGVsbG8gV29ybGQ=", // leading space
281
+ "SGVsbG8gV29ybGQ=\n", // trailing newline
282
+ "SGVs bG8gV29ybGQ=", // internal space
283
+ "SGVs\nbG8gV29ybGQ=", // internal newline
284
+ "SGVs\tbG8gV29ybGQ=", // internal tab
285
+ ];
286
+
287
+ for (const str of invalidBase64Strings) {
288
+ expect(str + z.string().base64().safeParse(str).success).toBe(`${str}false`);
289
+ }
290
+ });
291
+
292
+ test("base64url validations", () => {
293
+ const base64url = z.string().base64url();
294
+
295
+ const validBase64URLStrings = [
296
+ "SGVsbG8gV29ybGQ", // "Hello World"
297
+
298
+ "VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw", // "This is an encoded string"
299
+
300
+ "TWFueSBoYW5kcyBtYWtlIGxpZ2h0IHdvcms", // "Many hands make light work"
301
+
302
+ "UGF0aWVuY2UgaXMgdGhlIGtleSB0byBzdWNjZXNz", // "Patience is the key to success"
303
+ "QmFzZTY0IGVuY29kaW5nIGlzIGZ1bg", // "Base64 encoding is fun"
304
+
305
+ "MTIzNDU2Nzg5MA", // "1234567890"
306
+
307
+ "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXo", // "abcdefghijklmnopqrstuvwxyz"
308
+
309
+ "QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVo", // "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
310
+
311
+ "ISIkJSMmJyonKCk", // "!\"#$%&'()*"
312
+
313
+ "", // Empty string is technically valid base64url
314
+ "w7_Dv8O-w74K", // ÿÿþþ
315
+ "123456",
316
+ ];
317
+
318
+ for (const str of validBase64URLStrings) {
319
+ expect(str + base64url.safeParse(str).success).toBe(`${str}true`);
320
+ }
321
+
322
+ const invalidBase64URLStrings = [
323
+ "w7/Dv8O+w74K", // Has + and / characters (is base64)
324
+ "A", // Invalid length (1 mod 4 carries no whole byte)
325
+ "12345", // Invalid length (not a multiple of 4 characters when adding allowed number of padding characters)
326
+ "12345===", // Not padded correctly
327
+ "!UGF0aWVuY2UgaXMgdGhlIGtleSB0byBzdWNjZXNz", // Invalid character '!'
328
+ "?QmFzZTY0IGVuY29kaW5nIGlzIGZ1bg==", // Invalid character '?'
329
+ ".MTIzND2Nzg5MC4=", // Invalid character '.'
330
+
331
+ // disallow valid padding
332
+ "SGVsbG8gV29ybGQ=", // "Hello World" with padding
333
+ "VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw==", // "This is an encoded string" with padding
334
+ "TWFueSBoYW5kcyBtYWtlIGxpZ2h0IHdvcms=", // "Many hands make light work" with padding
335
+ "QmFzZTY0IGVuY29kaW5nIGlzIGZ1bg==", // "Base64 encoding is fun" with padding
336
+ "MTIzNDU2Nzg5MA==", // "1234567890" with padding
337
+ "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXo=", // "abcdefghijklmnopqrstuvwxyz with padding"
338
+ "QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVo=", // "ABCDEFGHIJKLMNOPQRSTUVWXYZ" with padding
339
+ "ISIkJSMmJyonKCk=", // "!\"#$%&'()*" with padding
340
+ ];
341
+
342
+ for (const str of invalidBase64URLStrings) {
343
+ expect(str + base64url.safeParse(str).success).toBe(`${str}false`);
344
+ }
345
+ });
346
+
347
+ test("big base64 and base64url", () => {
348
+ const bigbase64 = randomBytes(1024 * 1024 * 10).toString("base64");
349
+ z.base64().parse(bigbase64);
350
+ const bigbase64url = randomBytes(1024 * 1024 * 10).toString("base64url");
351
+ z.base64url().parse(bigbase64url);
352
+
353
+ // template literals compose def.pattern and test it on every parse; the quantified block forms overflowed the regex stack here
354
+ expect(z.templateLiteral(["id-", z.base64()]).safeParse(`id-${bigbase64}`).success).toBe(true);
355
+ expect(z.templateLiteral(["id-", z.base64url()]).safeParse(`id-${bigbase64url}`).success).toBe(true);
356
+ });
357
+
358
+ test("template literal composes base64 without alternation leaks", () => {
359
+ // the ^$| alternation in regexes.base64 used to leak: "AAAA" matched with the prefix dropped and "id-AAAA" was rejected
360
+ const tl = z.templateLiteral(["id-", z.base64()]);
361
+ expect(tl.safeParse("id-AAAA").success).toBe(true);
362
+ expect(tl.safeParse("id-").success).toBe(true);
363
+ expect(tl.safeParse("AAAA").success).toBe(false);
364
+ });
365
+
366
+ function makeJwt(header: object, payload: object) {
367
+ const headerBase64 = Buffer.from(JSON.stringify(header)).toString("base64url");
368
+ const payloadBase64 = Buffer.from(JSON.stringify(payload)).toString("base64url");
369
+ const signature = "signature"; // Placeholder for the signature
370
+ return `${headerBase64}.${payloadBase64}.${signature}`;
371
+ }
372
+
373
+ test("jwt token", () => {
374
+ const jwt = z.string().jwt();
375
+ expect(() => jwt.parse("invalid")).toThrow();
376
+ expect(() => jwt.parse("invalid.invalid")).toThrow();
377
+ expect(() => jwt.parse("invalid.invalid.invalid")).toThrow();
378
+
379
+ // Valid JWTs
380
+ const es256jwt = z.string().jwt({ alg: "ES256" });
381
+ const d1 = makeJwt({ typ: "JWT", alg: "ES256" }, {});
382
+ jwt.parse(d1);
383
+ es256jwt.parse(d1);
384
+
385
+ // Invalid header
386
+ const d2 = makeJwt({}, {});
387
+ expect(() => jwt.parse(d2)).toThrow();
388
+
389
+ // Wrong algorithm
390
+ const d3 = makeJwt({ typ: "JWT", alg: "RS256" }, {});
391
+ expect(() => es256jwt.parse(d3)).toThrow();
392
+
393
+ // missing typ is fine
394
+ const d4 = makeJwt({ alg: "HS256" }, {});
395
+ jwt.parse(d4);
396
+
397
+ // type isn't JWT
398
+ const d5 = makeJwt({ typ: "SUP", alg: "HS256" }, { foo: "bar" });
399
+ expect(() => jwt.parse(d5)).toThrow();
400
+ });
401
+
402
+ test("url validations", () => {
403
+ const url = z.string().url();
404
+ url.parse("http://google.com");
405
+ url.parse("https://google.com/asdf?asdf=ljk3lk4&asdf=234#asdf");
406
+ url.parse("https://anonymous:flabada@developer.mozilla.org/en-US/docs/Web/API/URL/password");
407
+ url.parse("https://localhost");
408
+ url.parse("https://my.local");
409
+ url.parse("http://aslkfjdalsdfkjaf");
410
+ url.parse("http://localhost");
411
+
412
+ url.parse("c:");
413
+
414
+ expect(() => url.parse("asdf")).toThrow();
415
+ expect(() => url.parse("https:/")).toThrow();
416
+ expect(() => url.parse("asdfj@lkjsdf.com")).toThrow();
417
+ expect(() => url.parse("https://")).toThrow();
418
+ });
419
+
420
+ test("url preserves original input", () => {
421
+ const url = z.string().url();
422
+
423
+ // Test the specific case from the user report
424
+ const input = "https://example.com?key=NUXOmHqWNVTapJkJJHw8BfD155AuqhH_qju_5fNmQ4ZHV7u8";
425
+ const output = url.parse(input);
426
+ expect(output).toBe(input); // Should preserve the original input exactly
427
+
428
+ // Test other cases where URL constructor would normalize
429
+ expect(url.parse("https://example.com?foo=bar")).toBe("https://example.com?foo=bar");
430
+ expect(url.parse("http://example.com?test=123")).toBe("http://example.com?test=123");
431
+ expect(url.parse("https://sub.example.com?param=value&other=data")).toBe(
432
+ "https://sub.example.com?param=value&other=data"
433
+ );
434
+
435
+ // Test cases with trailing slashes are preserved
436
+ expect(url.parse("https://example.com/")).toBe("https://example.com/");
437
+ expect(url.parse("https://example.com/path/")).toBe("https://example.com/path/");
438
+
439
+ // Test cases with paths and query parameters
440
+ expect(url.parse("https://example.com/path?query=param")).toBe("https://example.com/path?query=param");
441
+ });
442
+
443
+ test("url trims whitespace", () => {
444
+ const url = z.string().url();
445
+
446
+ // Test trimming whitespace from URLs
447
+ expect(url.parse(" https://example.com ")).toBe("https://example.com");
448
+ expect(url.parse(" https://example.com/path?query=param ")).toBe("https://example.com/path?query=param");
449
+ expect(url.parse("\t\nhttps://example.com\t\n")).toBe("https://example.com");
450
+ expect(url.parse(" https://example.com?key=value ")).toBe("https://example.com?key=value");
451
+
452
+ // Test that URLs without extra whitespace are unchanged
453
+ expect(url.parse("https://example.com")).toBe("https://example.com");
454
+ expect(url.parse("https://example.com/path")).toBe("https://example.com/path");
455
+ });
456
+
457
+ test("url returns the string the parser validated", () => {
458
+ // The URL parser deletes ASCII tab, LF and CR instead of failing, so `new URL()` reports on a string that is not the one it was given. The host is the consequential case: this validated example.com and used to hand back a URL naming a different host.
459
+ expect(z.url().parse("https://exa\nmple.com")).toBe("https://example.com");
460
+ expect(z.url().parse("https://exa\tmple.com")).toBe("https://example.com");
461
+ expect(z.url().parse("https://exa\rmple.com")).toBe("https://example.com");
462
+ expect(z.httpUrl().parse("https://exa\nmple.com")).toBe("https://example.com");
463
+ expect(z.url({ hostname: /^a\.com$/ }).parse("https://a\n.com")).toBe("https://a.com");
464
+ expect(z.url().parse("https://example.com/a\nb?c=\td#e")).toBe("https://example.com/ab?c=d#e");
465
+
466
+ // Nothing that parsed before stops parsing, and normalize still wins where it applies.
467
+ expect(z.url().parse("https://example.com/path")).toBe("https://example.com/path");
468
+ expect(z.url({ normalize: true }).parse("https://exa\nmple.com")).toBe("https://example.com/");
469
+ });
470
+
471
+ test("ipv6 and cidrv6 reject anything outside the address alphabet", () => {
472
+ // `new URL("http://[...]")` parses an authority rather than an address, so a delimiter re-splits it and the parser validates something else entirely.
473
+ expect(z.ipv6().safeParse("::@1\\").success).toBe(false); // used to validate against the host 0.0.0.1
474
+ expect(z.ipv6().safeParse("::]/1").success).toBe(false);
475
+ expect(z.ipv6().safeParse("@[::1").success).toBe(false);
476
+ expect(z.cidrv6().safeParse("::@1\\/64").success).toBe(false);
477
+
478
+ for (const c of ["\t", "\n", "\r"]) {
479
+ expect(z.ipv6().safeParse(`2001:db8::${c}1`).success).toBe(false);
480
+ expect(z.ipv6().safeParse(`::1${c}`).success).toBe(false);
481
+ expect(z.cidrv6().safeParse(`::1${c}/64`).success).toBe(false);
482
+ }
483
+
484
+ // A rejection has to surface as an issue, not just success: false.
485
+ const result = z.ipv6().safeParse("::1\n");
486
+ expect(result.success).toBe(false);
487
+ expect(result.error!.issues[0]).toMatchObject({ code: "invalid_format", format: "ipv6" });
488
+
489
+ expect(z.ipv6().parse("2001:db8::1")).toBe("2001:db8::1");
490
+ expect(z.ipv6().parse("::ffff:192.0.2.1")).toBe("::ffff:192.0.2.1");
491
+ expect(z.ipv6().parse("2001:DB8::1")).toBe("2001:DB8::1");
492
+ expect(z.cidrv6().parse("::ffff:192.0.2.1/96")).toBe("::ffff:192.0.2.1/96");
493
+ });
494
+
495
+ test("url normalize flag", () => {
496
+ const normalizeUrl = z.url({ normalize: true });
497
+ const preserveUrl = z.url(); // normalize: false/undefined by default
498
+
499
+ // Test that normalize flag causes URL normalization
500
+ expect(normalizeUrl.parse("https://example.com?key=value")).toBe("https://example.com/?key=value");
501
+ expect(normalizeUrl.parse("http://example.com?test=123")).toBe("http://example.com/?test=123");
502
+
503
+ // Test with already normalized URLs
504
+ expect(normalizeUrl.parse("https://example.com/")).toBe("https://example.com/");
505
+ expect(normalizeUrl.parse("https://example.com/path?query=param")).toBe("https://example.com/path?query=param");
506
+
507
+ // Test complex URLs with normalization
508
+ expect(normalizeUrl.parse("https://example.com/../?key=value")).toBe("https://example.com/?key=value");
509
+ expect(normalizeUrl.parse("https://example.com/./path?key=value")).toBe("https://example.com/path?key=value");
510
+
511
+ // Compare with non-normalize behavior
512
+ expect(preserveUrl.parse("https://example.com?key=value")).toBe("https://example.com?key=value");
513
+ expect(preserveUrl.parse("http://example.com?test=123")).toBe("http://example.com?test=123");
514
+
515
+ // Test trimming with normalize
516
+ expect(normalizeUrl.parse(" https://example.com?key=value ")).toBe("https://example.com/?key=value");
517
+ expect(preserveUrl.parse(" https://example.com?key=value ")).toBe("https://example.com?key=value");
518
+ });
519
+
520
+ test("url normalize with hostname and protocol constraints", () => {
521
+ const constrainedNormalizeUrl = z.url({
522
+ normalize: true,
523
+ protocol: /^https$/,
524
+ hostname: /^example\.com$/,
525
+ });
526
+
527
+ // Test that normalization works with constraints
528
+ expect(constrainedNormalizeUrl.parse("https://example.com?key=value")).toBe("https://example.com/?key=value");
529
+
530
+ // Test that constraints are still enforced
531
+ expect(() => constrainedNormalizeUrl.parse("http://example.com?key=value")).toThrow();
532
+ expect(() => constrainedNormalizeUrl.parse("https://other.com?key=value")).toThrow();
533
+ });
534
+
535
+ test("httpurl", () => {
536
+ const httpUrl = z.url({
537
+ protocol: /^https?$/,
538
+ hostname: z.regexes.domain,
539
+ // /^(?=.{1,253}$)([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,63}$/
540
+ });
541
+
542
+ httpUrl.parse("https://example.com");
543
+ httpUrl.parse("http://example.com");
544
+ // ports
545
+ httpUrl.parse("https://example.com:8080");
546
+ httpUrl.parse("http://example.com:8080");
547
+ // subdomains
548
+ httpUrl.parse("https://sub.example.com");
549
+ httpUrl.parse("http://sub.example.com");
550
+ // paths
551
+ httpUrl.parse("https://example.com/path/to/resource");
552
+ httpUrl.parse("http://example.com/path/to/resource");
553
+ // query parameters
554
+ httpUrl.parse("https://example.com/path?query=param");
555
+ httpUrl.parse("http://example.com/path?query=param");
556
+ // fragment identifiers
557
+ httpUrl.parse("https://example.com/path#fragment");
558
+ httpUrl.parse("http://example.com/path#fragment");
559
+ // fails
560
+ expect(() => httpUrl.parse("ftp://example.com")).toThrow();
561
+ expect(() => httpUrl.parse("shttp://example.com")).toThrow();
562
+ expect(() => httpUrl.parse("httpz://example.com")).toThrow();
563
+ expect(() => httpUrl.parse("http://")).toThrow();
564
+ expect(() => httpUrl.parse("http://localhost")).toThrow();
565
+ expect(() => httpUrl.parse("http://-asdf.com")).toThrow();
566
+ expect(() =>
567
+ httpUrl.parse(
568
+ "http://asdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdf.com"
569
+ )
570
+ ).toThrow();
571
+ expect(() => httpUrl.parse("http://asdf.c")).toThrow();
572
+ expect(() => httpUrl.parse("mailto:asdf@lckj.com")).toThrow();
573
+ // total host length over the RFC 1035 limit of 253 chars (built from valid-length labels)
574
+ const longHost = `${`${"a".repeat(50)}.`.repeat(5)}com`; // 5 * 51 + 3 = 258 chars
575
+ expect(longHost.length).toBeGreaterThan(253);
576
+ expect(() => httpUrl.parse(`http://${longHost}`)).toThrow();
577
+ // TLD over the 63-char label limit
578
+ expect(() => httpUrl.parse(`http://example.${"a".repeat(64)}`)).toThrow();
579
+ // a host at exactly the 253-char limit is still accepted, one char more is not
580
+ const maxHost = `${`${"a".repeat(61)}.`.repeat(4)}aaaaa`; // 4 * 62 + 5 = 253 chars
581
+ httpUrl.parse(`http://${maxHost}`);
582
+ expect(() => httpUrl.parse(`http://${maxHost}a`)).toThrow();
583
+ // missing // after protocol
584
+ expect(() => httpUrl.parse("http:example.com")).toThrow();
585
+ expect(() => httpUrl.parse("https:example.com")).toThrow();
586
+ // missing one /
587
+ expect(() => httpUrl.parse("https:/www.google.com")).toThrow();
588
+ expect(() => httpUrl.parse("http:/example.com")).toThrow();
589
+ });
590
+
591
+ test("url error overrides", () => {
592
+ try {
593
+ z.string().url().parse("https");
594
+ } catch (err) {
595
+ expect((err as z.YatspError).issues[0].message).toEqual("Invalid URL");
596
+ }
597
+ try {
598
+ z.string().url("badurl").parse("https");
599
+ } catch (err) {
600
+ expect((err as z.YatspError).issues[0].message).toEqual("badurl");
601
+ }
602
+ try {
603
+ z.string().url({ message: "badurl" }).parse("https");
604
+ } catch (err) {
605
+ expect((err as z.YatspError).issues[0].message).toEqual("badurl");
606
+ }
607
+ });
608
+
609
+ test("emoji validations", () => {
610
+ const emoji = z.string().emoji();
611
+
612
+ emoji.parse("🦰🦱🦲🦳"); // both Extended_Pictographic and Emoji_Component
613
+ emoji.parse("👋👋👋👋");
614
+ emoji.parse("🍺👩‍🚀🫡");
615
+ emoji.parse("💚💙💜💛❤️");
616
+ emoji.parse("🐛🗝🐏🍡🎦🚢🏨💫🎌☘🗡😹🔒🎬➡️🍹🗂🚨⚜🕑〽️🚦🌊🍴💍🍌💰😳🌺🍃");
617
+ emoji.parse("🇹🇷🤽🏿‍♂️");
618
+ emoji.parse(
619
+ "😀😁😂🤣😃😄😅😆😉😊😋😎😍😘🥰😗😙😚☺️☺🙂🤗🤩🤔🤨😐😑😶🙄😏😣😥😮🤐😯😪😫😴😌😛😜😝🤤😒😓😔😕🙃🤑😲☹️☹🙁😖😞😟😤😢😭😦😧😨😩🤯😬😰😱🥵🥶😳🤪😵😡😠🤬😷🤒🤕🤢🤮🤧😇🤠🥳🥴🥺🤥🤫🤭🧐🤓😈👿🤡👹👺💀☠️☠👻👽👾🤖💩😺😸😹😻😼😽🙀😿😾🙈🙉🙊🏻🏼🏽🏾🏿👶👶🏻👶🏼👶🏽👶🏾👶🏿🧒🧒🏻🧒🏼🧒🏽🧒🏾🧒🏿👦👦🏻👦🏼👦🏽👦🏾👦🏿👧👧🏻👧🏼👧🏽👧🏾👧🏿🧑🧑🏻🧑🏼🧑🏽🧑🏾🧑🏿👨👨🏻👨🏼👨🏽👨🏾👨🏿👩👩🏻👩🏼👩🏽👩🏾👩🏿🧓🧓🏻🧓🏼🧓🏽🧓🏾🧓🏿👴👴🏻👴🏼👴🏽👴🏾👴🏿👵👵🏻👵🏼👵🏽👵🏾👵🏿👨‍⚕️👨‍⚕👨🏻‍⚕️👨🏻‍⚕👨🏼‍⚕️👨🏼‍⚕👨🏽‍⚕️👨🏽‍⚕👨🏾‍⚕️👨🏾‍⚕👨🏿‍⚕️👨🏿‍⚕👩‍⚕️👩‍⚕👩🏻‍⚕️👩🏻‍⚕👩🏼‍⚕️👩🏼‍⚕👩🏽‍⚕️👩🏽‍⚕👩🏾‍⚕️👩🏾‍⚕👩🏿‍⚕️👩🏿‍⚕👨‍🎓👨🏻‍🎓👨🏼‍🎓👨🏽‍🎓👨🏾‍🎓👨🏿‍🎓👩‍🎓👩🏻‍🎓👩🏼‍🎓👩🏽‍🎓👩🏾‍🎓👩🏿‍🎓👨‍🏫👨🏻‍🏫👨🏼‍🏫👨🏽‍🏫👨🏾‍🏫👨🏿‍🏫👩‍🏫👩🏻‍🏫👩🏼‍🏫👩🏽‍🏫👩🏾‍🏫👩🏿‍🏫👨‍⚖️👨‍⚖👨🏻‍⚖️👨🏻‍⚖👨🏼‍⚖️👨🏼‍⚖👨🏽‍⚖️👨🏽‍⚖👨🏾‍⚖️👨🏾‍⚖👨🏿‍⚖️👨🏿‍⚖👩‍⚖️👩‍⚖👩🏻‍⚖️👩🏻‍⚖👩🏼‍⚖️👩🏼‍⚖👩🏽‍⚖️👩🏽‍⚖👩🏾‍⚖️👩🏾‍⚖👩🏿‍⚖️👩🏿‍⚖👨‍🌾👨🏻‍🌾👨🏼‍🌾👨🏽‍🌾👨🏾‍🌾👨🏿‍🌾👩‍🌾👩🏻‍🌾👩🏼‍🌾👩🏽‍🌾👩🏾‍🌾👩🏿‍🌾👨‍🍳👨🏻‍🍳👨🏼‍🍳👨🏽‍🍳👨🏾‍🍳👨🏿‍🍳👩‍🍳👩🏻‍🍳👩🏼‍🍳👩🏽‍🍳👩🏾‍🍳👩🏿‍🍳👨‍🔧👨🏻‍🔧👨🏼‍🔧👨🏽‍🔧👨🏾‍🔧👨🏿‍🔧👩‍🔧👩🏻‍🔧👩🏼‍🔧👩🏽‍🔧👩🏾‍🔧👩🏿‍🔧👨‍🏭👨🏻‍🏭👨🏼‍🏭👨🏽‍🏭👨🏾‍🏭👨🏿‍🏭👩‍🏭👩🏻‍🏭👩🏼‍🏭👩🏽‍🏭👩🏾‍🏭👩🏿‍🏭👨‍💼👨🏻‍💼👨🏼‍💼👨🏽‍💼👨🏾‍💼👨🏿‍💼👩‍💼👩🏻‍💼👩🏼‍💼👩🏽‍💼👩🏾‍💼👩🏿‍💼👨‍🔬👨🏻‍🔬👨🏼‍🔬👨🏽‍🔬👨🏾‍🔬👨🏿‍🔬👩‍🔬👩🏻‍🔬👩🏼‍🔬👩🏽‍🔬👩🏾‍🔬👩🏿‍🔬👨‍💻👨🏻‍💻👨🏼‍💻👨🏽‍💻👨🏾‍💻👨🏿‍💻👩‍💻👩🏻‍💻👩🏼‍💻👩🏽‍💻👩🏾‍💻👩🏿‍💻👨‍🎤👨🏻‍🎤👨🏼‍🎤👨🏽‍🎤👨🏾‍🎤👨🏿‍🎤👩‍🎤👩🏻‍🎤👩🏼‍🎤👩🏽‍🎤👩🏾‍🎤👩🏿‍🎤👨‍🎨👨🏻‍🎨👨🏼‍🎨👨🏽‍🎨👨🏾‍🎨👨🏿‍🎨👩‍🎨👩🏻‍🎨👩🏼‍🎨👩🏽‍🎨👩🏾‍🎨👩🏿‍🎨👨‍✈️👨‍✈👨🏻‍✈️👨🏻‍✈👨🏼‍✈️👨🏼‍✈👨🏽‍✈️👨🏽‍✈👨🏾‍✈️👨🏾‍✈👨🏿‍✈️👨🏿‍✈👩‍✈️👩‍✈👩🏻‍✈️👩🏻‍✈👩🏼‍✈️👩🏼‍✈👩🏽‍✈️👩🏽‍✈👩🏾‍✈️👩🏾‍✈👩🏿‍✈️👩🏿‍✈👨‍🚀👨🏻‍🚀👨🏼‍🚀👨🏽‍🚀👨🏾‍🚀👨🏿‍🚀👩‍🚀👩🏻‍🚀👩🏼‍🚀👩🏽‍🚀👩🏾‍🚀👩🏿‍🚀👨‍🚒👨🏻‍🚒👨🏼‍🚒👨🏽‍🚒👨🏾‍🚒👨🏿‍🚒👩‍🚒👩🏻‍🚒👩🏼‍🚒👩🏽‍🚒👩🏾‍🚒👩🏿‍🚒👮👮🏻👮🏼👮🏽👮🏾👮🏿👮‍♂️👮‍♂👮🏻‍♂️👮🏻‍♂👮🏼‍♂️👮🏼‍♂👮🏽‍♂️👮🏽‍♂👮🏾‍♂️👮🏾‍♂👮🏿‍♂️👮🏿‍♂👮‍♀️👮‍♀👮🏻‍♀️👮🏻‍♀👮🏼‍♀️👮🏼‍♀👮🏽‍♀️👮🏽‍♀👮🏾‍♀️👮🏾‍♀👮🏿‍♀️👮🏿‍♀🕵️🕵🕵🏻🕵🏼🕵🏽🕵🏾🕵🏿🕵️‍♂️🕵‍♂️🕵️‍♂🕵‍♂🕵🏻‍♂️🕵🏻‍♂🕵🏼‍♂️🕵🏼‍♂🕵🏽‍♂️🕵🏽‍♂🕵🏾‍♂️🕵🏾‍♂🕵🏿‍♂️🕵🏿‍♂🕵️‍♀️🕵‍♀️🕵️‍♀🕵‍♀🕵🏻‍♀️🕵🏻‍♀🕵🏼‍♀️🕵🏼‍♀🕵🏽‍♀️🕵🏽‍♀🕵🏾‍♀️🕵🏾‍♀🕵🏿‍♀️🕵🏿‍♀💂💂🏻💂🏼💂🏽💂🏾💂🏿💂‍♂️💂‍♂💂🏻‍♂️💂🏻‍♂💂🏼‍♂️💂🏼‍♂💂🏽‍♂️💂🏽‍♂💂🏾‍♂️💂🏾‍♂💂🏿‍♂️💂🏿‍♂💂‍♀️💂‍♀💂🏻‍♀️💂🏻‍♀💂🏼‍♀️💂🏼‍♀💂🏽‍♀️💂🏽‍♀💂🏾‍♀️💂🏾‍♀💂🏿‍♀️💂🏿‍♀👷👷🏻👷🏼👷🏽👷🏾👷🏿👷‍♂️👷‍♂👷🏻‍♂️👷🏻‍♂👷🏼‍♂️👷🏼‍♂👷🏽‍♂️👷🏽‍♂👷🏾‍♂️👷🏾‍♂👷🏿‍♂️👷🏿‍♂👷‍♀️👷‍♀👷🏻‍♀️👷🏻‍♀👷🏼‍♀️👷🏼‍♀👷🏽‍♀️👷🏽‍♀👷🏾‍♀️👷🏾‍♀👷🏿‍♀️👷🏿‍♀🤴🤴🏻🤴🏼🤴🏽🤴🏾🤴🏿👸👸🏻👸🏼👸🏽👸🏾👸🏿👳👳🏻👳🏼👳🏽👳🏾👳🏿👳‍♂️👳‍♂👳🏻‍♂️👳🏻‍♂👳🏼‍♂️👳🏼‍♂👳🏽‍♂️👳🏽‍♂👳🏾‍♂️👳🏾‍♂👳🏿‍♂️👳🏿‍♂👳‍♀️👳‍♀👳🏻‍♀️👳🏻‍♀👳🏼‍♀️👳🏼‍♀👳🏽‍♀️👳🏽‍♀👳🏾‍♀️👳🏾‍♀👳🏿‍♀️👳🏿‍♀👲👲🏻👲🏼👲🏽👲🏾👲🏿🧕🧕🏻🧕🏼🧕🏽🧕🏾🧕🏿🧔🧔🏻🧔🏼🧔🏽🧔🏾🧔🏿👱👱🏻👱🏼👱🏽👱🏾👱🏿👱‍♂️👱‍♂👱🏻‍♂️👱🏻‍♂👱🏼‍♂️👱🏼‍♂👱🏽‍♂️👱🏽‍♂👱🏾‍♂️👱🏾‍♂👱🏿‍♂️👱🏿‍♂👱‍♀️👱‍♀👱🏻‍♀️👱🏻‍♀👱🏼‍♀️👱🏼‍♀👱🏽‍♀️👱🏽‍♀👱🏾‍♀️👱🏾‍♀👱🏿‍♀️👱🏿‍♀👨‍🦰👨🏻‍🦰👨🏼‍🦰👨🏽‍🦰👨🏾‍🦰👨🏿‍🦰👩‍🦰👩🏻‍🦰👩🏼‍🦰👩🏽‍🦰👩🏾‍🦰👩🏿‍🦰👨‍🦱👨🏻‍🦱👨🏼‍🦱👨🏽‍🦱👨🏾‍🦱👨🏿‍🦱👩‍🦱👩🏻‍🦱👩🏼‍🦱👩🏽‍🦱👩🏾‍🦱👩🏿‍🦱👨‍🦲👨🏻‍🦲👨🏼‍🦲👨🏽‍🦲👨🏾‍🦲👨🏿‍🦲👩‍🦲👩🏻‍🦲👩🏼‍🦲👩🏽‍🦲👩🏾‍🦲👩🏿‍🦲👨‍🦳👨🏻‍🦳👨🏼‍🦳👨🏽‍🦳👨🏾‍🦳👨🏿‍🦳👩‍🦳👩🏻‍🦳👩🏼‍🦳👩🏽‍🦳👩🏾‍🦳👩🏿‍🦳🤵🤵🏻🤵🏼🤵🏽🤵🏾🤵🏿👰👰🏻👰🏼👰🏽👰🏾👰🏿🤰🤰🏻🤰🏼🤰🏽🤰🏾🤰🏿🤱🤱🏻🤱🏼🤱🏽🤱🏾🤱🏿👼👼🏻👼🏼👼🏽👼🏾👼🏿🎅🎅🏻🎅🏼🎅🏽🎅🏾🎅🏿🤶🤶🏻🤶🏼🤶🏽🤶🏾🤶🏿🦸🦸🏻🦸🏼🦸🏽🦸🏾🦸🏿🦸‍♀️🦸‍♀🦸🏻‍♀️🦸🏻‍♀🦸🏼‍♀️🦸🏼‍♀🦸🏽‍♀️🦸🏽‍♀🦸🏾‍♀️🦸🏾‍♀🦸🏿‍♀️🦸🏿‍♀🦸‍♂️🦸‍♂🦸🏻‍♂️🦸🏻‍♂🦸🏼‍♂️🦸🏼‍♂🦸🏽‍♂️🦸🏽‍♂🦸🏾‍♂️🦸🏾‍♂🦸🏿‍♂️🦸🏿‍♂🦹🦹🏻🦹🏼🦹🏽🦹🏾🦹🏿🦹‍♀️🦹‍♀🦹🏻‍♀️🦹🏻‍♀🦹🏼‍♀️🦹🏼‍♀🦹🏽‍♀️🦹🏽‍♀🦹🏾‍♀️🦹🏾‍♀🦹🏿‍♀️🦹🏿‍♀🦹‍♂️🦹‍♂🦹🏻‍♂️🦹🏻‍♂🦹🏼‍♂️🦹🏼‍♂🦹🏽‍♂️🦹🏽‍♂🦹🏾‍♂️🦹🏾‍♂🦹🏿‍♂️🦹🏿‍♂🧙🧙🏻🧙🏼🧙🏽🧙🏾🧙🏿🧙‍♀️🧙‍♀🧙🏻‍♀️🧙🏻‍♀🧙🏼‍♀️🧙🏼‍♀🧙🏽‍♀️🧙🏽‍♀🧙🏾‍♀️🧙🏾‍♀🧙🏿‍♀️🧙🏿‍♀🧙‍♂️🧙‍♂🧙🏻‍♂️🧙🏻‍♂🧙🏼‍♂️🧙🏼‍♂🧙🏽‍♂️🧙🏽‍♂🧙🏾‍♂️🧙🏾‍♂🧙🏿‍♂️🧙🏿‍♂🧚🧚🏻🧚🏼🧚🏽🧚🏾🧚🏿🧚‍♀️🧚‍♀🧚🏻‍♀️🧚🏻‍♀🧚🏼‍♀️🧚🏼‍♀🧚🏽‍♀️🧚🏽‍♀🧚🏾‍♀️🧚🏾‍♀🧚🏿‍♀️🧚🏿‍♀🧚‍♂️🧚‍♂🧚🏻‍♂️🧚🏻‍♂🧚🏼‍♂️🧚🏼‍♂🧚🏽‍♂️🧚🏽‍♂🧚🏾‍♂️🧚🏾‍♂🧚🏿‍♂️🧚🏿‍♂🧛🧛🏻🧛🏼🧛🏽🧛🏾🧛🏿🧛‍♀️🧛‍♀🧛🏻‍♀️🧛🏻‍♀🧛🏼‍♀️🧛🏼‍♀🧛🏽‍♀️🧛🏽‍♀🧛🏾‍♀️🧛🏾‍♀🧛🏿‍♀️🧛🏿‍♀🧛‍♂️🧛‍♂🧛🏻‍♂️🧛🏻‍♂🧛🏼‍♂️🧛🏼‍♂🧛🏽‍♂️🧛🏽‍♂🧛🏾‍♂️🧛🏾‍♂🧛🏿‍♂️🧛🏿‍♂🧜🧜🏻🧜🏼🧜🏽🧜🏾🧜🏿🧜‍♀️🧜‍♀🧜🏻‍♀️🧜🏻‍♀🧜🏼‍♀️🧜🏼‍♀🧜🏽‍♀️🧜🏽‍♀🧜🏾‍♀️🧜🏾‍♀🧜🏿‍♀️🧜🏿‍♀🧜‍♂️🧜‍♂🧜🏻‍♂️🧜🏻‍♂🧜🏼‍♂️🧜🏼‍♂🧜🏽‍♂️🧜🏽‍♂🧜🏾‍♂️🧜🏾‍♂🧜🏿‍♂️🧜🏿‍♂🧝🧝🏻🧝🏼🧝🏽🧝🏾🧝🏿🧝‍♀️🧝‍♀🧝🏻‍♀️🧝🏻‍♀🧝🏼‍♀️🧝🏼‍♀🧝🏽‍♀️🧝🏽‍♀🧝🏾‍♀️🧝🏾‍♀🧝🏿‍♀️🧝🏿‍♀🧝‍♂️🧝‍♂🧝🏻‍♂️🧝🏻‍♂🧝🏼‍♂️🧝🏼‍♂🧝🏽‍♂️🧝🏽‍♂🧝🏾‍♂️🧝🏾‍♂🧝🏿‍♂️🧝🏿‍♂🧞🧞‍♀️🧞‍♀🧞‍♂️🧞‍♂🧟🧟‍♀️🧟‍♀🧟‍♂️🧟‍♂🙍🙍🏻🙍🏼🙍🏽🙍🏾🙍🏿🙍‍♂️🙍‍♂🙍🏻‍♂️🙍🏻‍♂🙍🏼‍♂️🙍🏼‍♂🙍🏽‍♂️🙍🏽‍♂🙍🏾‍♂️🙍🏾‍♂🙍🏿‍♂️🙍🏿‍♂🙍‍♀️🙍‍♀🙍🏻‍♀️🙍🏻‍♀🙍🏼‍♀️🙍🏼‍♀🙍🏽‍♀️🙍🏽‍♀🙍🏾‍♀️🙍🏾‍♀🙍🏿‍♀️🙍🏿‍♀🙎🙎🏻🙎🏼🙎🏽🙎🏾🙎🏿🙎‍♂️🙎‍♂🙎🏻‍♂️🙎🏻‍♂🙎🏼‍♂️🙎🏼‍♂🙎🏽‍♂️🙎🏽‍♂🙎🏾‍♂️🙎🏾‍♂🙎🏿‍♂️🙎🏿‍♂🙎‍♀️🙎‍♀🙎🏻‍♀️🙎🏻‍♀🙎🏼‍♀️🙎🏼‍♀🙎🏽‍♀️🙎🏽‍♀🙎🏾‍♀️🙎🏾‍♀🙎🏿‍♀️🙎🏿‍♀🙅🙅🏻🙅🏼🙅🏽🙅🏾🙅🏿🙅‍♂️🙅‍♂🙅🏻‍♂️🙅🏻‍♂🙅🏼‍♂️🙅🏼‍♂🙅🏽‍♂️🙅🏽‍♂🙅🏾‍♂️🙅🏾‍♂🙅🏿‍♂️🙅🏿‍♂🙅‍♀️🙅‍♀🙅🏻‍♀️🙅🏻‍♀🙅🏼‍♀️🙅🏼‍♀🙅🏽‍♀️🙅🏽‍♀🙅🏾‍♀️🙅🏾‍♀🙅🏿‍♀️🙅🏿‍♀🙆🙆🏻🙆🏼🙆🏽🙆🏾🙆🏿🙆‍♂️🙆‍♂🙆🏻‍♂️🙆🏻‍♂🙆🏼‍♂️🙆🏼‍♂🙆🏽‍♂️🙆🏽‍♂🙆🏾‍♂️🙆🏾‍♂🙆🏿‍♂️🙆🏿‍♂🙆‍♀️🙆‍♀🙆🏻‍♀️🙆🏻‍♀🙆🏼‍♀️🙆🏼‍♀🙆🏽‍♀️🙆🏽‍♀🙆🏾‍♀️🙆🏾‍♀🙆🏿‍♀️🙆🏿‍♀💁💁🏻💁🏼💁🏽💁🏾💁🏿💁‍♂️💁‍♂💁🏻‍♂️💁🏻‍♂💁🏼‍♂️💁🏼‍♂💁🏽‍♂️💁🏽‍♂💁🏾‍♂️💁🏾‍♂💁🏿‍♂️💁🏿‍♂💁‍♀️💁‍♀💁🏻‍♀️💁🏻‍♀💁🏼‍♀️💁🏼‍♀💁🏽‍♀️💁🏽‍♀💁🏾‍♀️💁🏾‍♀💁🏿‍♀️💁🏿‍♀🙋🙋🏻🙋🏼🙋🏽🙋🏾🙋🏿🙋‍♂️🙋‍♂🙋🏻‍♂️🙋🏻‍♂🙋🏼‍♂️🙋🏼‍♂🙋🏽‍♂️🙋🏽‍♂🙋🏾‍♂️🙋🏾‍♂🙋🏿‍♂️🙋🏿‍♂🙋‍♀️🙋‍♀🙋🏻‍♀️🙋🏻‍♀🙋🏼‍♀️🙋🏼‍♀🙋🏽‍♀️🙋🏽‍♀🙋🏾‍♀️🙋🏾‍♀🙋🏿‍♀️🙋🏿‍♀🙇🙇🏻🙇🏼🙇🏽🙇🏾🙇🏿🙇‍♂️🙇‍♂🙇🏻‍♂️🙇🏻‍♂🙇🏼‍♂️🙇🏼‍♂🙇🏽‍♂️🙇🏽‍♂🙇🏾‍♂️🙇🏾‍♂🙇🏿‍♂️🙇🏿‍♂🙇‍♀️🙇‍♀🙇🏻‍♀️🙇🏻‍♀🙇🏼‍♀️🙇🏼‍♀🙇🏽‍♀️🙇🏽‍♀🙇🏾‍♀️🙇🏾‍♀🙇🏿‍♀️🙇🏿‍♀🤦🤦🏻🤦🏼🤦🏽🤦🏾🤦🏿🤦‍♂️🤦‍♂🤦🏻‍♂️🤦🏻‍♂🤦🏼‍♂️🤦🏼‍♂🤦🏽‍♂️🤦🏽‍♂🤦🏾‍♂️🤦🏾‍♂🤦🏿‍♂️🤦🏿‍♂🤦‍♀️🤦‍♀🤦🏻‍♀️🤦🏻‍♀🤦🏼‍♀️🤦🏼‍♀🤦🏽‍♀️🤦🏽‍♀🤦🏾‍♀️🤦🏾‍♀🤦🏿‍♀️🤦🏿‍♀🤷🤷🏻🤷🏼🤷🏽🤷🏾🤷🏿🤷‍♂️🤷‍♂🤷🏻‍♂️🤷🏻‍♂🤷🏼‍♂️🤷🏼‍♂🤷🏽‍♂️🤷🏽‍♂🤷🏾‍♂️🤷🏾‍♂🤷🏿‍♂️🤷🏿‍♂🤷‍♀️🤷‍♀🤷🏻‍♀️🤷🏻‍♀🤷🏼‍♀️🤷🏼‍♀🤷🏽‍♀️🤷🏽‍♀🤷🏾‍♀️🤷🏾‍♀🤷🏿‍♀️🤷🏿‍♀💆💆🏻💆🏼💆🏽💆🏾💆🏿💆‍♂️💆‍♂💆🏻‍♂️💆🏻‍♂💆🏼‍♂️💆🏼‍♂💆🏽‍♂️💆🏽‍♂💆🏾‍♂️💆🏾‍♂💆🏿‍♂️💆🏿‍♂💆‍♀️💆‍♀💆🏻‍♀️💆🏻‍♀💆🏼‍♀️💆🏼‍♀💆🏽‍♀️💆🏽‍♀💆🏾‍♀️💆🏾‍♀💆🏿‍♀️💆🏿‍♀💇💇🏻💇🏼💇🏽💇🏾💇🏿💇‍♂️💇‍♂💇🏻‍♂️💇🏻‍♂💇🏼‍♂️💇🏼‍♂💇🏽‍♂️💇🏽‍♂💇🏾‍♂️💇🏾‍♂💇🏿‍♂️💇🏿‍♂💇‍♀️💇‍♀💇🏻‍♀️💇🏻‍♀💇🏼‍♀️💇🏼‍♀💇🏽‍♀️💇🏽‍♀💇🏾‍♀️💇🏾‍♀💇🏿‍♀️💇🏿‍♀🚶🚶🏻🚶🏼🚶🏽🚶🏾🚶🏿🚶‍♂️🚶‍♂🚶🏻‍♂️🚶🏻‍♂🚶🏼‍♂️🚶🏼‍♂🚶🏽‍♂️🚶🏽‍♂🚶🏾‍♂️🚶🏾‍♂🚶🏿‍♂️🚶🏿‍♂🚶‍♀️🚶‍♀🚶🏻‍♀️🚶🏻‍♀🚶🏼‍♀️🚶🏼‍♀🚶🏽‍♀️🚶🏽‍♀🚶🏾‍♀️🚶🏾‍♀🚶🏿‍♀️🚶🏿‍♀🏃🏃🏻🏃🏼🏃🏽🏃🏾🏃🏿🏃‍♂️🏃‍♂🏃🏻‍♂️🏃🏻‍♂🏃🏼‍♂️🏃🏼‍♂🏃🏽‍♂️🏃🏽‍♂🏃🏾‍♂️🏃🏾‍♂🏃🏿‍♂️🏃🏿‍♂🏃‍♀️🏃‍♀🏃🏻‍♀️🏃🏻‍♀🏃🏼‍♀️🏃🏼‍♀🏃🏽‍♀️🏃🏽‍♀🏃🏾‍♀️🏃🏾‍♀🏃🏿‍♀️🏃🏿‍♀💃💃🏻💃🏼💃🏽💃🏾💃🏿🕺🕺🏻🕺🏼🕺🏽🕺🏾🕺🏿👯👯‍♂️👯‍♂👯‍♀️👯‍♀🧖🧖🏻🧖🏼🧖🏽🧖🏾🧖🏿🧖‍♀️🧖‍♀🧖🏻‍♀️🧖🏻‍♀🧖🏼‍♀️🧖🏼‍♀🧖🏽‍♀️🧖🏽‍♀🧖🏾‍♀️🧖🏾‍♀🧖🏿‍♀️🧖🏿‍♀🧖‍♂️🧖‍♂🧖🏻‍♂️🧖🏻‍♂🧖🏼‍♂️🧖🏼‍♂🧖🏽‍♂️🧖🏽‍♂🧖🏾‍♂️🧖🏾‍♂🧖🏿‍♂️🧖🏿‍♂🧗🧗🏻🧗🏼🧗🏽🧗🏾🧗🏿🧗‍♀️🧗‍♀🧗🏻‍♀️🧗🏻‍♀🧗🏼‍♀️🧗🏼‍♀🧗🏽‍♀️🧗🏽‍♀🧗🏾‍♀️🧗🏾‍♀🧗🏿‍♀️🧗🏿‍♀🧗‍♂️🧗‍♂🧗🏻‍♂️🧗🏻‍♂🧗🏼‍♂️🧗🏼‍♂🧗🏽‍♂️🧗🏽‍♂🧗🏾‍♂️🧗🏾‍♂🧗🏿‍♂️🧗🏿‍♂🧘🧘🏻🧘🏼🧘🏽🧘🏾🧘🏿🧘‍♀️🧘‍♀🧘🏻‍♀️🧘🏻‍♀🧘🏼‍♀️🧘🏼‍♀🧘🏽‍♀️🧘🏽‍♀🧘🏾‍♀️🧘🏾‍♀🧘🏿‍♀️🧘🏿‍♀🧘‍♂️🧘‍♂🧘🏻‍♂️🧘🏻‍♂🧘🏼‍♂️🧘🏼‍♂🧘🏽‍♂️🧘🏽‍♂🧘🏾‍♂️🧘🏾‍♂🧘🏿‍♂️🧘🏿‍♂🛀🛀🏻🛀🏼🛀🏽🛀🏾🛀🏿🛌🛌🏻🛌🏼🛌🏽🛌🏾🛌🏿🕴️🕴🕴🏻🕴🏼🕴🏽🕴🏾🕴🏿🗣️🗣👤👥🤺🏇🏇🏻🏇🏼🏇🏽🏇🏾🏇🏿⛷️⛷🏂🏂🏻🏂🏼🏂🏽🏂🏾🏂🏿🏌️🏌🏌🏻🏌🏼🏌🏽🏌🏾🏌🏿🏌️‍♂️🏌‍♂️🏌️‍♂🏌‍♂🏌🏻‍♂️🏌🏻‍♂🏌🏼‍♂️🏌🏼‍♂🏌🏽‍♂️🏌🏽‍♂🏌🏾‍♂️🏌🏾‍♂🏌🏿‍♂️🏌🏿‍♂🏌️‍♀️🏌‍♀️🏌️‍♀🏌‍♀🏌🏻‍♀️🏌🏻‍♀🏌🏼‍♀️🏌🏼‍♀🏌🏽‍♀️🏌🏽‍♀🏌🏾‍♀️🏌🏾‍♀🏌🏿‍♀️🏌🏿‍♀🏄🏄🏻🏄🏼🏄🏽🏄🏾🏄🏿🏄‍♂️🏄‍♂🏄🏻‍♂️🏄🏻‍♂🏄🏼‍♂️🏄🏼‍♂🏄🏽‍♂️🏄🏽‍♂🏄🏾‍♂️🏄🏾‍♂🏄🏿‍♂️🏄🏿‍♂🏄‍♀️🏄‍♀🏄🏻‍♀️🏄🏻‍♀🏄🏼‍♀️🏄🏼‍♀🏄🏽‍♀️🏄🏽‍♀🏄🏾‍♀️🏄🏾‍♀🏄🏿‍♀️🏄🏿‍♀🚣🚣🏻🚣🏼🚣🏽🚣🏾🚣🏿🚣‍♂️🚣‍♂🚣🏻‍♂️🚣🏻‍♂🚣🏼‍♂️🚣🏼‍♂🚣🏽‍♂️🚣🏽‍♂🚣🏾‍♂️🚣🏾‍♂🚣🏿‍♂️🚣🏿‍♂🚣‍♀️🚣‍♀🚣🏻‍♀️🚣🏻‍♀🚣🏼‍♀️🚣🏼‍♀🚣🏽‍♀️🚣🏽‍♀🚣🏾‍♀️🚣🏾‍♀🚣🏿‍♀️🚣🏿‍♀🏊🏊🏻🏊🏼🏊🏽🏊🏾🏊🏿🏊‍♂️🏊‍♂🏊🏻‍♂️🏊🏻‍♂🏊🏼‍♂️🏊🏼‍♂🏊🏽‍♂️🏊🏽‍♂🏊🏾‍♂️🏊🏾‍♂🏊🏿‍♂️🏊🏿‍♂🏊‍♀️🏊‍♀🏊🏻‍♀️🏊🏻‍♀🏊🏼‍♀️🏊🏼‍♀🏊🏽‍♀️🏊🏽‍♀🏊🏾‍♀️🏊🏾‍♀🏊🏿‍♀️🏊🏿‍♀⛹️⛹⛹🏻⛹🏼⛹🏽⛹🏾⛹🏿⛹️‍♂️⛹‍♂️⛹️‍♂⛹‍♂⛹🏻‍♂️⛹🏻‍♂⛹🏼‍♂️⛹🏼‍♂⛹🏽‍♂️⛹🏽‍♂⛹🏾‍♂️⛹🏾‍♂⛹🏿‍♂️⛹🏿‍♂⛹️‍♀️⛹‍♀️⛹️‍♀⛹‍♀⛹🏻‍♀️⛹🏻‍♀⛹🏼‍♀️⛹🏼‍♀⛹🏽‍♀️⛹🏽‍♀⛹🏾‍♀️⛹🏾‍♀⛹🏿‍♀️⛹🏿‍♀🏋️🏋🏋🏻🏋🏼🏋🏽🏋🏾🏋🏿🏋️‍♂️🏋‍♂️🏋️‍♂🏋‍♂🏋🏻‍♂️🏋🏻‍♂🏋🏼‍♂️🏋🏼‍♂🏋🏽‍♂️🏋🏽‍♂🏋🏾‍♂️🏋🏾‍♂🏋🏿‍♂️🏋🏿‍♂🏋️‍♀️🏋‍♀️🏋️‍♀🏋‍♀🏋🏻‍♀️🏋🏻‍♀🏋🏼‍♀️🏋🏼‍♀🏋🏽‍♀️🏋🏽‍♀🏋🏾‍♀️🏋🏾‍♀🏋🏿‍♀️🏋🏿‍♀🚴🚴🏻🚴🏼🚴🏽🚴🏾🚴🏿🚴‍♂️🚴‍♂🚴🏻‍♂️🚴🏻‍♂🚴🏼‍♂️🚴🏼‍♂🚴🏽‍♂️🚴🏽‍♂🚴🏾‍♂️🚴🏾‍♂🚴🏿‍♂️🚴🏿‍♂🚴‍♀️🚴‍♀🚴🏻‍♀️🚴🏻‍♀🚴🏼‍♀️🚴🏼‍♀🚴🏽‍♀️🚴🏽‍♀🚴🏾‍♀️🚴🏾‍♀🚴🏿‍♀️🚴🏿‍♀🚵🚵🏻🚵🏼🚵🏽🚵🏾🚵🏿🚵‍♂️🚵‍♂🚵🏻‍♂️🚵🏻‍♂🚵🏼‍♂️🚵🏼‍♂🚵🏽‍♂️🚵🏽‍♂🚵🏾‍♂️🚵🏾‍♂🚵🏿‍♂️🚵🏿‍♂🚵‍♀️🚵‍♀🚵🏻‍♀️🚵🏻‍♀🚵🏼‍♀️🚵🏼‍♀🚵🏽‍♀️🚵🏽‍♀🚵🏾‍♀️🚵🏾‍♀🚵🏿‍♀️🚵🏿‍♀🏎️🏎🏍️🏍🤸🤸🏻🤸🏼🤸🏽🤸🏾🤸🏿🤸‍♂️🤸‍♂🤸🏻‍♂️🤸🏻‍♂🤸🏼‍♂️🤸🏼‍♂🤸🏽‍♂️🤸🏽‍♂🤸🏾‍♂️🤸🏾‍♂🤸🏿‍♂️🤸🏿‍♂🤸‍♀️🤸‍♀🤸🏻‍♀️🤸🏻‍♀🤸🏼‍♀️🤸🏼‍♀🤸🏽‍♀️🤸🏽‍♀🤸🏾‍♀️🤸🏾‍♀🤸🏿‍♀️🤸🏿‍♀🤼🤼‍♂️🤼‍♂🤼‍♀️🤼‍♀🤽🤽🏻🤽🏼🤽🏽🤽🏾🤽🏿🤽‍♂️🤽‍♂🤽🏻‍♂️🤽🏻‍♂🤽🏼‍♂️🤽🏼‍♂🤽🏽‍♂️🤽🏽‍♂🤽🏾‍♂️🤽🏾‍♂🤽🏿‍♂️🤽🏿‍♂🤽‍♀️🤽‍♀🤽🏻‍♀️🤽🏻‍♀🤽🏼‍♀️🤽🏼‍♀🤽🏽‍♀️🤽🏽‍♀🤽🏾‍♀️🤽🏾‍♀🤽🏿‍♀️🤽🏿‍♀🤾🤾🏻🤾🏼🤾🏽🤾🏾🤾🏿🤾‍♂️🤾‍♂🤾🏻‍♂️🤾🏻‍♂🤾🏼‍♂️🤾🏼‍♂🤾🏽‍♂️🤾🏽‍♂🤾🏾‍♂️🤾🏾‍♂🤾🏿‍♂️🤾🏿‍♂🤾‍♀️🤾‍♀🤾🏻‍♀️🤾🏻‍♀🤾🏼‍♀️🤾🏼‍♀🤾🏽‍♀️🤾🏽‍♀🤾🏾‍♀️🤾🏾‍♀🤾🏿‍♀️🤾🏿‍♀🤹🤹🏻🤹🏼🤹🏽🤹🏾🤹🏿🤹‍♂️🤹‍♂🤹🏻‍♂️🤹🏻‍♂🤹🏼‍♂️🤹🏼‍♂🤹🏽‍♂️🤹🏽‍♂🤹🏾‍♂️🤹🏾‍♂🤹🏿‍♂️🤹🏿‍♂🤹‍♀️🤹‍♀🤹🏻‍♀️🤹🏻‍♀🤹🏼‍♀️🤹🏼‍♀🤹🏽‍♀️🤹🏽‍♀🤹🏾‍♀️🤹🏾‍♀🤹🏿‍♀️🤹🏿‍♀👫👬👭💏👩‍❤️‍💋‍👨👩‍❤‍💋‍👨👨‍❤️‍💋‍👨👨‍❤‍💋‍👨👩‍❤️‍💋‍👩👩‍❤‍💋‍👩💑👩‍❤️‍👨👩‍❤‍👨👨‍❤️‍👨👨‍❤‍👨👩‍❤️‍👩👩‍❤‍👩👪👨‍👩‍👦👨‍👩‍👧👨‍👩‍👧‍👦👨‍👩‍👦‍👦👨‍👩‍👧‍👧👨‍👨‍👦👨‍👨‍👧👨‍👨‍👧‍👦👨‍👨‍👦‍👦👨‍👨‍👧‍👧👩‍👩‍👦👩‍👩‍👧👩‍👩‍👧‍👦👩‍👩‍👦‍👦👩‍👩‍👧‍👧👨‍👦👨‍👦‍👦👨‍👧👨‍👧‍👦👨‍👧‍👧👩‍👦👩‍👦‍👦👩‍👧👩‍👧‍👦👩‍👧‍👧🤳🤳🏻🤳🏼🤳🏽🤳🏾🤳🏿💪💪🏻💪🏼💪🏽💪🏾💪🏿🦵🦵🏻🦵🏼🦵🏽🦵🏾🦵🏿🦶🦶🏻🦶🏼🦶🏽🦶🏾🦶🏿👈👈🏻👈🏼👈🏽👈🏾👈🏿👉👉🏻👉🏼👉🏽👉🏾👉🏿☝️☝☝🏻☝🏼☝🏽☝🏾☝🏿👆👆🏻👆🏼👆🏽👆🏾👆🏿🖕🖕🏻🖕🏼🖕🏽🖕🏾🖕🏿👇👇🏻👇🏼👇🏽👇🏾👇🏿✌️✌✌🏻✌🏼✌🏽✌🏾✌🏿🤞🤞🏻🤞🏼🤞🏽🤞🏾🤞🏿🖖🖖🏻🖖🏼🖖🏽🖖🏾🖖🏿🤘🤘🏻🤘🏼🤘🏽🤘🏾🤘🏿🤙🤙🏻🤙🏼🤙🏽🤙🏾🤙🏿🖐️🖐🖐🏻🖐🏼🖐🏽🖐🏾🖐🏿✋✋🏻✋🏼✋🏽✋🏾✋🏿👌👌🏻👌🏼👌🏽👌🏾👌🏿👍👍🏻👍🏼👍🏽👍🏾👍🏿👎👎🏻👎🏼👎🏽👎🏾👎🏿✊✊🏻✊🏼✊🏽✊🏾✊🏿👊👊🏻👊🏼👊🏽👊🏾👊🏿🤛🤛🏻🤛🏼🤛🏽🤛🏾🤛🏿🤜🤜🏻🤜🏼🤜🏽🤜🏾🤜🏿🤚🤚🏻🤚🏼🤚🏽🤚🏾🤚🏿👋👋🏻👋🏼👋🏽👋🏾👋🏿🤟🤟🏻🤟🏼🤟🏽🤟🏾🤟🏿✍️✍✍🏻✍🏼✍🏽✍🏾✍🏿👏👏🏻👏🏼👏🏽👏🏾👏🏿👐👐🏻👐🏼👐🏽👐🏾👐🏿🙌🙌🏻🙌🏼🙌🏽🙌🏾🙌🏿🤲🤲🏻🤲🏼🤲🏽🤲🏾🤲🏿🙏🙏🏻🙏🏼🙏🏽🙏🏾🙏🏿🤝💅💅🏻💅🏼💅🏽💅🏾💅🏿👂👂🏻👂🏼👂🏽👂🏾👂🏿👃👃🏻👃🏼👃🏽👃🏾👃🏿🦰🦱🦲🦳👣👀👁️👁👁️‍🗨️👁‍🗨️👁️‍🗨👁‍🗨🧠🦴🦷👅👄💋💘❤️❤💓💔💕💖💗💙💚💛🧡💜🖤💝💞💟❣️❣💌💤💢💣💥💦💨💫💬🗨️🗨🗯️🗯💭🕳️🕳👓🕶️🕶🥽🥼👔👕👖🧣🧤🧥🧦👗👘👙👚👛👜👝🛍️🛍🎒👞👟🥾🥿👠👡👢👑👒🎩🎓🧢⛑️⛑📿💄💍💎🐵🐒🦍🐶🐕🐩🐺🦊🦝🐱🐈🦁🐯🐅🐆🐴🐎🦄🦓🦌🐮🐂🐃🐄🐷🐖🐗🐽🐏🐑🐐🐪🐫🦙🦒🐘🦏🦛🐭🐁🐀🐹🐰🐇🐿️🐿🦔🦇🐻🐨🐼🦘🦡🐾🦃🐔🐓🐣🐤🐥🐦🐧🕊️🕊🦅🦆🦢🦉🦚🦜🐸🐊🐢🦎🐍🐲🐉🦕🦖🐳🐋🐬🐟🐠🐡🦈🐙🐚🦀🦞🦐🦑🐌🦋🐛🐜🐝🐞🦗🕷️🕷🕸️🕸🦂🦟🦠💐🌸💮🏵️🏵🌹🥀🌺🌻🌼🌷🌱🌲🌳🌴🌵🌾🌿☘️☘🍀🍁🍂🍃🍇🍈🍉🍊🍋🍌🍍🥭🍎🍏🍐🍑🍒🍓🥝🍅🥥🥑🍆🥔🥕🌽🌶️🌶🥒🥬🥦🍄🥜🌰🍞🥐🥖🥨🥯🥞🧀🍖🍗🥩🥓🍔🍟🍕🌭🥪🌮🌯🥙🥚🍳🥘🍲🥣🥗🍿🧂🥫🍱🍘🍙🍚🍛🍜🍝🍠🍢🍣🍤🍥🥮🍡🥟🥠🥡🍦🍧🍨🍩🍪🎂🍰🧁🥧🍫🍬🍭🍮🍯🍼🥛☕🍵🍶🍾🍷🍸🍹🍺🍻🥂🥃🥤🥢🍽️🍽🍴🥄🔪🏺🌍🌎🌏🌐🗺️🗺🗾🧭🏔️🏔⛰️⛰🌋🗻🏕️🏕🏖️🏖🏜️🏜🏝️🏝🏞️🏞🏟️🏟🏛️🏛🏗️🏗🧱🏘️🏘🏚️🏚🏠🏡🏢🏣🏤🏥🏦🏨🏩🏪🏫🏬🏭🏯🏰💒🗼🗽⛪🕌🕍⛩️⛩🕋⛲⛺🌁🌃🏙️🏙🌄🌅🌆🌇🌉♨️♨🌌🎠🎡🎢💈🎪🚂🚃🚄🚅🚆🚇🚈🚉🚊🚝🚞🚋🚌🚍🚎🚐🚑🚒🚓🚔🚕🚖🚗🚘🚙🚚🚛🚜🚲🛴🛹🛵🚏🛣️🛣🛤️🛤🛢️🛢⛽🚨🚥🚦🛑🚧⚓⛵🛶🚤🛳️🛳⛴️⛴🛥️🛥🚢✈️✈🛩️🛩🛫🛬💺🚁🚟🚠🚡🛰️🛰🚀🛸🛎️🛎🧳⌛⏳⌚⏰⏱️⏱⏲️⏲🕰️🕰🕛🕧🕐🕜🕑🕝🕒🕞🕓🕟🕔🕠🕕🕡🕖🕢🕗🕣🕘🕤🕙🕥🕚🕦🌑🌒🌓🌔🌕🌖🌗🌘🌙🌚🌛🌜🌡️🌡☀️☀🌝🌞⭐🌟🌠☁️☁⛅⛈️⛈🌤️🌤🌥️🌥🌦️🌦🌧️🌧🌨️🌨🌩️🌩🌪️🌪🌫️🌫🌬️🌬🌀🌈🌂☂️☂☔⛱️⛱⚡❄️❄☃️☃⛄☄️☄🔥💧🌊🎃🎄🎆🎇🧨✨🎈🎉🎊🎋🎍🎎🎏🎐🎑🧧🎀🎁🎗️🎗🎟️🎟🎫🎖️🎖🏆🏅🥇🥈🥉⚽⚾🥎🏀🏐🏈🏉🎾🥏🎳🏏🏑🏒🥍🏓🏸🥊🥋🥅⛳⛸️⛸🎣🎽🎿🛷🥌🎯🎱🔮🧿🎮🕹️🕹🎰🎲🧩🧸♠️♠♥️♥♦️♦♣️♣♟️♟🃏🀄🎴🎭🖼️🖼🎨🧵🧶🔇🔈🔉🔊📢📣📯🔔🔕🎼🎵🎶🎙️🎙🎚️🎚🎛️🎛🎤🎧📻🎷🎸🎹🎺🎻🥁📱📲☎️☎📞📟📠🔋🔌💻🖥️🖥🖨️🖨⌨️⌨🖱️🖱🖲️🖲💽💾💿📀🧮🎥🎞️🎞📽️📽🎬📺📷📸📹📼🔍🔎🕯️🕯💡🔦🏮📔📕📖📗📘📙📚📓📒📃📜📄📰🗞️🗞📑🔖🏷️🏷💰💴💵💶💷💸💳🧾💹💱💲✉️✉📧📨📩📤📥📦📫📪📬📭📮🗳️🗳✏️✏✒️✒🖋️🖋🖊️🖊🖌️🖌🖍️🖍📝💼📁📂🗂️🗂📅📆🗒️🗒🗓️🗓📇📈📉📊📋📌📍📎🖇️🖇📏📐✂️✂🗃️🗃🗄️🗄🗑️🗑🔒🔓🔏🔐🔑🗝️🗝🔨⛏️⛏⚒️⚒🛠️🛠🗡️🗡⚔️⚔🔫🏹🛡️🛡🔧🔩⚙️⚙🗜️🗜⚖️⚖🔗⛓️⛓🧰🧲⚗️⚗🧪🧫🧬🔬🔭📡💉💊🚪🛏️🛏🛋️🛋🚽🚿🛁🧴🧷🧹🧺🧻🧼🧽🧯🛒🚬⚰️⚰⚱️⚱🗿🏧🚮🚰♿🚹🚺🚻🚼🚾🛂🛃🛄🛅⚠️⚠🚸⛔🚫🚳🚭🚯🚱🚷📵🔞☢️☢☣️☣⬆️⬆↗️↗➡️➡↘️↘⬇️⬇↙️↙⬅️⬅↖️↖↕️↕↔️↔↩️↩↪️↪⤴️⤴⤵️⤵🔃🔄🔙🔚🔛🔜🔝🛐⚛️⚛🕉️🕉✡️✡☸️☸☯️☯✝️✝☦️☦☪️☪☮️☮🕎🔯♈♉♊♋♌♍♎♏♐♑♒♓⛎🔀🔁🔂▶️▶⏩⏭️⏭⏯️⏯◀️◀⏪⏮️⏮🔼⏫🔽⏬⏸️⏸⏹️⏹⏺️⏺⏏️⏏🎦🔅🔆📶📳📴♀️♀♂️♂⚕️⚕♾️♾♻️♻⚜️⚜🔱📛🔰⭕✅☑️☑✔️✔✖️✖❌❎➕➖➗➰➿〽️〽✳️✳✴️✴❇️❇‼️‼⁉️⁉❓❔❕❗〰️〰©️©®️®™️™#️⃣#⃣*️⃣*⃣0️⃣0⃣1️⃣1⃣2️⃣2⃣3️⃣3⃣4️⃣4⃣5️⃣5⃣6️⃣6⃣7️⃣7⃣8️⃣8⃣9️⃣9⃣🔟💯🔠🔡🔢🔣🔤🅰️🅰🆎🅱️🅱🆑🆒🆓ℹ️ℹ🆔Ⓜ️Ⓜ🆕🆖🅾️🅾🆗🅿️🅿🆘🆙🆚🈁🈂️🈂🈷️🈷🈶🈯🉐🈹🈚🈲🉑🈸🈴🈳㊗️㊗㊙️㊙🈺🈵▪️▪▫️▫◻️◻◼️◼◽◾⬛⬜🔶🔷🔸🔹🔺🔻💠🔘🔲🔳⚪⚫🔴🔵🏁🚩🎌🏴🏳️🏳🏳️‍🌈🏳‍🌈🏴‍☠️🏴‍☠🇦🇨🇦🇩🇦🇪🇦🇫🇦🇬🇦🇮🇦🇱🇦🇲🇦🇴🇦🇶🇦🇷🇦🇸🇦🇹🇦🇺🇦🇼🇦🇽🇦🇿🇧🇦🇧🇧🇧🇩🇧🇪🇧🇫🇧🇬🇧🇭🇧🇮🇧🇯🇧🇱🇧🇲🇧🇳🇧🇴🇧🇶🇧🇷🇧🇸🇧🇹🇧🇻🇧🇼🇧🇾🇧🇿🇨🇦🇨🇨🇨🇩🇨🇫🇨🇬🇨🇭🇨🇮🇨🇰🇨🇱🇨🇲🇨🇳🇨🇴🇨🇵🇨🇷🇨🇺🇨🇻🇨🇼🇨🇽🇨🇾🇨🇿🇩🇪🇩🇬🇩🇯🇩🇰🇩🇲🇩🇴🇩🇿🇪🇦🇪🇨🇪🇪🇪🇬🇪🇭🇪🇷🇪🇸🇪🇹🇪🇺🇫🇮🇫🇯🇫🇰🇫🇲🇫🇴🇫🇷🇬🇦🇬🇧🇬🇩🇬🇪🇬🇫🇬🇬🇬🇭🇬🇮🇬🇱🇬🇲🇬🇳🇬🇵🇬🇶🇬🇷🇬🇸🇬🇹🇬🇺🇬🇼🇬🇾🇭🇰🇭🇲🇭🇳🇭🇷🇭🇹🇭🇺🇮🇨🇮🇩🇮🇪🇮🇱🇮🇲🇮🇳🇮🇴🇮🇶🇮🇷🇮🇸🇮🇹🇯🇪🇯🇲🇯🇴🇯🇵🇰🇪🇰🇬🇰🇭🇰🇮🇰🇲🇰🇳🇰🇵🇰🇷🇰🇼🇰🇾🇰🇿🇱🇦🇱🇧🇱🇨🇱🇮🇱🇰🇱🇷🇱🇸🇱🇹🇱🇺🇱🇻🇱🇾🇲🇦🇲🇨🇲🇩🇲🇪🇲🇫🇲🇬🇲🇭🇲🇰🇲🇱🇲🇲🇲🇳🇲🇴🇲🇵🇲🇶🇲🇷🇲🇸🇲🇹🇲🇺🇲🇻🇲🇼🇲🇽🇲🇾🇲🇿🇳🇦🇳🇨🇳🇪🇳🇫🇳🇬🇳🇮🇳🇱🇳🇴🇳🇵🇳🇷🇳🇺🇳🇿🇴🇲🇵🇦🇵🇪🇵🇫🇵🇬🇵🇭🇵🇰🇵🇱🇵🇲🇵🇳🇵🇷🇵🇸🇵🇹🇵🇼🇵🇾🇶🇦🇷🇪🇷🇴🇷🇸🇷🇺🇷🇼🇸🇦🇸🇧🇸🇨🇸🇩🇸🇪🇸🇬🇸🇭🇸🇮🇸🇯🇸🇰🇸🇱🇸🇲🇸🇳🇸🇴🇸🇷🇸🇸🇸🇹🇸🇻🇸🇽🇸🇾🇸🇿🇹🇦🇹🇨🇹🇩🇹🇫🇹🇬🇹🇭🇹🇯🇹🇰🇹🇱🇹🇲🇹🇳🇹🇴🇹🇷🇹🇹🇹🇻🇹🇼🇹🇿🇺🇦🇺🇬🇺🇲🇺🇳🇺🇸🇺🇾🇺🇿🇻🇦🇻🇨🇻🇪🇻🇬🇻🇮🇻🇳🇻🇺🇼🇫🇼🇸🇽🇰🇾🇪🇾🇹🇿🇦🇿🇲🇿🇼🏴󠁧󠁢󠁥󠁮󠁧󠁿🏴󠁧󠁢󠁳󠁣󠁴󠁿🏴󠁧󠁢󠁷󠁬󠁳󠁿"
620
+ );
621
+ expect(() => emoji.parse(":-)")).toThrow();
622
+ expect(() => emoji.parse("😀 is an emoji")).toThrow();
623
+ expect(() => emoji.parse("😀stuff")).toThrow();
624
+ expect(() => emoji.parse("stuff😀")).toThrow();
625
+
626
+ emoji.parse("1\u{FE0F}\u{20E3}"); // keycap sequences stay valid
627
+ emoji.parse("#\u{FE0F}\u{20E3}");
628
+
629
+ // `\p{Emoji_Component}` alone covers ASCII digits, "#", "*", ZWJ, variation selectors and skin tone modifiers; none is an emoji without a base, so a component-only string is not one either
630
+ expect(() => emoji.parse("123")).toThrow();
631
+ expect(() => emoji.parse("#")).toThrow();
632
+ expect(() => emoji.parse("*")).toThrow();
633
+ expect(() => emoji.parse("\u{200D}")).toThrow();
634
+ expect(() => emoji.parse("\u{FE0F}")).toThrow();
635
+ expect(() => emoji.parse("\u{1F3FD}")).toThrow();
636
+ expect(() => emoji.parse("1\u{FE0F}")).toThrow();
637
+ });
638
+
639
+ test("nanoid", () => {
640
+ const nanoid = z.string().nanoid("custom error");
641
+ nanoid.parse("lfNZluvAxMkf7Q8C5H-QS");
642
+ nanoid.parse("mIU_4PJWikaU8fMbmkouz");
643
+ nanoid.parse("Hb9ZUtUa2JDm_dD-47EGv");
644
+ nanoid.parse("5Noocgv_8vQ9oPijj4ioQ");
645
+ const result = nanoid.safeParse("Xq90uDyhddC53KsoASYJGX");
646
+ expect(result).toMatchObject({ success: false });
647
+
648
+ expect(result.error!.issues[0].message).toEqual("custom error");
649
+ expect(result.error).toMatchInlineSnapshot(`
650
+ [YatspError: [
651
+ {
652
+ "origin": "string",
653
+ "code": "invalid_format",
654
+ "format": "nanoid",
655
+ "pattern": "/^[a-zA-Z0-9_-]{21}$/",
656
+ "path": [],
657
+ "message": "custom error"
658
+ }
659
+ ]]
660
+ `);
661
+ });
662
+
663
+ test("bad nanoid", () => {
664
+ const nanoid = z.string().nanoid("custom error");
665
+ nanoid.parse("ySh_984wpDUu7IQRrLXAp");
666
+ const result = nanoid.safeParse("invalid nanoid");
667
+ expect(result).toMatchObject({ success: false });
668
+
669
+ expect(result.error!.issues[0].message).toEqual("custom error");
670
+ expect(result.error).toMatchInlineSnapshot(`
671
+ [YatspError: [
672
+ {
673
+ "origin": "string",
674
+ "code": "invalid_format",
675
+ "format": "nanoid",
676
+ "pattern": "/^[a-zA-Z0-9_-]{21}$/",
677
+ "path": [],
678
+ "message": "custom error"
679
+ }
680
+ ]]
681
+ `);
682
+ });
683
+
684
+ test("good uuid", () => {
685
+ const uuid = z.string().uuid("custom error");
686
+ const goodUuids = [
687
+ "9491d710-3185-1e06-bea0-6a2f275345e0",
688
+ "9491d710-3185-2e06-bea0-6a2f275345e0",
689
+ "9491d710-3185-3e06-bea0-6a2f275345e0",
690
+ "9491d710-3185-4e06-bea0-6a2f275345e0",
691
+ "9491d710-3185-5e06-bea0-6a2f275345e0",
692
+ "9491d710-3185-5e06-aea0-6a2f275345e0",
693
+ "9491d710-3185-5e06-8ea0-6a2f275345e0",
694
+ "9491d710-3185-5e06-9ea0-6a2f275345e0",
695
+ "00000000-0000-0000-0000-000000000000",
696
+ "ffffffff-ffff-ffff-ffff-ffffffffffff",
697
+ ];
698
+
699
+ for (const goodUuid of goodUuids) {
700
+ const result = uuid.safeParse(goodUuid);
701
+ expect(result.success).toEqual(true);
702
+ }
703
+ });
704
+
705
+ test(`bad uuid`, () => {
706
+ const uuid = z.string().uuid("custom error");
707
+ for (const badUuid of [
708
+ "9491d710-3185-0e06-bea0-6a2f275345e0",
709
+ "9491d710-3185-5e06-0ea0-6a2f275345e0",
710
+ "d89e7b01-7598-ed11-9d7a-0022489382fd", // new sequential id
711
+ "b3ce60f8-e8b9-40f5-1150-172ede56ff74", // Variant 0 - RFC 9562/4122: Reserved, NCS backward compatibility
712
+ "92e76bf9-28b3-4730-cd7f-cb6bc51f8c09", // Variant 2 - RFC 9562/4122: Reserved, Microsoft Corporation backward compatibility
713
+ "invalid uuid",
714
+ "9491d710-3185-4e06-bea0-6a2f275345e0X",
715
+ ]) {
716
+ const result = uuid.safeParse(badUuid);
717
+ expect(result).toMatchObject({ success: false });
718
+ expect(result.error?.issues[0].message).toEqual("custom error");
719
+ }
720
+ });
721
+
722
+ test("good guid", () => {
723
+ const guid = z.string().guid("custom error");
724
+ for (const goodGuid of [
725
+ "9491d710-3185-4e06-bea0-6a2f275345e0",
726
+ "d89e7b01-7598-ed11-9d7a-0022489382fd", // new sequential id
727
+ "b3ce60f8-e8b9-40f5-1150-172ede56ff74", // Variant 0 - RFC 9562/4122: Reserved, NCS backward compatibility
728
+ "92e76bf9-28b3-4730-cd7f-cb6bc51f8c09", // Variant 2 - RFC 9562/4122: Reserved, Microsoft Corporation backward compatibility
729
+ "00000000-0000-0000-0000-000000000000",
730
+ "ffffffff-ffff-ffff-ffff-ffffffffffff",
731
+ ]) {
732
+ const result = guid.safeParse(goodGuid);
733
+ expect(result.success).toEqual(true);
734
+ }
735
+ });
736
+
737
+ test("bad guid", () => {
738
+ const guid = z.string().guid("custom error");
739
+ for (const badGuid of ["9491d710-3185-4e06-bea0-6a2f275345e0X"]) {
740
+ const result = guid.safeParse(badGuid);
741
+ expect(result).toMatchObject({ success: false });
742
+ expect(result.error?.issues[0].message).toEqual("custom error");
743
+ }
744
+ });
745
+
746
+ test("nanoid custom length", () => {
747
+ const nanoid64 = z.nanoid({ length: 64 });
748
+ nanoid64.parse("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_");
749
+ expect(nanoid64.safeParse("lfNZluvAxMkf7Q8C5H-QS")).toMatchObject({ success: false });
750
+
751
+ // the deprecated method and the default length both still work
752
+ expect(z.string().nanoid({ length: 10 }).safeParse("IRFa-VaY2b")).toMatchObject({ success: true });
753
+ expect(z.nanoid().safeParse("lfNZluvAxMkf7Q8C5H-QS")).toMatchObject({ success: true });
754
+
755
+ expect(z.nanoid({ length: 64, error: "custom error" }).safeParse("abc").error!.issues[0].message).toEqual(
756
+ "custom error"
757
+ );
758
+ });
759
+
760
+ test("nanoid rejects a length that is not a positive integer", () => {
761
+ expect(() => z.nanoid({ length: 0 })).toThrow("Invalid nanoid length: 0");
762
+ expect(() => z.nanoid({ length: -1 })).toThrow("Invalid nanoid length: -1");
763
+ expect(() => z.nanoid({ length: 1.5 })).toThrow("Invalid nanoid length: 1.5");
764
+ });
765
+
766
+ test("cuid", () => {
767
+ const cuid = z.string().cuid();
768
+ cuid.parse("ckopqwooh000001la8mbi2im9");
769
+ const result = cuid.safeParse("cifjhdsfhsd-invalid-cuid");
770
+ expect(result).toMatchObject({ success: false });
771
+
772
+ expect(result.error!.issues[0].message).toEqual("Invalid cuid");
773
+ expect(result.error).toMatchInlineSnapshot(`
774
+ [YatspError: [
775
+ {
776
+ "origin": "string",
777
+ "code": "invalid_format",
778
+ "format": "cuid",
779
+ "pattern": "/^[cC][0-9a-z]{6,}$/",
780
+ "path": [],
781
+ "message": "Invalid cuid"
782
+ }
783
+ ]]
784
+ `);
785
+
786
+ // Strings containing non-base36 characters that the old denylist regex
787
+ // (/^[cC][^\s-]{8,}$/) accepted. The new regex restricts the body to
788
+ // [0-9a-z], matching the actual CUID v1 base36 format. See #3621.
789
+ const previouslyAcceptedNonCuids = [
790
+ "cly63t164000245zw008pggon';select1;", // SQLi-shaped (no whitespace, no hyphen)
791
+ "c<script>alert(1)</script>aaaaaa", // XSS-shaped
792
+ "c{};alert(1)//", // bracket / curly chars
793
+ "C0123_45678", // underscore is not base36
794
+ "cAAAAAAAAA", // uppercase letters in body are not base36 (CUIDs are lowercase)
795
+ ];
796
+ for (const s of previouslyAcceptedNonCuids) {
797
+ expect(cuid.safeParse(s).success).toBe(false);
798
+ }
799
+ });
800
+
801
+ test("cuid2", () => {
802
+ const cuid2 = z.string().cuid2();
803
+ const validStrings = [
804
+ "a", // short string
805
+ "tz4a98xxat96iws9zmbrgj3a", // normal string
806
+ "kf5vz6ssxe4zjcb409rjgo747tc5qjazgptvotk6", // longer than require("@paralleldrive/cuid2").bigLength
807
+ ];
808
+ for (const s of validStrings) {
809
+ cuid2.parse(s);
810
+ }
811
+
812
+ const invalidStrings = [
813
+ "", // empty string
814
+ "tz4a98xxat96iws9zMbrgj3a", // include uppercase
815
+ "tz4a98xxat96iws-zmbrgj3a", // involve symbols
816
+ ];
817
+ const results = invalidStrings.map((s) => cuid2.safeParse(s));
818
+ expect(results.every((r) => !r.success)).toEqual(true);
819
+ if (!results[0].success) {
820
+ expect(results[0].error.issues[0].message).toEqual("Invalid cuid2");
821
+ }
822
+ });
823
+
824
+ test("ulid", () => {
825
+ const ulid = z.string().ulid();
826
+ ulid.parse("01ARZ3NDEKTSV4RRFFQ69G5FAV");
827
+ const result = ulid.safeParse("invalidulid");
828
+ expect(result).toMatchObject({ success: false });
829
+ const tooLong = "01ARZ3NDEKTSV4RRFFQ69G5FAVA";
830
+ expect(ulid.safeParse(tooLong)).toMatchObject({ success: false });
831
+
832
+ const caseInsensitive = ulid.safeParse("01arZ3nDeKTsV4RRffQ69G5FAV");
833
+ expect(caseInsensitive.success).toEqual(true);
834
+
835
+ // first char is capped at 7: the spec's largest ULID is 7ZZZZZZZZZZZZZZZZZZZZZZZZZ, so 8-9 and every letter overflow 2^48-1
836
+ expect(ulid.safeParse("7ZZZZZZZZZZZZZZZZZZZZZZZZZ").success).toEqual(true);
837
+ for (const first of ["8", "9", "A", "Z", "z"]) {
838
+ expect(ulid.safeParse(`${first}AAAAAAAAAAAAAAAAAAAAAAAAA`).success).toEqual(false);
839
+ }
840
+
841
+ expect(result.error!.issues[0].message).toEqual("Invalid ULID");
842
+ expect(result.error).toMatchInlineSnapshot(`
843
+ [YatspError: [
844
+ {
845
+ "origin": "string",
846
+ "code": "invalid_format",
847
+ "format": "ulid",
848
+ "pattern": "/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/",
849
+ "path": [],
850
+ "message": "Invalid ULID"
851
+ }
852
+ ]]
853
+ `);
854
+ });
855
+
856
+ test("xid", () => {
857
+ const xid = z.string().xid();
858
+ xid.parse("9m4e2mr0ui3e8a215n4g");
859
+ const result = xid.safeParse("invalidxid");
860
+ expect(result).toMatchObject({ success: false });
861
+
862
+ expect(result.error!.issues[0].message).toEqual("Invalid XID");
863
+ expect(result.error).toMatchInlineSnapshot(`
864
+ [YatspError: [
865
+ {
866
+ "origin": "string",
867
+ "code": "invalid_format",
868
+ "format": "xid",
869
+ "pattern": "/^[0-9a-vA-V]{20}$/",
870
+ "path": [],
871
+ "message": "Invalid XID"
872
+ }
873
+ ]]
874
+ `);
875
+ });
876
+
877
+ test("ksuid", () => {
878
+ const ksuid = z.string().ksuid();
879
+ ksuid.parse("0o0t9hkGxgFLtd3lmJ4TSTeY0Vb");
880
+ const result = ksuid.safeParse("invalidksuid");
881
+ expect(result).toMatchObject({ success: false });
882
+ const tooLong = "0o0t9hkGxgFLtd3lmJ4TSTeY0VbA";
883
+ expect(ksuid.safeParse(tooLong)).toMatchObject({ success: false });
884
+ expect(result.error!.issues).toMatchInlineSnapshot(`
885
+ [
886
+ {
887
+ "code": "invalid_format",
888
+ "format": "ksuid",
889
+ "message": "Invalid KSUID",
890
+ "origin": "string",
891
+ "path": [],
892
+ "pattern": "/^[A-Za-z0-9]{27}$/",
893
+ },
894
+ ]
895
+ `);
896
+ });
897
+
898
+ test("regex", () => {
899
+ z.string()
900
+ .regex(/^moo+$/)
901
+ .parse("mooooo");
902
+ expect(() => z.string().uuid().parse("purr")).toThrow();
903
+ });
904
+
905
+ test("regexp error message", () => {
906
+ const result = z
907
+ .string()
908
+ .regex(/^moo+$/)
909
+ .safeParse("boooo");
910
+ expect(result.error!.issues).toMatchInlineSnapshot(`
911
+ [
912
+ {
913
+ "code": "invalid_format",
914
+ "format": "regex",
915
+ "message": "Invalid string: must match pattern /^moo+$/",
916
+ "origin": "string",
917
+ "path": [],
918
+ "pattern": "/^moo+$/",
919
+ },
920
+ ]
921
+ `);
922
+
923
+ expect(() => z.string().uuid().parse("purr")).toThrow();
924
+ });
925
+
926
+ test("regexp error custom message", () => {
927
+ const result = z
928
+ .string()
929
+ .regex(/^moo+$/, { message: "Custom error message" })
930
+ .safeParse("boooo");
931
+ expect(result.error!.issues).toMatchInlineSnapshot(`
932
+ [
933
+ {
934
+ "code": "invalid_format",
935
+ "format": "regex",
936
+ "message": "Custom error message",
937
+ "origin": "string",
938
+ "path": [],
939
+ "pattern": "/^moo+$/",
940
+ },
941
+ ]
942
+ `);
943
+
944
+ expect(() => z.string().uuid().parse("purr")).toThrow();
945
+ });
946
+
947
+ test("regex lastIndex reset", () => {
948
+ const schema = z.string().regex(/^\d+$/g);
949
+ expect(schema.safeParse("123").success).toEqual(true);
950
+ expect(schema.safeParse("123").success).toEqual(true);
951
+ expect(schema.safeParse("123").success).toEqual(true);
952
+ expect(schema.safeParse("123").success).toEqual(true);
953
+ expect(schema.safeParse("123").success).toEqual(true);
954
+ });
955
+
956
+ test("format", () => {
957
+ expect(z.string().email().format).toEqual("email");
958
+ expect(z.string().url().format).toEqual("url");
959
+ expect(z.string().jwt().format).toEqual("jwt");
960
+ expect(z.string().emoji().format).toEqual("emoji");
961
+ expect(z.string().guid().format).toEqual("guid");
962
+ expect(z.string().uuid().format).toEqual("uuid");
963
+ expect(z.string().uuidv4().format).toEqual("uuid");
964
+ expect(z.string().uuidv6().format).toEqual("uuid");
965
+ expect(z.string().uuidv7().format).toEqual("uuid");
966
+ expect(z.string().nanoid().format).toEqual("nanoid");
967
+ expect(z.string().guid().format).toEqual("guid");
968
+ expect(z.string().cuid().format).toEqual("cuid");
969
+ expect(z.string().cuid2().format).toEqual("cuid2");
970
+ expect(z.string().ulid().format).toEqual("ulid");
971
+ expect(z.string().base64().format).toEqual("base64");
972
+ // expect(z.string().jsonString().format).toEqual("json_string");
973
+ // expect(z.string().json().format).toEqual("json_string");
974
+ expect(z.string().xid().format).toEqual("xid");
975
+ expect(z.string().ksuid().format).toEqual("ksuid");
976
+ // expect(z.string().ip().format).toEqual("ip");
977
+ expect(z.string().ipv4().format).toEqual("ipv4");
978
+ expect(z.string().ipv6().format).toEqual("ipv6");
979
+ expect(z.string().e164().format).toEqual("e164");
980
+ expect(z.string().datetime().format).toEqual("datetime");
981
+ expect(z.string().date().format).toEqual("date");
982
+ expect(z.string().time().format).toEqual("time");
983
+ expect(z.string().duration().format).toEqual("duration");
984
+
985
+ expect(z.mac().format).toEqual("mac");
986
+ });
987
+
988
+ test("min max getters", () => {
989
+ expect(z.string().min(5).minLength).toEqual(5);
990
+ expect(z.string().min(5).min(10).minLength).toEqual(10);
991
+ expect(z.string().minLength).toEqual(null);
992
+
993
+ expect(z.string().max(5).maxLength).toEqual(5);
994
+ expect(z.string().max(5).max(1).maxLength).toEqual(1);
995
+ expect(z.string().max(5).max(10).maxLength).toEqual(5);
996
+ expect(z.string().maxLength).toEqual(null);
997
+ });
998
+
999
+ test("boundary cases with zero length", () => {
1000
+ // Test length(0) - only empty string should pass
1001
+ const lengthZero = z.string().length(0);
1002
+ expect(lengthZero.parse("")).toEqual("");
1003
+ expect(() => lengthZero.parse("a")).toThrow();
1004
+
1005
+ // Test min(0) - all strings including empty should pass
1006
+ const minZero = z.string().min(0);
1007
+ expect(minZero.parse("")).toEqual("");
1008
+ expect(minZero.parse("a")).toEqual("a");
1009
+ expect(minZero.parse("hello")).toEqual("hello");
1010
+
1011
+ // Test max(0) - only empty string should pass
1012
+ const maxZero = z.string().max(0);
1013
+ expect(maxZero.parse("")).toEqual("");
1014
+ expect(() => maxZero.parse("a")).toThrow();
1015
+ expect(() => maxZero.parse("hello")).toThrow();
1016
+ });
1017
+
1018
+ test("length checks count Unicode code points, not UTF-16 code units", () => {
1019
+ // "\u{1F600}" is one code point but two UTF-16 code units
1020
+ const five = "\u{1F600}\u{1F600}\u{1F600}\u{1F600}\u{1F600}";
1021
+ expect(z.string().max(5).safeParse(five).success).toBe(true);
1022
+ expect(
1023
+ z
1024
+ .string()
1025
+ .max(5)
1026
+ .safeParse(five + "\u{1F600}").success
1027
+ ).toBe(false);
1028
+ expect(z.string().min(5).safeParse(five).success).toBe(true);
1029
+ expect(z.string().min(5).safeParse("\u{1F600}\u{1F600}\u{1F600}\u{1F600}").success).toBe(false);
1030
+ expect(z.string().length(5).safeParse(five).success).toBe(true);
1031
+ expect(z.string().length(1).safeParse("\u{1F600}").success).toBe(true);
1032
+ expect(z.string().nonempty().safeParse("\u{1F600}").success).toBe(true);
1033
+
1034
+ // code points, not graphemes: a combining mark and a ZWJ sequence each stay several
1035
+ expect(z.string().length(2).safeParse("e\u0301").success).toBe(true);
1036
+ expect(z.string().length(3).safeParse("\u{1F9D1}\u200D\u{1F37C}").success).toBe(true);
1037
+
1038
+ // an unpaired surrogate is its own code point
1039
+ expect(z.string().length(1).safeParse("\uD83D").success).toBe(true);
1040
+ expect(z.string().length(2).safeParse("\uDE00\uD83D").success).toBe(true);
1041
+
1042
+ // the reported bound is still the declared one
1043
+ expect(
1044
+ z
1045
+ .string()
1046
+ .max(5)
1047
+ .safeParse(five + "\u{1F600}").error!.issues[0]
1048
+ ).toMatchObject({
1049
+ code: "too_big",
1050
+ maximum: 5,
1051
+ origin: "string",
1052
+ });
1053
+
1054
+ // other lengthables keep counting elements
1055
+ expect(z.array(z.string()).max(2).safeParse(["a", "b", "c"]).success).toBe(false);
1056
+ expect(z.array(z.string()).length(2).safeParse(["\u{1F600}", "\u{1F600}"]).success).toBe(true);
1057
+ });
1058
+
1059
+ test("trim", () => {
1060
+ expect(z.string().trim().min(2).parse(" 12 ")).toEqual("12");
1061
+
1062
+ // ordering of methods is respected
1063
+ expect(z.string().min(2).trim().parse(" 1 ")).toEqual("1");
1064
+ expect(() => z.string().trim().min(2).parse(" 1 ")).toThrow();
1065
+ });
1066
+
1067
+ test("lowerCase", () => {
1068
+ expect(z.string().toLowerCase().parse("ASDF")).toEqual("asdf");
1069
+ expect(z.string().toUpperCase().parse("asdf")).toEqual("ASDF");
1070
+ });
1071
+
1072
+ test("slugify", () => {
1073
+ expect(z.string().slugify().parse("Hello World")).toEqual("hello-world");
1074
+ expect(z.string().slugify().parse(" Hello World ")).toEqual("hello-world");
1075
+ expect(z.string().slugify().parse("Hello@World#123")).toEqual("helloworld123");
1076
+ expect(z.string().slugify().parse("Hello-World")).toEqual("hello-world");
1077
+ expect(z.string().slugify().parse("Hello_World")).toEqual("hello-world");
1078
+ expect(z.string().slugify().parse("---Hello---World---")).toEqual("hello-world");
1079
+ expect(z.string().slugify().parse("Hello World")).toEqual("hello-world");
1080
+ expect(z.string().slugify().parse("Hello!@#$%^&*()World")).toEqual("helloworld");
1081
+
1082
+ // can be used with check
1083
+ expect(z.string().check(z.slugify()).parse("Hello World")).toEqual("hello-world");
1084
+
1085
+ // can be chained with other methods
1086
+ expect(z.string().slugify().min(5).parse("Hello World")).toEqual("hello-world");
1087
+ expect(() => z.string().slugify().min(20).parse("Hello World")).toThrow();
1088
+ });
1089
+
1090
+ // test("IP validation", () => {
1091
+ // const ipSchema = z.string().ip();
1092
+
1093
+ // // General IP validation (accepts both v4 and v6)
1094
+ // expect(ipSchema.safeParse("114.71.82.94").success).toBe(true);
1095
+ // expect(ipSchema.safeParse("0.0.0.0").success).toBe(true);
1096
+ // expect(ipSchema.safeParse("37.85.236.115").success).toBe(true);
1097
+ // expect(ipSchema.safeParse("1e5e:e6c8:daac:514b:114b:e360:d8c0:682c").success).toBe(true);
1098
+ // expect(ipSchema.safeParse("9d4:c956:420f:5788:4339:9b3b:2418:75c3").success).toBe(true);
1099
+ // expect(ipSchema.safeParse("a6ea::2454:a5ce:94.105.123.75").success).toBe(true);
1100
+ // expect(ipSchema.safeParse("474f:4c83::4e40:a47:ff95:0cda").success).toBe(true);
1101
+ // expect(ipSchema.safeParse("d329:0:25b4:db47:a9d1:0:4926:0000").success).toBe(true);
1102
+ // expect(ipSchema.safeParse("e48:10fb:1499:3e28:e4b6:dea5:4692:912c").success).toBe(true);
1103
+
1104
+ // expect(ipSchema.safeParse("d329:1be4:25b4:db47:a9d1:dc71:4926:992c:14af").success).toBe(false);
1105
+ // expect(ipSchema.safeParse("d5e7:7214:2b78::3906:85e6:53cc:709:32ba").success).toBe(false);
1106
+ // expect(ipSchema.safeParse("8f69::c757:395e:976e::3441").success).toBe(false);
1107
+ // expect(ipSchema.safeParse("54cb::473f:d516:0.255.256.22").success).toBe(false);
1108
+ // expect(ipSchema.safeParse("54cb::473f:d516:192.168.1").success).toBe(false);
1109
+ // expect(ipSchema.safeParse("256.0.4.4").success).toBe(false);
1110
+ // expect(ipSchema.safeParse("-1.0.555.4").success).toBe(false);
1111
+ // expect(ipSchema.safeParse("0.0.0.0.0").success).toBe(false);
1112
+ // expect(ipSchema.safeParse("1.1.1").success).toBe(false);
1113
+ // });
1114
+
1115
+ test("IPv4 validation", () => {
1116
+ const ipv4 = z.string().ipv4();
1117
+
1118
+ // Valid IPv4 addresses
1119
+ expect(ipv4.safeParse("114.71.82.94").success).toBe(true);
1120
+ expect(ipv4.safeParse("0.0.0.0").success).toBe(true);
1121
+ expect(ipv4.safeParse("37.85.236.115").success).toBe(true);
1122
+ expect(ipv4.safeParse("192.168.0.1").success).toBe(true);
1123
+ expect(ipv4.safeParse("255.255.255.255").success).toBe(true);
1124
+ expect(ipv4.safeParse("1.2.3.4").success).toBe(true);
1125
+
1126
+ // Invalid IPv4 addresses
1127
+ expect(ipv4.safeParse("256.0.4.4").success).toBe(false);
1128
+ expect(ipv4.safeParse("-1.0.555.4").success).toBe(false);
1129
+ expect(ipv4.safeParse("0.0.0.0.0").success).toBe(false);
1130
+ expect(ipv4.safeParse("1.1.1").success).toBe(false);
1131
+ expect(ipv4.safeParse("1e5e:e6c8:daac:514b:114b:e360:d8c0:682c").success).toBe(false);
1132
+ expect(ipv4.safeParse("a6ea::2454:a5ce:94.105.123.75").success).toBe(false);
1133
+ expect(ipv4.safeParse("not an ip").success).toBe(false);
1134
+ expect(ipv4.safeParse("1.2.3").success).toBe(false);
1135
+ expect(ipv4.safeParse("1.2.3.4.5").success).toBe(false);
1136
+ expect(ipv4.safeParse("1.2.3.256").success).toBe(false);
1137
+
1138
+ // Test specific error
1139
+ expect(() => ipv4.parse("6097:adfa:6f0b:220d:db08:5021:6191:7990")).toThrow();
1140
+ });
1141
+
1142
+ test("IPv6 validation", () => {
1143
+ const ipv6 = z.string().ipv6();
1144
+
1145
+ // Valid IPv6 addresses
1146
+ expect(ipv6.safeParse("1e5e:e6c8:daac:514b:114b:e360:d8c0:682c").success).toBe(true);
1147
+ expect(ipv6.safeParse("9d4:c956:420f:5788:4339:9b3b:2418:75c3").success).toBe(true);
1148
+ expect(ipv6.safeParse("a6ea::2454:a5ce:94.105.123.75").success).toBe(true);
1149
+ expect(ipv6.safeParse("474f:4c83::4e40:a47:ff95:0cda").success).toBe(true);
1150
+ expect(ipv6.safeParse("d329:0:25b4:db47:a9d1:0:4926:0000").success).toBe(true);
1151
+ expect(ipv6.safeParse("e48:10fb:1499:3e28:e4b6:dea5:4692:912c").success).toBe(true);
1152
+ expect(ipv6.safeParse("::1").success).toBe(true);
1153
+ expect(ipv6.safeParse("2001:db8::").success).toBe(true);
1154
+ expect(ipv6.safeParse("2001:0db8:85a3:0000:0000:8a2e:0370:7334").success).toBe(true);
1155
+ expect(ipv6.safeParse("2001:db8::192.168.0.1").success).toBe(true);
1156
+ expect(ipv6.safeParse("::ffff:192.168.0.1").success).toBe(true);
1157
+ expect(ipv6.safeParse("::ffff:c000:0280").success).toBe(true); // IPv4-mapped IPv6 address
1158
+ expect(ipv6.safeParse("64:ff9b::192.168.0.1").success).toBe(true); // IPv4/IPv6 translation
1159
+
1160
+ // Invalid IPv6 addresses
1161
+ expect(ipv6.safeParse("d329:1be4:25b4:db47:a9d1:dc71:4926:992c:14af").success).toBe(false);
1162
+ expect(ipv6.safeParse("d5e7:7214:2b78::3906:85e6:53cc:709:32ba").success).toBe(false);
1163
+ expect(ipv6.safeParse("8f69::c757:395e:976e::3441").success).toBe(false);
1164
+ expect(ipv6.safeParse("54cb::473f:d516:0.255.256.22").success).toBe(false);
1165
+ expect(ipv6.safeParse("54cb::473f:d516:192.168.1").success).toBe(false);
1166
+ expect(ipv6.safeParse("114.71.82.94").success).toBe(false);
1167
+ expect(ipv6.safeParse("not an ip").success).toBe(false);
1168
+ expect(ipv6.safeParse("g123::1234:5678").success).toBe(false);
1169
+
1170
+ // Test specific error
1171
+ expect(() => ipv6.parse("254.164.77.1")).toThrow();
1172
+ });
1173
+
1174
+ test("MAC validation", () => {
1175
+ const mac = z.mac();
1176
+
1177
+ // Valid MAC addresses
1178
+ expect(mac.safeParse("00:1A:2B:3C:4D:5E").success).toBe(true);
1179
+ expect(mac.safeParse("FF:FF:FF:FF:FF:FF").success).toBe(true);
1180
+ expect(mac.safeParse("00:11:22:33:44:55").success).toBe(true);
1181
+ expect(mac.safeParse("A1:B2:C3:D4:E5:F6").success).toBe(true);
1182
+ expect(mac.safeParse("10:20:30:40:50:60").success).toBe(true);
1183
+ expect(mac.safeParse("0a:1b:2c:3d:4e:5f").success).toBe(true);
1184
+ expect(mac.safeParse("12:34:56:78:9A:BC").success).toBe(true);
1185
+
1186
+ // Invalid MAC addresses
1187
+ expect(mac.safeParse("00:1A-2B:3C-4D:5E").success).toBe(false);
1188
+ expect(mac.safeParse("00:1A:2B:3C:4D").success).toBe(false);
1189
+ expect(mac.safeParse("00:1A:2B:3C:4D").success).toBe(false);
1190
+ expect(mac.safeParse("00-1A-2B-3C-4D").success).toBe(false);
1191
+ expect(mac.safeParse("01-23-45-67-89-AB").success).toBe(false); // Dash delimiter not accepted by default
1192
+ expect(mac.safeParse("AA-BB-CC-DD-EE-FF").success).toBe(false); // Dash delimiter not accepted by default
1193
+ expect(mac.safeParse("DE-AD-BE-EF-00-01").success).toBe(false); // Dash delimiter not accepted by default
1194
+ expect(mac.safeParse("98-76-54-32-10-FF").success).toBe(false); // Dash delimiter not accepted by default
1195
+ expect(mac.safeParse("00:1A:2B:3C:4D:GZ").success).toBe(false);
1196
+ expect(mac.safeParse("00:1A:2B:3C:4D:5E:GG").success).toBe(false);
1197
+ expect(mac.safeParse("123:45:67:89:AB:CD").success).toBe(false);
1198
+ expect(mac.safeParse("00--1A:2B:3C:4D:5E").success).toBe(false);
1199
+ expect(mac.safeParse("00:1A::2B:3C:4D:5E").success).toBe(false);
1200
+ expect(mac.safeParse("00:1A:2B:3C:3C:2B:1A:00").success).toBe(false); // Disallow EUI-64
1201
+ expect(mac.safeParse("00:1a:2B:3c:4D:5e").success).toBe(false); // Disallow mixed-case
1202
+
1203
+ // MAC formats that are nonstandard but occassionally referenced, ex. https://www.postgresql.org/docs/17/datatype-net-types.html#DATATYPE-MACADDR
1204
+ expect(mac.safeParse("00:1A:2B:3C:4D:5E:FF").success).toBe(false);
1205
+ expect(mac.safeParse("001A2B:3C4D5E").success).toBe(false);
1206
+ expect(mac.safeParse("001A:2B3C:4D5E").success).toBe(false);
1207
+ expect(mac.safeParse("001A.2B3C.4D5E").success).toBe(false);
1208
+ expect(mac.safeParse("001A2B3C4D5E").success).toBe(false);
1209
+ expect(mac.safeParse("00.1A.2B.3C.4D.5E").success).toBe(false);
1210
+ });
1211
+
1212
+ test("MAC validation with custom delimiter", () => {
1213
+ const colonMac = z.mac({ delimiter: ":" });
1214
+ expect(colonMac.safeParse("00:1A:2B:3C:4D:5E").success).toBe(true);
1215
+ expect(colonMac.safeParse("00-1A-2B-3C-4D-5E").success).toBe(false);
1216
+
1217
+ const dashMac = z.mac({ delimiter: "-" });
1218
+ expect(dashMac.safeParse("00-1A-2B-3C-4D-5E").success).toBe(true);
1219
+ expect(dashMac.safeParse("00:1A:2B:3C:4D:5E").success).toBe(false);
1220
+
1221
+ const colonOnlyMac = z.mac({ delimiter: ":" });
1222
+ expect(colonOnlyMac.safeParse("00:1A:2B:3C:4D:5E").success).toBe(true);
1223
+ expect(colonOnlyMac.safeParse("00-1A-2B-3C-4D-5E").success).toBe(false);
1224
+ });
1225
+
1226
+ test("CIDR v4 validation", () => {
1227
+ const cidrV4 = z.string().cidrv4();
1228
+
1229
+ // Valid CIDR v4 addresses
1230
+ expect(cidrV4.safeParse("192.168.0.0/24").success).toBe(true);
1231
+ expect(cidrV4.safeParse("10.0.0.0/8").success).toBe(true);
1232
+ expect(cidrV4.safeParse("172.16.0.0/12").success).toBe(true);
1233
+ expect(cidrV4.safeParse("0.0.0.0/0").success).toBe(true);
1234
+ expect(cidrV4.safeParse("255.255.255.255/32").success).toBe(true);
1235
+
1236
+ // Invalid CIDR v4 addresses
1237
+ expect(cidrV4.safeParse("192.168.0.0").success).toBe(false); // Missing prefix
1238
+ expect(cidrV4.safeParse("192.168.0.0/33").success).toBe(false); // Invalid prefix length
1239
+ expect(cidrV4.safeParse("256.0.0.0/24").success).toBe(false); // Invalid IP
1240
+ expect(cidrV4.safeParse("192.168.0.0/-1").success).toBe(false); // Negative prefix length
1241
+ expect(cidrV4.safeParse("not a cidr").success).toBe(false); // Invalid format
1242
+ });
1243
+
1244
+ test("CIDR v6 validation", () => {
1245
+ const cidrV6 = z.string().cidrv6();
1246
+
1247
+ // Valid CIDR v6 addresses
1248
+ expect(cidrV6.safeParse("2001:db8::/32").success).toBe(true);
1249
+ expect(cidrV6.safeParse("::/0").success).toBe(true);
1250
+ expect(cidrV6.safeParse("fe80::/10").success).toBe(true);
1251
+ expect(cidrV6.safeParse("::1/128").success).toBe(true);
1252
+ expect(cidrV6.safeParse("2001:0db8:85a3::/64").success).toBe(true);
1253
+ expect(cidrV6.safeParse("2001:db8:1::/48").success).toBe(true);
1254
+ expect(cidrV6.safeParse("2001:db8:85a3::8a2e:370:7334/64").success).toBe(true);
1255
+ expect(cidrV6.safeParse("2001:db8:85a3:0:0:8a2e:370:7334/64").success).toBe(true);
1256
+
1257
+ const pattern = new RegExp(z.toJSONSchema(cidrV6).pattern as string);
1258
+ for (const input of ["2001:db8::/32", "2001:db8:1::/48", "2001:0db8:85a3::/64", "fe80::/10", "::/0"]) {
1259
+ expect(pattern.test(input)).toBe(true);
1260
+ }
1261
+
1262
+ // Invalid CIDR v6 addresses
1263
+ expect(cidrV6.safeParse("2001:db8::").success).toBe(false); // Missing prefix
1264
+ expect(cidrV6.safeParse("2001:db8::/129").success).toBe(false); // Invalid prefix length
1265
+ expect(cidrV6.safeParse("2001:db8::/abc").success).toBe(false); // Invalid prefix format
1266
+ expect(cidrV6.safeParse("not a cidr").success).toBe(false); // Invalid format
1267
+ expect(cidrV6.safeParse("192.168.0.0/24").success).toBe(false); // IPv4 CIDR in v6 validation
1268
+ expect(cidrV6.safeParse("2001:0db8:85a3::/64/whatever-after").success).toBe(false);
1269
+ expect(cidrV6.safeParse("22d9:f4a8:6a90:f3bf:dcaa:2beb:5fba:0000/112").success).toBe(true);
1270
+ expect(cidrV6.safeParse("22d9:f4a8:6a90:f3bf:dcaa:2beb:5fba:0000/112/268").success).toBe(false);
1271
+ });
1272
+
1273
+ test("E.164 validation", () => {
1274
+ const e164Number = z.string().e164();
1275
+ expect(e164Number.safeParse("+1555555").success).toBe(true);
1276
+
1277
+ const validE164Numbers = [
1278
+ "+1555555", // min-length (7 digits + '+')
1279
+ "+15555555",
1280
+ "+155555555",
1281
+ "+1555555555",
1282
+ "+15555555555",
1283
+ "+155555555555",
1284
+ "+1555555555555",
1285
+ "+15555555555555",
1286
+ "+155555555555555",
1287
+ "+105555555555555",
1288
+ "+100555555555555", // max-length (15 digits + '+')
1289
+ ];
1290
+
1291
+ const invalidE164Numbers = [
1292
+ "", // empty
1293
+ "+", // only plus sign
1294
+ "-", // wrong sign
1295
+ " 555555555", // starts with space
1296
+ "555555555", // missing plus sign
1297
+ "+1 555 555 555", // space after plus sign
1298
+ "+1555 555 555", // space between numbers
1299
+ "+1555+555", // multiple plus signs
1300
+ "+0000000", // leading zero country code
1301
+ "+0123456789", // leading zero with more digits
1302
+ "+1555555555555555", // too long
1303
+ "+115abc55", // non numeric characters in number part
1304
+ "+1555555 ", // space after number
1305
+ ];
1306
+
1307
+ expect(validE164Numbers.every((number) => e164Number.safeParse(number).success)).toBe(true);
1308
+ expect(invalidE164Numbers.every((number) => e164Number.safeParse(number).success === false)).toBe(true);
1309
+ });
1310
+
1311
+ test("hostname", () => {
1312
+ const hostname = z.hostname();
1313
+
1314
+ // Valid hostnames
1315
+ hostname.parse("localhost");
1316
+ hostname.parse("example.com");
1317
+ hostname.parse("sub.example.com");
1318
+ hostname.parse("a-b-c.example.com");
1319
+ hostname.parse("123.example.com");
1320
+ hostname.parse("example-123.com");
1321
+ hostname.parse("example-123.1234");
1322
+ hostname.parse("developer.mozilla.org");
1323
+ hostname.parse("hello.world.example.com");
1324
+ hostname.parse("www.google.com");
1325
+ hostname.parse("192.168.1.1");
1326
+ hostname.parse("xn--d1acj3b.com");
1327
+ hostname.parse("xn--d1acj3b.org");
1328
+ hostname.parse("xn--d1acj3b");
1329
+
1330
+ // Invalid hostnames
1331
+ expect(() => hostname.parse("")).toThrow();
1332
+ expect(() => hostname.parse("example..com")).toThrow();
1333
+ expect(() => hostname.parse("example-.com")).toThrow();
1334
+ expect(() => hostname.parse("-example.com")).toThrow();
1335
+ expect(() => hostname.parse("example.com-")).toThrow();
1336
+ expect(() => hostname.parse("example_com")).toThrow();
1337
+ expect(() => hostname.parse("example.com:8080")).toThrow();
1338
+ expect(() => hostname.parse("http://example.com")).toThrow();
1339
+ expect(() => hostname.parse("ht!tp://invalid.com")).toThrow();
1340
+
1341
+ expect(() => hostname.parse("xn--d1acj3b..com")).toThrow();
1342
+ expect(() => hostname.parse("ex@mple.com")).toThrow();
1343
+ expect(() => hostname.parse("[2001:db8::zzzz]")).toThrow();
1344
+ expect(() => hostname.parse("exa mple.com")).toThrow();
1345
+ expect(() => hostname.parse("-example.com")).toThrow();
1346
+ expect(() => hostname.parse("example..com")).toThrow();
1347
+ });
1348
+
1349
+ test("currency code", () => {
1350
+ const currency = z.currencyCode();
1351
+ for (const code of ["USD", "EUR", "XXX", "XCG", "XAD"]) expect(currency.parse(code)).toBe(code);
1352
+ for (const input of ["", "usd", "US", "USDX", " USD", "ANG", "BGN"])
1353
+ expect(currency.safeParse(input).success).toBe(false);
1354
+ expect(currency.safeParse("usd").error!.issues[0]).toMatchObject({
1355
+ code: "invalid_format",
1356
+ format: "currency_code",
1357
+ message: "Invalid currency code",
1358
+ });
1359
+ });
1360
+
1361
+ test("hash validation", () => {
1362
+ // MD5 tests
1363
+ const md5hex = z.hash("md5");
1364
+ const md5base64 = z.hash("md5", { enc: "base64" });
1365
+ const md5base64url = z.hash("md5", { enc: "base64url" });
1366
+
1367
+ // Valid MD5 hashes
1368
+ expect(md5hex.parse("5d41402abc4b2a76b9719d911017c592")).toBe("5d41402abc4b2a76b9719d911017c592");
1369
+ expect(md5hex.parse("5D41402ABC4B2A76B9719D911017C592")).toBe("5D41402ABC4B2A76B9719D911017C592"); // uppercase
1370
+ expect(md5base64.parse("XUFAKrxLKna5cZ2REBfFkg==")).toBe("XUFAKrxLKna5cZ2REBfFkg==");
1371
+ expect(md5base64url.parse("XUFAKrxLKna5cZ2REBfFkg")).toBe("XUFAKrxLKna5cZ2REBfFkg");
1372
+
1373
+ // Invalid MD5 hashes
1374
+ expect(() => md5hex.parse("5d41402abc4b2a76b9719d911017c59")).toThrow(); // too short
1375
+ expect(() => md5hex.parse("5d41402abc4b2a76b9719d911017c592x")).toThrow(); // too long
1376
+ expect(() => md5base64.parse("XUFAKrxLKna5cZ2REBfFkg=")).toThrow(); // wrong padding
1377
+ expect(() => md5base64url.parse("XUFAKrxLKna5cZ2REBfFkg=")).toThrow(); // has padding
1378
+
1379
+ // SHA1 tests
1380
+ const sha1hex = z.hash("sha1");
1381
+ const sha1base64 = z.hash("sha1", { enc: "base64" });
1382
+ const sha1base64url = z.hash("sha1", { enc: "base64url" });
1383
+
1384
+ // Valid SHA1 hashes
1385
+ expect(sha1hex.parse("aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d")).toBe("aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d");
1386
+ expect(sha1base64.parse("qvTGHdzF6KLavt4PO0gs2a6pQ00=")).toBe("qvTGHdzF6KLavt4PO0gs2a6pQ00=");
1387
+ expect(sha1base64url.parse("qvTGHdzF6KLavt4PO0gs2a6pQ00")).toBe("qvTGHdzF6KLavt4PO0gs2a6pQ00");
1388
+
1389
+ // SHA256 tests
1390
+ const sha256hex = z.hash("sha256");
1391
+ const sha256base64 = z.hash("sha256", { enc: "base64" });
1392
+ const sha256base64url = z.hash("sha256", { enc: "base64url" });
1393
+
1394
+ // Valid SHA256 hashes
1395
+ expect(sha256hex.parse("2cf24dba4f21d4288094c4a2e2c2d6c6b0c3e0c8f0e0c8f0e0c8f0e0c8f0e0c8")).toBe(
1396
+ "2cf24dba4f21d4288094c4a2e2c2d6c6b0c3e0c8f0e0c8f0e0c8f0e0c8f0e0c8"
1397
+ );
1398
+ expect(sha256base64.parse("LPJNul+wow4m6DsqxbninhsWHlwfp0JecwQzYpOLmCQ=")).toBe(
1399
+ "LPJNul+wow4m6DsqxbninhsWHlwfp0JecwQzYpOLmCQ="
1400
+ );
1401
+ expect(sha256base64url.parse("LPJNul-wow4m6DsqxbninhsWHlwfp0JecwQzYpOLmCQ")).toBe(
1402
+ "LPJNul-wow4m6DsqxbninhsWHlwfp0JecwQzYpOLmCQ"
1403
+ );
1404
+
1405
+ // SHA384 tests (no padding in base64)
1406
+ const sha384hex = z.hash("sha384");
1407
+ const sha384base64 = z.hash("sha384", { enc: "base64" });
1408
+
1409
+ expect(
1410
+ sha384hex.parse("59e1748777448c69de6b800d7a33bbfb9ff1b463e44354c3553bcdb9c666fa90125a3c79f90397bdf5f6a13de828684f")
1411
+ ).toBe("59e1748777448c69de6b800d7a33bbfb9ff1b463e44354c3553bcdb9c666fa90125a3c79f90397bdf5f6a13de828684f");
1412
+ expect(sha384base64.parse("WeF0h3dEjGneawDXozO7+5/xtGPkQ1TDVTvNucZm+pASWjx5+QOXvfX2oT3oKGhP")).toBe(
1413
+ "WeF0h3dEjGneawDXozO7+5/xtGPkQ1TDVTvNucZm+pASWjx5+QOXvfX2oT3oKGhP"
1414
+ );
1415
+
1416
+ // SHA512 tests
1417
+ const sha512hex = z.hash("sha512");
1418
+ const sha512base64 = z.hash("sha512", { enc: "base64" });
1419
+
1420
+ expect(
1421
+ sha512hex.parse(
1422
+ "9b71d224bd62f3785d96d46ad3ea3d73319bfbc2890caadae2dff72519673ca72323c3d99ba5c11d7c7acc6e14b8c5da0c4663475c2e5c3adef46f73bcdec043"
1423
+ )
1424
+ ).toBe(
1425
+ "9b71d224bd62f3785d96d46ad3ea3d73319bfbc2890caadae2dff72519673ca72323c3d99ba5c11d7c7acc6e14b8c5da0c4663475c2e5c3adef46f73bcdec043"
1426
+ );
1427
+ expect(
1428
+ sha512base64.parse("m3HSJL1i83hdltRq0+o9czGb+8KJDKra4t/3JRlnPKcjI8PZm6XBHXx6zG4UuMXaDEZjR1wuXDre9G9zvN7AQw==")
1429
+ ).toBe("m3HSJL1i83hdltRq0+o9czGb+8KJDKra4t/3JRlnPKcjI8PZm6XBHXx6zG4UuMXaDEZjR1wuXDre9G9zvN7AQw==");
1430
+
1431
+ // Test default encoding (hex)
1432
+ const defaultHash = z.hash("sha256");
1433
+ expect(defaultHash.parse("2cf24dba4f21d4288094c4a2e2c2d6c6b0c3e0c8f0e0c8f0e0c8f0e0c8f0e0c8")).toBe(
1434
+ "2cf24dba4f21d4288094c4a2e2c2d6c6b0c3e0c8f0e0c8f0e0c8f0e0c8f0e0c8"
1435
+ );
1436
+
1437
+ // Test with custom error message
1438
+ const hashWithMessage = z.hash("md5", { message: "Invalid MD5 hash" });
1439
+ expect(() => hashWithMessage.parse("invalid")).toThrow("Invalid MD5 hash");
1440
+ });