zod 4.2.0-canary.20251124T022609 → 4.2.0-canary.20251202T062120

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zod",
3
- "version": "4.2.0-canary.20251124T022609",
3
+ "version": "4.2.0-canary.20251202T062120",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Colin McDonnell <zod@colinhacks.com>",
@@ -1,4 +1,4 @@
1
- import { test } from "vitest";
1
+ import { expect, test } from "vitest";
2
2
  import * as z from "zod/v3";
3
3
 
4
4
  const crazySchema = z.object({
@@ -40,7 +40,7 @@ const crazySchema = z.object({
40
40
  // });
41
41
 
42
42
  test("parse", () => {
43
- crazySchema.parse({
43
+ const input = {
44
44
  tuple: ["asdf", 1234, true, null, undefined, "1234"],
45
45
  merged: { k1: "asdf", k2: 12 },
46
46
  union: ["asdf", 12, "asdf", 12, "asdf", 12],
@@ -52,5 +52,19 @@ test("parse", () => {
52
52
  nonstrict: { points: 1234 },
53
53
  numProm: Promise.resolve(12),
54
54
  lenfun: (x: string) => x.length,
55
- });
55
+ };
56
+
57
+ const result = crazySchema.parse(input);
58
+
59
+ // Verify the parsed result structure
60
+ expect(result.tuple).toEqual(input.tuple);
61
+ expect(result.merged).toEqual(input.merged);
62
+ expect(result.union).toEqual(input.union);
63
+ expect(result.array).toEqual(input.array);
64
+ expect(result.sumMinLength).toEqual(input.sumMinLength);
65
+ expect(result.intersection).toEqual(input.intersection);
66
+ expect(result.enum).toEqual(input.enum);
67
+ expect(result.nonstrict).toEqual(input.nonstrict);
68
+ expect(result.numProm).toBeInstanceOf(Promise);
69
+ expect(typeof result.lenfun).toBe("function");
56
70
  });
@@ -10,7 +10,8 @@ const func1 = z.function(args1, returns1);
10
10
 
11
11
  test("function parsing", () => {
12
12
  const parsed = func1.parse((arg: any) => arg.length);
13
- parsed("asdf");
13
+ const result = parsed("asdf");
14
+ expect(result).toBe(4);
14
15
  });
15
16
 
16
17
  test("parsed function fail 1", () => {
@@ -226,8 +227,11 @@ test("allow extra parameters", () => {
226
227
  test("params and returnType getters", () => {
227
228
  const func = z.function().args(z.string()).returns(z.string());
228
229
 
229
- func.parameters().items[0].parse("asdf");
230
- func.returnType().parse("asdf");
230
+ const paramResult = func.parameters().items[0].parse("asdf");
231
+ expect(paramResult).toBe("asdf");
232
+
233
+ const returnResult = func.returnType().parse("asdf");
234
+ expect(returnResult).toBe("asdf");
231
235
  });
232
236
 
233
237
  test("inference with transforms", () => {
@@ -6,8 +6,11 @@ import * as z from "zod/v3";
6
6
  const schema = z.nan();
7
7
 
8
8
  test("passing validations", () => {
9
- schema.parse(Number.NaN);
10
- schema.parse(Number("Not a number"));
9
+ const result1 = schema.parse(Number.NaN);
10
+ expect(Number.isNaN(result1)).toBe(true);
11
+
12
+ const result2 = schema.parse(Number("Not a number"));
13
+ expect(Number.isNaN(result2)).toBe(true);
11
14
  });
12
15
 
13
16
  test("failing validations", () => {
@@ -199,7 +199,7 @@ export function assertNotEqual<A, B>(val: AssertNotEqual<A, B>): AssertNotEqual<
199
199
  export function assertIs<T>(_arg: T): void {}
200
200
 
201
201
  export function assertNever(_x: never): never {
202
- throw new Error();
202
+ throw new Error("Unexpected value in exhaustive check");
203
203
  }
204
204
  export function assert<T>(_: any): asserts _ is T {}
205
205
 
@@ -1,5 +1,5 @@
1
1
  export const version = {
2
2
  major: 4,
3
3
  minor: 1,
4
- patch: 12 as number,
4
+ patch: 13 as number,
5
5
  } as const;
package/v4/core/util.cjs CHANGED
@@ -63,7 +63,7 @@ function assertNotEqual(val) {
63
63
  }
64
64
  function assertIs(_arg) { }
65
65
  function assertNever(_x) {
66
- throw new Error();
66
+ throw new Error("Unexpected value in exhaustive check");
67
67
  }
68
68
  function assert(_) { }
69
69
  function getEnumValues(entries) {
package/v4/core/util.js CHANGED
@@ -7,7 +7,7 @@ export function assertNotEqual(val) {
7
7
  }
8
8
  export function assertIs(_arg) { }
9
9
  export function assertNever(_x) {
10
- throw new Error();
10
+ throw new Error("Unexpected value in exhaustive check");
11
11
  }
12
12
  export function assert(_) { }
13
13
  export function getEnumValues(entries) {
@@ -4,5 +4,5 @@ exports.version = void 0;
4
4
  exports.version = {
5
5
  major: 4,
6
6
  minor: 1,
7
- patch: 12,
7
+ patch: 13,
8
8
  };
@@ -1,5 +1,5 @@
1
1
  export const version = {
2
2
  major: 4,
3
3
  minor: 1,
4
- patch: 12,
4
+ patch: 13,
5
5
  };