zod 3.26.0-canary.20250703T011142 → 3.26.0-canary.20250703T025502

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 (269) hide show
  1. package/package.json +4 -4
  2. package/src/index.ts +4 -0
  3. package/src/v3/ZodError.ts +330 -0
  4. package/src/v3/benchmarks/datetime.ts +58 -0
  5. package/src/v3/benchmarks/discriminatedUnion.ts +80 -0
  6. package/src/v3/benchmarks/index.ts +59 -0
  7. package/src/v3/benchmarks/ipv4.ts +57 -0
  8. package/src/v3/benchmarks/object.ts +69 -0
  9. package/src/v3/benchmarks/primitives.ts +162 -0
  10. package/src/v3/benchmarks/realworld.ts +63 -0
  11. package/src/v3/benchmarks/string.ts +55 -0
  12. package/src/v3/benchmarks/union.ts +80 -0
  13. package/src/v3/errors.ts +13 -0
  14. package/src/v3/external.ts +6 -0
  15. package/src/v3/helpers/enumUtil.ts +17 -0
  16. package/src/v3/helpers/errorUtil.ts +8 -0
  17. package/src/v3/helpers/parseUtil.ts +176 -0
  18. package/src/v3/helpers/partialUtil.ts +34 -0
  19. package/src/v3/helpers/typeAliases.ts +2 -0
  20. package/src/v3/helpers/util.ts +224 -0
  21. package/src/v3/index.ts +4 -0
  22. package/src/v3/locales/en.ts +124 -0
  23. package/src/v3/standard-schema.ts +113 -0
  24. package/src/v3/tests/Mocker.ts +54 -0
  25. package/src/v3/tests/all-errors.test.ts +157 -0
  26. package/src/v3/tests/anyunknown.test.ts +28 -0
  27. package/src/v3/tests/array.test.ts +71 -0
  28. package/src/v3/tests/async-parsing.test.ts +388 -0
  29. package/src/v3/tests/async-refinements.test.ts +46 -0
  30. package/src/v3/tests/base.test.ts +29 -0
  31. package/src/v3/tests/bigint.test.ts +55 -0
  32. package/src/v3/tests/branded.test.ts +53 -0
  33. package/src/v3/tests/catch.test.ts +220 -0
  34. package/src/v3/tests/coerce.test.ts +133 -0
  35. package/src/v3/tests/complex.test.ts +56 -0
  36. package/src/v3/tests/custom.test.ts +31 -0
  37. package/src/v3/tests/date.test.ts +32 -0
  38. package/src/v3/tests/deepmasking.test.ts +186 -0
  39. package/src/v3/tests/default.test.ts +112 -0
  40. package/src/v3/tests/description.test.ts +33 -0
  41. package/src/v3/tests/discriminated-unions.test.ts +315 -0
  42. package/src/v3/tests/enum.test.ts +80 -0
  43. package/src/v3/tests/error.test.ts +551 -0
  44. package/src/v3/tests/firstparty.test.ts +87 -0
  45. package/src/v3/tests/firstpartyschematypes.test.ts +21 -0
  46. package/src/v3/tests/function.test.ts +257 -0
  47. package/src/v3/tests/generics.test.ts +48 -0
  48. package/src/v3/tests/instanceof.test.ts +37 -0
  49. package/src/v3/tests/intersection.test.ts +110 -0
  50. package/src/v3/tests/language-server.source.ts +76 -0
  51. package/src/v3/tests/language-server.test.ts +207 -0
  52. package/src/v3/tests/literal.test.ts +36 -0
  53. package/src/v3/tests/map.test.ts +110 -0
  54. package/src/v3/tests/masking.test.ts +4 -0
  55. package/src/v3/tests/mocker.test.ts +19 -0
  56. package/src/v3/tests/nan.test.ts +21 -0
  57. package/src/v3/tests/nativeEnum.test.ts +87 -0
  58. package/src/v3/tests/nullable.test.ts +42 -0
  59. package/src/v3/tests/number.test.ts +176 -0
  60. package/src/v3/tests/object-augmentation.test.ts +29 -0
  61. package/src/v3/tests/object-in-es5-env.test.ts +29 -0
  62. package/src/v3/tests/object.test.ts +434 -0
  63. package/src/v3/tests/optional.test.ts +42 -0
  64. package/src/v3/tests/parseUtil.test.ts +23 -0
  65. package/src/v3/tests/parser.test.ts +41 -0
  66. package/src/v3/tests/partials.test.ts +243 -0
  67. package/src/v3/tests/pickomit.test.ts +111 -0
  68. package/src/v3/tests/pipeline.test.ts +29 -0
  69. package/src/v3/tests/preprocess.test.ts +186 -0
  70. package/src/v3/tests/primitive.test.ts +440 -0
  71. package/src/v3/tests/promise.test.ts +90 -0
  72. package/src/v3/tests/readonly.test.ts +194 -0
  73. package/src/v3/tests/record.test.ts +171 -0
  74. package/src/v3/tests/recursive.test.ts +197 -0
  75. package/src/v3/tests/refine.test.ts +313 -0
  76. package/src/v3/tests/safeparse.test.ts +27 -0
  77. package/src/v3/tests/set.test.ts +142 -0
  78. package/src/v3/tests/standard-schema.test.ts +83 -0
  79. package/src/v3/tests/string.test.ts +916 -0
  80. package/src/v3/tests/transformer.test.ts +233 -0
  81. package/src/v3/tests/tuple.test.ts +90 -0
  82. package/src/v3/tests/unions.test.ts +57 -0
  83. package/src/v3/tests/validations.test.ts +133 -0
  84. package/src/v3/tests/void.test.ts +15 -0
  85. package/src/v3/types.ts +5136 -0
  86. package/src/v4/classic/checks.ts +30 -0
  87. package/src/v4/classic/coerce.ts +27 -0
  88. package/src/v4/classic/compat.ts +66 -0
  89. package/src/v4/classic/errors.ts +75 -0
  90. package/src/v4/classic/external.ts +50 -0
  91. package/src/v4/classic/index.ts +5 -0
  92. package/src/v4/classic/iso.ts +90 -0
  93. package/src/v4/classic/parse.ts +33 -0
  94. package/src/v4/classic/schemas.ts +2055 -0
  95. package/src/v4/classic/tests/anyunknown.test.ts +26 -0
  96. package/src/v4/classic/tests/array.test.ts +264 -0
  97. package/src/v4/classic/tests/assignability.test.ts +210 -0
  98. package/src/v4/classic/tests/async-parsing.test.ts +381 -0
  99. package/src/v4/classic/tests/async-refinements.test.ts +68 -0
  100. package/src/v4/classic/tests/base.test.ts +7 -0
  101. package/src/v4/classic/tests/bigint.test.ts +54 -0
  102. package/src/v4/classic/tests/brand.test.ts +65 -0
  103. package/src/v4/classic/tests/catch.test.ts +252 -0
  104. package/src/v4/classic/tests/coalesce.test.ts +20 -0
  105. package/src/v4/classic/tests/coerce.test.ts +160 -0
  106. package/src/v4/classic/tests/continuability.test.ts +352 -0
  107. package/src/v4/classic/tests/custom.test.ts +40 -0
  108. package/src/v4/classic/tests/date.test.ts +31 -0
  109. package/src/v4/classic/tests/datetime.test.ts +296 -0
  110. package/src/v4/classic/tests/default.test.ts +313 -0
  111. package/src/v4/classic/tests/description.test.ts +32 -0
  112. package/src/v4/classic/tests/discriminated-unions.test.ts +592 -0
  113. package/src/v4/classic/tests/enum.test.ts +285 -0
  114. package/src/v4/classic/tests/error-utils.test.ts +527 -0
  115. package/src/v4/classic/tests/error.test.ts +711 -0
  116. package/src/v4/classic/tests/file.test.ts +91 -0
  117. package/src/v4/classic/tests/firstparty.test.ts +175 -0
  118. package/src/v4/classic/tests/function.test.ts +268 -0
  119. package/src/v4/classic/tests/generics.test.ts +72 -0
  120. package/src/v4/classic/tests/index.test.ts +829 -0
  121. package/src/v4/classic/tests/instanceof.test.ts +34 -0
  122. package/src/v4/classic/tests/intersection.test.ts +171 -0
  123. package/src/v4/classic/tests/json.test.ts +108 -0
  124. package/src/v4/classic/tests/lazy.test.ts +227 -0
  125. package/src/v4/classic/tests/literal.test.ts +92 -0
  126. package/src/v4/classic/tests/map.test.ts +196 -0
  127. package/src/v4/classic/tests/nan.test.ts +21 -0
  128. package/src/v4/classic/tests/nested-refine.test.ts +168 -0
  129. package/src/v4/classic/tests/nonoptional.test.ts +86 -0
  130. package/src/v4/classic/tests/nullable.test.ts +22 -0
  131. package/src/v4/classic/tests/number.test.ts +247 -0
  132. package/src/v4/classic/tests/object.test.ts +553 -0
  133. package/src/v4/classic/tests/optional.test.ts +103 -0
  134. package/src/v4/classic/tests/partial.test.ts +147 -0
  135. package/src/v4/classic/tests/pickomit.test.ts +127 -0
  136. package/src/v4/classic/tests/pipe.test.ts +81 -0
  137. package/src/v4/classic/tests/prefault.test.ts +37 -0
  138. package/src/v4/classic/tests/preprocess.test.ts +298 -0
  139. package/src/v4/classic/tests/primitive.test.ts +175 -0
  140. package/src/v4/classic/tests/promise.test.ts +81 -0
  141. package/src/v4/classic/tests/prototypes.test.ts +23 -0
  142. package/src/v4/classic/tests/readonly.test.ts +252 -0
  143. package/src/v4/classic/tests/record.test.ts +332 -0
  144. package/src/v4/classic/tests/recursive-types.test.ts +325 -0
  145. package/src/v4/classic/tests/refine.test.ts +423 -0
  146. package/src/v4/classic/tests/registries.test.ts +195 -0
  147. package/src/v4/classic/tests/set.test.ts +179 -0
  148. package/src/v4/classic/tests/standard-schema.test.ts +57 -0
  149. package/src/v4/classic/tests/string-formats.test.ts +109 -0
  150. package/src/v4/classic/tests/string.test.ts +881 -0
  151. package/src/v4/classic/tests/stringbool.test.ts +66 -0
  152. package/src/v4/classic/tests/template-literal.test.ts +758 -0
  153. package/src/v4/classic/tests/to-json-schema.test.ts +2182 -0
  154. package/src/v4/classic/tests/transform.test.ts +250 -0
  155. package/src/v4/classic/tests/tuple.test.ts +163 -0
  156. package/src/v4/classic/tests/union.test.ts +94 -0
  157. package/src/v4/classic/tests/validations.test.ts +283 -0
  158. package/src/v4/classic/tests/void.test.ts +12 -0
  159. package/src/v4/core/api.ts +1592 -0
  160. package/src/v4/core/checks.ts +1285 -0
  161. package/src/v4/core/config.ts +15 -0
  162. package/src/v4/core/core.ts +134 -0
  163. package/src/v4/core/doc.ts +44 -0
  164. package/src/v4/core/errors.ts +420 -0
  165. package/src/v4/core/function.ts +176 -0
  166. package/src/v4/core/index.ts +15 -0
  167. package/src/v4/core/json-schema.ts +143 -0
  168. package/src/v4/core/parse.ts +94 -0
  169. package/src/v4/core/regexes.ts +135 -0
  170. package/src/v4/core/registries.ts +86 -0
  171. package/src/v4/core/schemas.ts +3781 -0
  172. package/src/v4/core/standard-schema.ts +64 -0
  173. package/src/v4/core/tests/index.test.ts +46 -0
  174. package/src/v4/core/tests/locales/be.test.ts +124 -0
  175. package/src/v4/core/tests/locales/en.test.ts +22 -0
  176. package/src/v4/core/tests/locales/ru.test.ts +128 -0
  177. package/src/v4/core/tests/locales/tr.test.ts +69 -0
  178. package/src/v4/core/to-json-schema.ts +944 -0
  179. package/src/v4/core/util.ts +775 -0
  180. package/src/v4/core/versions.ts +5 -0
  181. package/src/v4/core/zsf.ts +323 -0
  182. package/src/v4/index.ts +4 -0
  183. package/src/v4/locales/ar.ts +125 -0
  184. package/src/v4/locales/az.ts +121 -0
  185. package/src/v4/locales/be.ts +184 -0
  186. package/src/v4/locales/ca.ts +127 -0
  187. package/src/v4/locales/cs.ts +142 -0
  188. package/src/v4/locales/de.ts +124 -0
  189. package/src/v4/locales/en.ts +127 -0
  190. package/src/v4/locales/es.ts +125 -0
  191. package/src/v4/locales/fa.ts +134 -0
  192. package/src/v4/locales/fi.ts +131 -0
  193. package/src/v4/locales/fr-CA.ts +126 -0
  194. package/src/v4/locales/fr.ts +124 -0
  195. package/src/v4/locales/he.ts +125 -0
  196. package/src/v4/locales/hu.ts +126 -0
  197. package/src/v4/locales/id.ts +125 -0
  198. package/src/v4/locales/index.ts +38 -0
  199. package/src/v4/locales/it.ts +125 -0
  200. package/src/v4/locales/ja.ts +122 -0
  201. package/src/v4/locales/kh.ts +126 -0
  202. package/src/v4/locales/ko.ts +131 -0
  203. package/src/v4/locales/mk.ts +127 -0
  204. package/src/v4/locales/ms.ts +124 -0
  205. package/src/v4/locales/nl.ts +126 -0
  206. package/src/v4/locales/no.ts +124 -0
  207. package/src/v4/locales/ota.ts +125 -0
  208. package/src/v4/locales/pl.ts +126 -0
  209. package/src/v4/locales/ps.ts +133 -0
  210. package/src/v4/locales/pt.ts +123 -0
  211. package/src/v4/locales/ru.ts +184 -0
  212. package/src/v4/locales/sl.ts +126 -0
  213. package/src/v4/locales/sv.ts +127 -0
  214. package/src/v4/locales/ta.ts +125 -0
  215. package/src/v4/locales/th.ts +126 -0
  216. package/src/v4/locales/tr.ts +121 -0
  217. package/src/v4/locales/ua.ts +126 -0
  218. package/src/v4/locales/ur.ts +126 -0
  219. package/src/v4/locales/vi.ts +125 -0
  220. package/src/v4/locales/zh-CN.ts +123 -0
  221. package/src/v4/locales/zh-TW.ts +125 -0
  222. package/src/v4/mini/checks.ts +32 -0
  223. package/src/v4/mini/coerce.ts +22 -0
  224. package/src/v4/mini/external.ts +40 -0
  225. package/src/v4/mini/index.ts +3 -0
  226. package/src/v4/mini/iso.ts +62 -0
  227. package/src/v4/mini/parse.ts +1 -0
  228. package/src/v4/mini/schemas.ts +1579 -0
  229. package/src/v4/mini/tests/assignability.test.ts +129 -0
  230. package/src/v4/mini/tests/brand.test.ts +51 -0
  231. package/src/v4/mini/tests/checks.test.ts +144 -0
  232. package/src/v4/mini/tests/computed.test.ts +36 -0
  233. package/src/v4/mini/tests/error.test.ts +22 -0
  234. package/src/v4/mini/tests/functions.test.ts +43 -0
  235. package/src/v4/mini/tests/index.test.ts +871 -0
  236. package/src/v4/mini/tests/number.test.ts +95 -0
  237. package/src/v4/mini/tests/object.test.ts +185 -0
  238. package/src/v4/mini/tests/prototypes.test.ts +43 -0
  239. package/src/v4/mini/tests/recursive-types.test.ts +275 -0
  240. package/src/v4/mini/tests/string.test.ts +293 -0
  241. package/src/v4-mini/index.ts +1 -0
  242. package/v4/classic/compat.cjs +1 -7
  243. package/v4/classic/compat.d.cts +0 -2
  244. package/v4/classic/compat.d.ts +0 -2
  245. package/v4/classic/compat.js +0 -6
  246. package/v4/classic/external.cjs +2 -1
  247. package/v4/classic/external.d.cts +1 -1
  248. package/v4/classic/external.d.ts +1 -1
  249. package/v4/classic/external.js +1 -1
  250. package/v4/classic/schemas.d.cts +4 -4
  251. package/v4/classic/schemas.d.ts +4 -4
  252. package/v4/core/api.cjs +11 -10
  253. package/v4/core/api.js +11 -10
  254. package/v4/core/checks.cjs +6 -4
  255. package/v4/core/checks.js +6 -4
  256. package/v4/core/core.cjs +5 -1
  257. package/v4/core/core.d.cts +2 -0
  258. package/v4/core/core.d.ts +2 -0
  259. package/v4/core/core.js +4 -0
  260. package/v4/core/schemas.cjs +12 -13
  261. package/v4/core/schemas.js +12 -13
  262. package/v4/core/util.cjs +3 -0
  263. package/v4/core/util.d.cts +1 -1
  264. package/v4/core/util.d.ts +1 -1
  265. package/v4/core/util.js +3 -0
  266. package/v4/mini/external.cjs +2 -1
  267. package/v4/mini/external.d.cts +1 -1
  268. package/v4/mini/external.d.ts +1 -1
  269. package/v4/mini/external.js +1 -1
