zod 4.0.9 → 4.0.10

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.0.9",
3
+ "version": "4.0.10",
4
4
  "type": "module",
5
5
  "author": "Colin McDonnell <zod@colinhacks.com>",
6
6
  "description": "TypeScript-first schema declaration and validation library with static type inference",
@@ -157,6 +157,7 @@ test("invalid discriminator value", () => {
157
157
  "code": "invalid_union",
158
158
  "errors": [],
159
159
  "note": "No matching discriminator",
160
+ "discriminator": "type",
160
161
  "path": [
161
162
  "type"
162
163
  ],
@@ -1,7 +1,6 @@
1
- // @ts-ignore
2
1
  import { File as WebFile } from "@web-std/file";
3
2
 
4
- import { afterEach, beforeEach, expect, test } from "vitest";
3
+ import { afterEach, beforeEach, expect, expectTypeOf, test } from "vitest";
5
4
 
6
5
  import * as z from "zod/v4";
7
6
 
@@ -27,6 +26,10 @@ test("passing validations", () => {
27
26
  expect(() => mimeCheck.parse(new File([""], "test.txt", { type: "text/csv" }))).toThrow();
28
27
  });
29
28
 
29
+ test("types", () => {
30
+ expectTypeOf(z.file().parse(new File([], "test.txt"))).toEqualTypeOf(new File([], "test.txt"));
31
+ });
32
+
30
33
  test("failing validations", () => {
31
34
  expect(minCheck.safeParse(new File(["1234"], "test.txt"))).toMatchInlineSnapshot(`
32
35
  {
@@ -67,6 +67,7 @@ export interface $ZodIssueInvalidUnion extends $ZodIssueBase {
67
67
  readonly code: "invalid_union";
68
68
  readonly errors: $ZodIssue[][];
69
69
  readonly input: unknown;
70
+ readonly discriminator?: string | undefined;
70
71
  }
71
72
 
72
73
  export interface $ZodIssueInvalidKey<Input = unknown> extends $ZodIssueBase {
@@ -2069,6 +2069,7 @@ export const $ZodDiscriminatedUnion: core.$constructor<$ZodDiscriminatedUnion> =
2069
2069
  code: "invalid_union",
2070
2070
  errors: [],
2071
2071
  note: "No matching discriminator",
2072
+ discriminator: def.discriminator,
2072
2073
  input,
2073
2074
  path: [def.discriminator],
2074
2075
  inst,
@@ -2862,8 +2863,8 @@ export const $ZodLiteral: core.$constructor<$ZodLiteral> = /*@__PURE__*/ core.$c
2862
2863
  type _File = typeof globalThis extends { File: infer F extends new (...args: any[]) => any } ? InstanceType<F> : {};
2863
2864
  /** Do not reference this directly. */
2864
2865
  export interface File extends _File {
2865
- type: string;
2866
- size: number;
2866
+ readonly type: string;
2867
+ readonly size: number;
2867
2868
  }
2868
2869
 
2869
2870
  export interface $ZodFileDef extends $ZodTypeDef {
@@ -1,5 +1,5 @@
1
1
  export const version = {
2
2
  major: 4,
3
3
  minor: 0,
4
- patch: 9 as number,
4
+ patch: 10 as number,
5
5
  } as const;
@@ -52,6 +52,7 @@ export interface $ZodIssueInvalidUnion extends $ZodIssueBase {
52
52
  readonly code: "invalid_union";
53
53
  readonly errors: $ZodIssue[][];
54
54
  readonly input: unknown;
55
+ readonly discriminator?: string | undefined;
55
56
  }
56
57
  export interface $ZodIssueInvalidKey<Input = unknown> extends $ZodIssueBase {
57
58
  readonly code: "invalid_key";
@@ -52,6 +52,7 @@ export interface $ZodIssueInvalidUnion extends $ZodIssueBase {
52
52
  readonly code: "invalid_union";
53
53
  readonly errors: $ZodIssue[][];
54
54
  readonly input: unknown;
55
+ readonly discriminator?: string | undefined;
55
56
  }
56
57
  export interface $ZodIssueInvalidKey<Input = unknown> extends $ZodIssueBase {
57
58
  readonly code: "invalid_key";
@@ -977,6 +977,7 @@ core.$constructor("$ZodDiscriminatedUnion", (inst, def) => {
977
977
  code: "invalid_union",
978
978
  errors: [],
979
979
  note: "No matching discriminator",
980
+ discriminator: def.discriminator,
980
981
  input,
981
982
  path: [def.discriminator],
982
983
  inst,
@@ -768,8 +768,8 @@ type _File = typeof globalThis extends {
768
768
  } ? InstanceType<F> : {};
769
769
  /** Do not reference this directly. */
770
770
  export interface File extends _File {
771
- type: string;
772
- size: number;
771
+ readonly type: string;
772
+ readonly size: number;
773
773
  }
774
774
  export interface $ZodFileDef extends $ZodTypeDef {
775
775
  type: "file";
@@ -768,8 +768,8 @@ type _File = typeof globalThis extends {
768
768
  } ? InstanceType<F> : {};
769
769
  /** Do not reference this directly. */
770
770
  export interface File extends _File {
771
- type: string;
772
- size: number;
771
+ readonly type: string;
772
+ readonly size: number;
773
773
  }
774
774
  export interface $ZodFileDef extends $ZodTypeDef {
775
775
  type: "file";
@@ -946,6 +946,7 @@ core.$constructor("$ZodDiscriminatedUnion", (inst, def) => {
946
946
  code: "invalid_union",
947
947
  errors: [],
948
948
  note: "No matching discriminator",
949
+ discriminator: def.discriminator,
949
950
  input,
950
951
  path: [def.discriminator],
951
952
  inst,
@@ -4,5 +4,5 @@ exports.version = void 0;
4
4
  exports.version = {
5
5
  major: 4,
6
6
  minor: 0,
7
- patch: 9,
7
+ patch: 10,
8
8
  };
@@ -1,5 +1,5 @@
1
1
  export const version = {
2
2
  major: 4,
3
3
  minor: 0,
4
- patch: 9,
4
+ patch: 10,
5
5
  };