@@ -0,0 +1,293 @@
1
+ import { expect, expectTypeOf, test } from "vitest";
2
+ import * as z from "zod/v4-mini";
3
+
4
+ const FAIL = { success: false };
5
+
6
+ test("z.string", async () => {
7
+ const a = z.string();
8
+ expect(z.parse(a, "hello")).toEqual("hello");
9
+ expect(() => z.parse(a, 123)).toThrow();
10
+ expect(() => z.parse(a, false)).toThrow();
11
+ type a = z.infer<typeof a>;
12
+ expectTypeOf<a>().toEqualTypeOf<string>();
13
+ });
14
+
15
+ // test("z.string with description", () => {
16
+ // const a = z.string({ description: "string description" });
17
+ // a._def;
18
+ // expect(a._def.description).toEqual("string description");
19
+ // });
20
+
21
+ test("z.string with custom error", () => {
22
+ const a = z.string({ error: () => "BAD" });
23
+ expect(z.safeParse(a, 123).error!.issues[0].message).toEqual("BAD");
24
+ });
25
+
26
+ test("inference in checks", () => {
27
+ const a = z.string().check(z.refine((val) => val.length));
28
+ z.parse(a, "___");
29
+ expect(() => z.parse(a, "")).toThrow();
30
+ const b = z.string().check(z.refine((val) => val.length));
31
+ z.parse(b, "___");
32
+ expect(() => z.parse(b, "")).toThrow();
33
+ const c = z.string().check(z.refine((val) => val.length));
34
+ z.parse(c, "___");
35
+ expect(() => z.parse(c, "")).toThrow();
36
+ const d = z.string().check(z.refine((val) => val.length));
37
+ z.parse(d, "___");
38
+ expect(() => z.parse(d, "")).toThrow();
39
+ });
40
+
41
+ test("z.string async", async () => {
42
+ // async
43
+ const a = z.string().check(z.refine(async (val) => val.length));
44
+ expect(await z.parseAsync(a, "___")).toEqual("___");
45
+ await expect(() => z.parseAsync(a, "")).rejects.toThrowError();
46
+ });
47
+
48
+ test("z.uuid", () => {
49
+ const a = z.uuid();
50
+ // parse uuid
51
+ z.parse(a, "550e8400-e29b-41d4-a716-446655440000");
52
+ z.parse(a, "550e8400-e29b-61d4-a716-446655440000");
53
+
54
+ // bad uuid
55
+ expect(() => z.parse(a, "hello")).toThrow();
56
+ // wrong type
57
+ expect(() => z.parse(a, 123)).toThrow();
58
+
59
+ const b = z.uuidv4();
60
+ z.parse(b, "550e8400-e29b-41d4-a716-446655440000");
61
+ expect(z.safeParse(b, "550e8400-e29b-61d4-a716-446655440000")).toMatchObject(FAIL);
62
+
63
+ const c = z.uuidv6();
64
+ z.parse(c, "550e8400-e29b-61d4-a716-446655440000");
65
+ expect(z.safeParse(c, "550e8400-e29b-41d4-a716-446655440000")).toMatchObject(FAIL);
66
+
67
+ const d = z.uuidv7();
68
+ z.parse(d, "550e8400-e29b-71d4-a716-446655440000");
69
+ expect(z.safeParse(d, "550e8400-e29b-41d4-a716-446655440000")).toMatchObject(FAIL);
70
+ expect(z.safeParse(d, "550e8400-e29b-61d4-a716-446655440000")).toMatchObject(FAIL);
71
+ });
72
+
73
+ test("z.email", () => {
74
+ const a = z.email();
75
+ expect(z.parse(a, "test@test.com")).toEqual("test@test.com");
76
+ expect(() => z.parse(a, "test")).toThrow();
77
+ expect(z.safeParse(a, "bad email", { error: () => "bad email" }).error!.issues[0].message).toEqual("bad email");
78
+
79
+ const b = z.email("bad email");
80
+ expect(z.safeParse(b, "bad email").error!.issues[0].message).toEqual("bad email");
81
+
82
+ const c = z.email({ error: "bad email" });
83
+ expect(z.safeParse(c, "bad email").error!.issues[0].message).toEqual("bad email");
84
+
85
+ const d = z.email({ error: () => "bad email" });
86
+ expect(z.safeParse(d, "bad email").error!.issues[0].message).toEqual("bad email");
87
+ });
88
+
89
+ test("z.url", () => {
90
+ const a = z.url();
91
+ // valid URLs
92
+ expect(a.parse("http://example.com")).toEqual("http://example.com");
93
+ expect(a.parse("https://example.com")).toEqual("https://example.com");
94
+ expect(a.parse("ftp://example.com")).toEqual("ftp://example.com");
95
+ expect(a.parse("http://sub.example.com")).toEqual("http://sub.example.com");
96
+ expect(a.parse("https://example.com/path?query=123#fragment")).toEqual("https://example.com/path?query=123#fragment");
97
+ expect(a.parse("http://localhost")).toEqual("http://localhost");
98
+ expect(a.parse("https://localhost")).toEqual("https://localhost");
99
+ expect(a.parse("http://localhost:3000")).toEqual("http://localhost:3000");
100
+ expect(a.parse("https://localhost:3000")).toEqual("https://localhost:3000");
101
+
102
+ // invalid URLs
103
+ expect(() => a.parse("not-a-url")).toThrow();
104
+ // expect(() => a.parse("http:/example.com")).toThrow();
105
+ expect(() => a.parse("://example.com")).toThrow();
106
+ expect(() => a.parse("http://")).toThrow();
107
+ expect(() => a.parse("example.com")).toThrow();
108
+
109
+ // wrong type
110
+ expect(() => a.parse(123)).toThrow();
111
+ expect(() => a.parse(null)).toThrow();
112
+ expect(() => a.parse(undefined)).toThrow();
113
+ });
114
+
115
+ test("z.url with optional hostname regex", () => {
116
+ const a = z.url({ hostname: /example\.com$/ });
117
+ expect(a.parse("http://example.com")).toEqual("http://example.com");
118
+ expect(a.parse("https://sub.example.com")).toEqual("https://sub.example.com");
119
+ expect(() => a.parse("http://examples.com")).toThrow();
120
+ expect(() => a.parse("http://example.org")).toThrow();
121
+ expect(() => a.parse("asdf")).toThrow();
122
+ });
123
+
124
+ test("z.url - file urls", () => {
125
+ // file URLs
126
+ const a = z.url({ hostname: /.*/ }); // allow any hostname
127
+ expect(a.parse("file:///path/to/file.txt")).toEqual("file:///path/to/file.txt");
128
+ expect(a.parse("file:///C:/path/to/file.txt")).toEqual("file:///C:/path/to/file.txt");
129
+ expect(a.parse("file:///C:/path/to/file.txt?query=123#fragment")).toEqual(
130
+ "file:///C:/path/to/file.txt?query=123#fragment"
131
+ );
132
+ });
133
+ test("z.url with optional protocol regex", () => {
134
+ const a = z.url({ protocol: /^https?$/ });
135
+ expect(a.parse("http://example.com")).toEqual("http://example.com");
136
+ expect(a.parse("https://example.com")).toEqual("https://example.com");
137
+ expect(() => a.parse("ftp://example.com")).toThrow();
138
+ expect(() => a.parse("mailto:example@example.com")).toThrow();
139
+ expect(() => a.parse("asdf")).toThrow();
140
+ });
141
+
142
+ test("z.url with both hostname and protocol regexes", () => {
143
+ const a = z.url({ hostname: /example\.com$/, protocol: /^https$/ });
144
+ expect(a.parse("https://example.com")).toEqual("https://example.com");
145
+ expect(a.parse("https://sub.example.com")).toEqual("https://sub.example.com");
146
+ expect(() => a.parse("http://example.com")).toThrow();
147
+ expect(() => a.parse("https://example.org")).toThrow();
148
+ expect(() => a.parse("ftp://example.com")).toThrow();
149
+ expect(() => a.parse("asdf")).toThrow();
150
+ });
151
+
152
+ test("z.url with invalid regex patterns", () => {
153
+ const a = z.url({ hostname: /a+$/, protocol: /^ftp$/ });
154
+ a.parse("ftp://a");
155
+ a.parse("ftp://aaaaaaaa");
156
+ expect(() => a.parse("http://aaa")).toThrow();
157
+ expect(() => a.parse("https://example.com")).toThrow();
158
+ expect(() => a.parse("ftp://asdfasdf")).toThrow();
159
+ expect(() => a.parse("ftp://invalid")).toThrow();
160
+ });
161
+
162
+ test("z.emoji", () => {
163
+ const a = z.emoji();
164
+ expect(z.parse(a, "😀")).toEqual("😀");
165
+ expect(() => z.parse(a, "hello")).toThrow();
166
+ });
167
+
168
+ test("z.nanoid", () => {
169
+ const a = z.nanoid();
170
+ expect(z.parse(a, "8FHZpIxleEK3axQRBNNjN")).toEqual("8FHZpIxleEK3axQRBNNjN");
171
+ expect(() => z.parse(a, "abc")).toThrow();
172
+ });
173
+
174
+ test("z.cuid", () => {
175
+ const a = z.cuid();
176
+ expect(z.parse(a, "cixs7y0c0000f7x3b1z6m3w6r")).toEqual("cixs7y0c0000f7x3b1z6m3w6r");
177
+ expect(() => z.parse(a, "abc")).toThrow();
178
+ });
179
+
180
+ test("z.cuid2", () => {
181
+ const a = z.cuid2();
182
+ expect(z.parse(a, "cixs7y0c0000f7x3b1z6m3w6r")).toEqual("cixs7y0c0000f7x3b1z6m3w6r");
183
+ expect(() => z.parse(a, 123)).toThrow();
184
+ });
185
+
186
+ test("z.ulid", () => {
187
+ const a = z.ulid();
188
+ expect(z.parse(a, "01ETGRM9QYVX6S9V2F3B6JXG4N")).toEqual("01ETGRM9QYVX6S9V2F3B6JXG4N");
189
+ expect(() => z.parse(a, "abc")).toThrow();
190
+ });
191
+
192
+ test("z.xid", () => {
193
+ const a = z.xid();
194
+ expect(z.parse(a, "9m4e2mr0ui3e8a215n4g")).toEqual("9m4e2mr0ui3e8a215n4g");
195
+ expect(() => z.parse(a, "abc")).toThrow();
196
+ });
197
+
198
+ test("z.ksuid", () => {
199
+ const a = z.ksuid();
200
+ expect(z.parse(a, "2naeRjTrrHJAkfd3tOuEjw90WCA")).toEqual("2naeRjTrrHJAkfd3tOuEjw90WCA");
201
+ expect(() => z.parse(a, "abc")).toThrow();
202
+ });
203
+
204
+ // test("z.ip", () => {
205
+ // const a = z.ip();
206
+ // expect(z.parse(a, "127.0.0.1")).toEqual("127.0.0.1");
207
+ // expect(z.parse(a, "2001:0db8:85a3:0000:0000:8a2e:0370:7334")).toEqual("2001:0db8:85a3:0000:0000:8a2e:0370:7334");
208
+ // expect(() => z.parse(a, "abc")).toThrow();
209
+ // });
210
+
211
+ test("z.ipv4", () => {
212
+ const a = z.ipv4();
213
+ // valid ipv4
214
+ expect(z.parse(a, "192.168.1.1")).toEqual("192.168.1.1");
215
+ expect(z.parse(a, "255.255.255.255")).toEqual("255.255.255.255");
216
+ // invalid ipv4
217
+ expect(() => z.parse(a, "999.999.999.999")).toThrow();
218
+ expect(() => z.parse(a, "256.256.256.256")).toThrow();
219
+ expect(() => z.parse(a, "192.168.1")).toThrow();
220
+ expect(() => z.parse(a, "hello")).toThrow();
221
+ // wrong type
222
+ expect(() => z.parse(a, 123)).toThrow();
223
+ });
224
+
225
+ test("z.ipv6", () => {
226
+ const a = z.ipv6();
227
+ // valid ipv6
228
+ expect(z.parse(a, "2001:0db8:85a3:0000:0000:8a2e:0370:7334")).toEqual("2001:0db8:85a3:0000:0000:8a2e:0370:7334");
229
+ expect(z.parse(a, "::1")).toEqual("::1");
230
+ // invalid ipv6
231
+ expect(() => z.parse(a, "2001:db8::85a3::8a2e:370:7334")).toThrow();
232
+ expect(() => z.parse(a, "2001:db8:85a3:0:0:8a2e:370g:7334")).toThrow();
233
+ expect(() => z.parse(a, "hello")).toThrow();
234
+ // wrong type
235
+ expect(() => z.parse(a, 123)).toThrow();
236
+ });
237
+
238
+ test("z.base64", () => {
239
+ const a = z.base64();
240
+ // valid base64
241
+ expect(z.parse(a, "SGVsbG8gd29ybGQ=")).toEqual("SGVsbG8gd29ybGQ=");
242
+ expect(z.parse(a, "U29tZSBvdGhlciBzdHJpbmc=")).toEqual("U29tZSBvdGhlciBzdHJpbmc=");
243
+ // invalid base64
244
+ expect(() => z.parse(a, "SGVsbG8gd29ybGQ")).toThrow();
245
+ expect(() => z.parse(a, "U29tZSBvdGhlciBzdHJpbmc")).toThrow();
246
+ expect(() => z.parse(a, "hello")).toThrow();
247
+ // wrong type
248
+ expect(() => z.parse(a, 123)).toThrow();
249
+ });
250
+
251
+ // test("z.jsonString", () => {
252
+ // const a = z.jsonString();
253
+ // // valid JSON string
254
+ // expect(z.parse(a, '{"key":"value"}')).toEqual('{"key":"value"}');
255
+ // expect(z.parse(a, '["item1", "item2"]')).toEqual('["item1", "item2"]');
256
+ // // invalid JSON string
257
+ // expect(() => z.parse(a, '{"key":value}')).toThrow();
258
+ // expect(() => z.parse(a, '["item1", "item2"')).toThrow();
259
+ // expect(() => z.parse(a, "hello")).toThrow();
260
+ // // wrong type
261
+ // expect(() => z.parse(a, 123)).toThrow();
262
+ // });
263
+
264
+ test("z.e164", () => {
265
+ const a = z.e164();
266
+ // valid e164
267
+ expect(z.parse(a, "+1234567890")).toEqual("+1234567890");
268
+ expect(z.parse(a, "+19876543210")).toEqual("+19876543210");
269
+ // invalid e164
270
+ expect(() => z.parse(a, "1234567890")).toThrow();
271
+ expect(() => z.parse(a, "+12345")).toThrow();
272
+ expect(() => z.parse(a, "hello")).toThrow();
273
+ // wrong type
274
+ expect(() => z.parse(a, 123)).toThrow();
275
+ });
276
+
277
+ test("z.jwt", () => {
278
+ const a = z.jwt();
279
+ // valid jwt
280
+ expect(
281
+ z.parse(
282
+ a,
283
+ "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
284
+ )
285
+ ).toEqual(
286
+ "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
287
+ );
288
+ // invalid jwt
289
+ expect(() => z.parse(a, "invalid.jwt.token")).toThrow();
290
+ expect(() => z.parse(a, "hello")).toThrow();
291
+ // wrong type
292
+ expect(() => z.parse(a, 123)).toThrow();
293
+ });
@@ -0,0 +1 @@
1
+ export * from "../v4/mini/index.js";
@@ -24,7 +24,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  return result;
25
25
  };
26
26
  Object.defineProperty(exports, "__esModule", { value: true });
27
- exports.config = exports.$brand = exports.NEVER = exports.ZodIssueCode = void 0;
27
+ exports.config = exports.$brand = exports.ZodIssueCode = void 0;
28
28
  exports.setErrorMap = setErrorMap;
29
29
  exports.getErrorMap = getErrorMap;
30
30
  const core = __importStar(require("../core/index.cjs"));
@@ -42,12 +42,6 @@ exports.ZodIssueCode = {
42
42
  invalid_value: "invalid_value",
43
43
  custom: "custom",
44
44
  };
45
- /** @deprecated Not necessary in Zod 4. */
46
- const INVALID = Object.freeze({
47
- status: "aborted",
48
- });
49
- /** A special constant with type `never` */
50
- exports.NEVER = INVALID;
51
45
  var index_js_1 = require("../core/index.cjs");
52
46
  Object.defineProperty(exports, "$brand", { enumerable: true, get: function () { return index_js_1.$brand; } });
53
47
  Object.defineProperty(exports, "config", { enumerable: true, get: function () { return index_js_1.config; } });
@@ -21,8 +21,6 @@ export declare const ZodIssueCode: {
21
21
  readonly invalid_value: "invalid_value";
22
22
  readonly custom: "custom";
23
23
  };
24
- /** A special constant with type `never` */
25
- export declare const NEVER: never;
26
24
  /** @deprecated Use `z.$ZodFlattenedError` */
27
25
  export type inferFlattenedErrors<T extends core.$ZodType, U = string> = core.$ZodFlattenedError<core.output<T>, U>;
28
26
  /** @deprecated Use `z.$ZodFormattedError` */
@@ -21,8 +21,6 @@ export declare const ZodIssueCode: {
21
21
  readonly invalid_value: "invalid_value";
22
22
  readonly custom: "custom";
23
23
  };
24
- /** A special constant with type `never` */
25
- export declare const NEVER: never;
26
24
  /** @deprecated Use `z.$ZodFlattenedError` */
27
25
  export type inferFlattenedErrors<T extends core.$ZodType, U = string> = core.$ZodFlattenedError<core.output<T>, U>;
28
26
  /** @deprecated Use `z.$ZodFormattedError` */
@@ -14,12 +14,6 @@ export const ZodIssueCode = {
14
14
  invalid_value: "invalid_value",
15
15
  custom: "custom",
16
16
  };
17
- /** @deprecated Not necessary in Zod 4. */
18
- const INVALID = Object.freeze({
19
- status: "aborted",
20
- });
21
- /** A special constant with type `never` */
22
- export const NEVER = INVALID;
23
17
  export { $brand, config } from "../core/index.js";
24
18
  /** @deprecated Use `z.config(params)` instead. */
25
19
  export function setErrorMap(map) {
@@ -29,7 +29,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
29
29
  return (mod && mod.__esModule) ? mod : { "default": mod };
30
30
  };
31
31
  Object.defineProperty(exports, "__esModule", { value: true });
32
- exports.coerce = exports.iso = exports.ZodISODuration = exports.ZodISOTime = exports.ZodISODate = exports.ZodISODateTime = exports.locales = exports.TimePrecision = exports.toJSONSchema = exports.flattenError = exports.formatError = exports.prettifyError = exports.treeifyError = exports.regexes = exports.clone = exports.$brand = exports.$input = exports.$output = exports.function = exports.config = exports.registry = exports.globalRegistry = exports.core = void 0;
32
+ exports.coerce = exports.iso = exports.ZodISODuration = exports.ZodISOTime = exports.ZodISODate = exports.ZodISODateTime = exports.locales = exports.NEVER = exports.TimePrecision = exports.toJSONSchema = exports.flattenError = exports.formatError = exports.prettifyError = exports.treeifyError = exports.regexes = exports.clone = exports.$brand = exports.$input = exports.$output = exports.function = exports.config = exports.registry = exports.globalRegistry = exports.core = void 0;
33
33
  exports.core = __importStar(require("../core/index.cjs"));
34
34
  __exportStar(require("./schemas.cjs"), exports);
35
35
  __exportStar(require("./checks.cjs"), exports);
@@ -56,6 +56,7 @@ Object.defineProperty(exports, "formatError", { enumerable: true, get: function
56
56
  Object.defineProperty(exports, "flattenError", { enumerable: true, get: function () { return index_js_2.flattenError; } });
57
57
  Object.defineProperty(exports, "toJSONSchema", { enumerable: true, get: function () { return index_js_2.toJSONSchema; } });
58
58
  Object.defineProperty(exports, "TimePrecision", { enumerable: true, get: function () { return index_js_2.TimePrecision; } });
59
+ Object.defineProperty(exports, "NEVER", { enumerable: true, get: function () { return index_js_2.NEVER; } });
59
60
  exports.locales = __importStar(require("../locales/index.cjs"));
60
61
  // iso
61
62
  // must be exported from top-level
@@ -5,7 +5,7 @@ export * from "./errors.cjs";
5
5
  export * from "./parse.cjs";
6
6
  export * from "./compat.cjs";
7
7
  export type { infer, output, input } from "../core/index.cjs";
8
- export { globalRegistry, type GlobalMeta, registry, config, function, $output, $input, $brand, clone, regexes, treeifyError, prettifyError, formatError, flattenError, toJSONSchema, TimePrecision, } from "../core/index.cjs";
8
+ export { globalRegistry, type GlobalMeta, registry, config, function, $output, $input, $brand, clone, regexes, treeifyError, prettifyError, formatError, flattenError, toJSONSchema, TimePrecision, NEVER, } from "../core/index.cjs";
9
9
  export * as locales from "../locales/index.cjs";
10
10
  export { ZodISODateTime, ZodISODate, ZodISOTime, ZodISODuration } from "./iso.cjs";
11
11
  export * as iso from "./iso.cjs";
@@ -5,7 +5,7 @@ export * from "./errors.js";
5
5
  export * from "./parse.js";
6
6
  export * from "./compat.js";
7
7
  export type { infer, output, input } from "../core/index.js";
8
- export { globalRegistry, type GlobalMeta, registry, config, function, $output, $input, $brand, clone, regexes, treeifyError, prettifyError, formatError, flattenError, toJSONSchema, TimePrecision, } from "../core/index.js";
8
+ export { globalRegistry, type GlobalMeta, registry, config, function, $output, $input, $brand, clone, regexes, treeifyError, prettifyError, formatError, flattenError, toJSONSchema, TimePrecision, NEVER, } from "../core/index.js";
9
9
  export * as locales from "../locales/index.js";
10
10
  export { ZodISODateTime, ZodISODate, ZodISOTime, ZodISODuration } from "./iso.js";
11
11
  export * as iso from "./iso.js";
@@ -8,7 +8,7 @@ export * from "./compat.js";
8
8
  import { config } from "../core/index.js";
9
9
  import en from "../locales/en.js";
10
10
  config(en());
11
- export { globalRegistry, registry, config, function, $output, $input, $brand, clone, regexes, treeifyError, prettifyError, formatError, flattenError, toJSONSchema, TimePrecision, } from "../core/index.js";
11
+ export { globalRegistry, registry, config, function, $output, $input, $brand, clone, regexes, treeifyError, prettifyError, formatError, flattenError, toJSONSchema, TimePrecision, NEVER, } from "../core/index.js";
12
12
  export * as locales from "../locales/index.js";
13
13
  // iso
14
14
  // must be exported from top-level
@@ -428,18 +428,18 @@ out Shape extends core.$ZodShape = core.$ZodLooseShape, out Config extends core.
428
428
  * ```
429
429
  */
430
430
  merge<U extends ZodObject>(other: U): ZodObject<util.Extend<Shape, U["shape"]>, U["_zod"]["config"]>;
431
- pick<M extends util.Exactly<util.Mask<keyof Shape>, M>>(mask: M): ZodObject<util.Flatten<Pick<Shape, Extract<keyof Shape, keyof M>>>, Config>;
432
- omit<M extends util.Exactly<util.Mask<keyof Shape>, M>>(mask: M): ZodObject<util.Flatten<Omit<Shape, Extract<keyof Shape, keyof M>>>, Config>;
431
+ pick<M extends util.Mask<keyof Shape>>(mask: M): ZodObject<util.Flatten<Pick<Shape, Extract<keyof Shape, keyof M>>>, Config>;
432
+ omit<M extends util.Mask<keyof Shape>>(mask: M): ZodObject<util.Flatten<Omit<Shape, Extract<keyof Shape, keyof M>>>, Config>;
433
433
  partial(): ZodObject<{
434
434
  [k in keyof Shape]: ZodOptional<Shape[k]>;
435
435
  }, Config>;
436
- partial<M extends util.Exactly<util.Mask<keyof Shape>, M>>(mask: M): ZodObject<{
436
+ partial<M extends util.Mask<keyof Shape>>(mask: M): ZodObject<{
437
437
  [k in keyof Shape]: k extends keyof M ? ZodOptional<Shape[k]> : Shape[k];
438
438
  }, Config>;
439
439
  required(): ZodObject<{
440
440
  [k in keyof Shape]: ZodNonOptional<Shape[k]>;
441
441
  }, Config>;
442
- required<M extends util.Exactly<util.Mask<keyof Shape>, M>>(mask: M): ZodObject<{
442
+ required<M extends util.Mask<keyof Shape>>(mask: M): ZodObject<{
443
443
  [k in keyof Shape]: k extends keyof M ? ZodNonOptional<Shape[k]> : Shape[k];
444
444
  }, Config>;
445
445
  }
@@ -428,18 +428,18 @@ out Shape extends core.$ZodShape = core.$ZodLooseShape, out Config extends core.
428
428
  * ```
429
429
  */
430
430
  merge<U extends ZodObject>(other: U): ZodObject<util.Extend<Shape, U["shape"]>, U["_zod"]["config"]>;
431
- pick<M extends util.Exactly<util.Mask<keyof Shape>, M>>(mask: M): ZodObject<util.Flatten<Pick<Shape, Extract<keyof Shape, keyof M>>>, Config>;
432
- omit<M extends util.Exactly<util.Mask<keyof Shape>, M>>(mask: M): ZodObject<util.Flatten<Omit<Shape, Extract<keyof Shape, keyof M>>>, Config>;
431
+ pick<M extends util.Mask<keyof Shape>>(mask: M): ZodObject<util.Flatten<Pick<Shape, Extract<keyof Shape, keyof M>>>, Config>;
432
+ omit<M extends util.Mask<keyof Shape>>(mask: M): ZodObject<util.Flatten<Omit<Shape, Extract<keyof Shape, keyof M>>>, Config>;
433
433
  partial(): ZodObject<{
434
434
  [k in keyof Shape]: ZodOptional<Shape[k]>;
435
435
  }, Config>;
436
- partial<M extends util.Exactly<util.Mask<keyof Shape>, M>>(mask: M): ZodObject<{
436
+ partial<M extends util.Mask<keyof Shape>>(mask: M): ZodObject<{
437
437
  [k in keyof Shape]: k extends keyof M ? ZodOptional<Shape[k]> : Shape[k];
438
438
  }, Config>;
439
439
  required(): ZodObject<{
440
440
  [k in keyof Shape]: ZodNonOptional<Shape[k]>;
441
441
  }, Config>;
442
- required<M extends util.Exactly<util.Mask<keyof Shape>, M>>(mask: M): ZodObject<{
442
+ required<M extends util.Mask<keyof Shape>>(mask: M): ZodObject<{
443
443
  [k in keyof Shape]: k extends keyof M ? ZodNonOptional<Shape[k]> : Shape[k];
444
444
  }, Config>;
445
445
  }
package/v4/core/api.cjs CHANGED
@@ -965,10 +965,10 @@ function _refine(Class, fn, _params) {
965
965
  return schema;
966
966
  }
967
967
  function _stringbool(Classes, _params) {
968
- const { case: _case, error, truthy, falsy } = util.normalizeParams(_params);
969
- let truthyArray = truthy ?? ["true", "1", "yes", "on", "y", "enabled"];
970
- let falsyArray = falsy ?? ["false", "0", "no", "off", "n", "disabled"];
971
- if (_case !== "sensitive") {
968
+ const params = util.normalizeParams(_params);
969
+ let truthyArray = params.truthy ?? ["true", "1", "yes", "on", "y", "enabled"];
970
+ let falsyArray = params.falsy ?? ["false", "0", "no", "off", "n", "disabled"];
971
+ if (params.case !== "sensitive") {
972
972
  truthyArray = truthyArray.map((v) => (typeof v === "string" ? v.toLowerCase() : v));
973
973
  falsyArray = falsyArray.map((v) => (typeof v === "string" ? v.toLowerCase() : v));
974
974
  }
@@ -982,7 +982,7 @@ function _stringbool(Classes, _params) {
982
982
  type: "transform",
983
983
  transform: (input, payload) => {
984
984
  let data = input;
985
- if (_case !== "sensitive")
985
+ if (params.case !== "sensitive")
986
986
  data = data.toLowerCase();
987
987
  if (truthySet.has(data)) {
988
988
  return true;
@@ -1001,22 +1001,23 @@ function _stringbool(Classes, _params) {
1001
1001
  return {};
1002
1002
  }
1003
1003
  },
1004
- error,
1004
+ error: params.error,
1005
1005
  });
1006
+ // params.error;
1006
1007
  const innerPipe = new _Pipe({
1007
1008
  type: "pipe",
1008
- in: new _String({ type: "string", error }),
1009
+ in: new _String({ type: "string", error: params.error }),
1009
1010
  out: tx,
1010
- error,
1011
+ error: params.error,
1011
1012
  });
1012
1013
  const outerPipe = new _Pipe({
1013
1014
  type: "pipe",
1014
1015
  in: innerPipe,
1015
1016
  out: new _Boolean({
1016
1017
  type: "boolean",
1017
- error,
1018
+ error: params.error,
1018
1019
  }),
1019
- error,
1020
+ error: params.error,
1020
1021
  });
1021
1022
  return outerPipe;
1022
1023
  }
package/v4/core/api.js CHANGED
@@ -832,10 +832,10 @@ export function _refine(Class, fn, _params) {
832
832
  return schema;
833
833
  }
834
834
  export function _stringbool(Classes, _params) {
835
- const { case: _case, error, truthy, falsy } = util.normalizeParams(_params);
836
- let truthyArray = truthy ?? ["true", "1", "yes", "on", "y", "enabled"];
837
- let falsyArray = falsy ?? ["false", "0", "no", "off", "n", "disabled"];
838
- if (_case !== "sensitive") {
835
+ const params = util.normalizeParams(_params);
836
+ let truthyArray = params.truthy ?? ["true", "1", "yes", "on", "y", "enabled"];
837
+ let falsyArray = params.falsy ?? ["false", "0", "no", "off", "n", "disabled"];
838
+ if (params.case !== "sensitive") {
839
839
  truthyArray = truthyArray.map((v) => (typeof v === "string" ? v.toLowerCase() : v));
840
840
  falsyArray = falsyArray.map((v) => (typeof v === "string" ? v.toLowerCase() : v));
841
841
  }
@@ -849,7 +849,7 @@ export function _stringbool(Classes, _params) {
849
849
  type: "transform",
850
850
  transform: (input, payload) => {
851
851
  let data = input;
852
- if (_case !== "sensitive")
852
+ if (params.case !== "sensitive")
853
853
  data = data.toLowerCase();
854
854
  if (truthySet.has(data)) {
855
855
  return true;
@@ -868,22 +868,23 @@ export function _stringbool(Classes, _params) {
868
868
  return {};
869
869
  }
870
870
  },
871
- error,
871
+ error: params.error,
872
872
  });
873
+ // params.error;
873
874
  const innerPipe = new _Pipe({
874
875
  type: "pipe",
875
- in: new _String({ type: "string", error }),
876
+ in: new _String({ type: "string", error: params.error }),
876
877
  out: tx,
877
- error,
878
+ error: params.error,
878
879
  });
879
880
  const outerPipe = new _Pipe({
880
881
  type: "pipe",
881
882
  in: innerPipe,
882
883
  out: new _Boolean({
883
884
  type: "boolean",
884
- error,
885
+ error: params.error,
885
886
  }),
886
- error,
887
+ error: params.error,
887
888
  });
888
889
  return outerPipe;
889
890
  }
@@ -85,7 +85,7 @@ exports.$ZodCheckGreaterThan = core.$constructor("$ZodCheckGreaterThan", (inst,
85
85
  return;
86
86
  }
87
87
  payload.issues.push({
88
- origin: origin,
88
+ origin,
89
89
  code: "too_small",
90
90
  minimum: def.value,
91
91
  input: payload.value,
@@ -320,6 +320,8 @@ exports.$ZodCheckSizeEquals = core.$constructor("$ZodCheckSizeEquals", (inst, de
320
320
  payload.issues.push({
321
321
  origin: util.getSizableOrigin(input),
322
322
  ...(tooBig ? { code: "too_big", maximum: def.size } : { code: "too_small", minimum: def.size }),
323
+ inclusive: true,
324
+ exact: true,
323
325
  input: payload.value,
324
326
  inst,
325
327
  continue: !def.abort,
@@ -403,9 +405,9 @@ exports.$ZodCheckLengthEquals = core.$constructor("$ZodCheckLengthEquals", (inst
403
405
  const tooBig = length > def.length;
404
406
  payload.issues.push({
405
407
  origin,
406
- ...(tooBig
407
- ? { code: "too_big", maximum: def.length, exact: true }
408
- : { code: "too_small", minimum: def.length, exact: true }),
408
+ ...(tooBig ? { code: "too_big", maximum: def.length } : { code: "too_small", minimum: def.length }),
409
+ inclusive: true,
410
+ exact: true,
409
411
  input: payload.value,
410
412
  inst,
411
413
  continue: !def.abort,
package/v4/core/checks.js CHANGED
@@ -59,7 +59,7 @@ export const $ZodCheckGreaterThan = /*@__PURE__*/ core.$constructor("$ZodCheckGr
59
59
  return;
60
60
  }
61
61
  payload.issues.push({
62
- origin: origin,
62
+ origin,
63
63
  code: "too_small",
64
64
  minimum: def.value,
65
65
  input: payload.value,
@@ -294,6 +294,8 @@ export const $ZodCheckSizeEquals = /*@__PURE__*/ core.$constructor("$ZodCheckSiz
294
294
  payload.issues.push({
295
295
  origin: util.getSizableOrigin(input),
296
296
  ...(tooBig ? { code: "too_big", maximum: def.size } : { code: "too_small", minimum: def.size }),
297
+ inclusive: true,
298
+ exact: true,
297
299
  input: payload.value,
298
300
  inst,
299
301
  continue: !def.abort,
@@ -377,9 +379,9 @@ export const $ZodCheckLengthEquals = /*@__PURE__*/ core.$constructor("$ZodCheckL
377
379
  const tooBig = length > def.length;
378
380
  payload.issues.push({
379
381
  origin,
380
- ...(tooBig
381
- ? { code: "too_big", maximum: def.length, exact: true }
382
- : { code: "too_small", minimum: def.length, exact: true }),
382
+ ...(tooBig ? { code: "too_big", maximum: def.length } : { code: "too_small", minimum: def.length }),
383
+ inclusive: true,
384
+ exact: true,
383
385
  input: payload.value,
384
386
  inst,
385
387
  continue: !def.abort,
package/v4/core/core.cjs CHANGED
@@ -1,8 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.globalConfig = exports.$ZodAsyncError = exports.$brand = void 0;
3
+ exports.globalConfig = exports.$ZodAsyncError = exports.$brand = exports.NEVER = void 0;
4
4
  exports.$constructor = $constructor;
5
5
  exports.config = config;
6
+ /** A special constant with type `never` */
7
+ exports.NEVER = Object.freeze({
8
+ status: "aborted",
9
+ });
6
10
  function $constructor(name, initializer, params) {
7
11
  function init(inst, def) {
8
12
  var _a;
@@ -11,6 +11,8 @@ export interface $constructor<T extends ZodTrait, D = T["_zod"]["def"]> {
11
11
  new (def: D): T;
12
12
  init(inst: T, def: D): asserts inst is T;
13
13
  }
14
+ /** A special constant with type `never` */
15
+ export declare const NEVER: never;
14
16
  export declare function $constructor<T extends ZodTrait, D = T["_zod"]["def"]>(name: string, initializer: (inst: T, def: D) => void, params?: {
15
17
  Parent?: typeof Class;
16
18
  }): $constructor<T, D>;
package/v4/core/core.d.ts CHANGED
@@ -11,6 +11,8 @@ export interface $constructor<T extends ZodTrait, D = T["_zod"]["def"]> {
11
11
  new (def: D): T;
12
12
  init(inst: T, def: D): asserts inst is T;
13
13
  }
14
+ /** A special constant with type `never` */
15
+ export declare const NEVER: never;
14
16
  export declare function $constructor<T extends ZodTrait, D = T["_zod"]["def"]>(name: string, initializer: (inst: T, def: D) => void, params?: {
15
17
  Parent?: typeof Class;
16
18
  }): $constructor<T, D>;