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 +1 -1
- package/src/v4/classic/tests/discriminated-unions.test.ts +1 -0
- package/src/v4/classic/tests/file.test.ts +5 -2
- package/src/v4/core/errors.ts +1 -0
- package/src/v4/core/schemas.ts +3 -2
- package/src/v4/core/versions.ts +1 -1
- package/v4/core/errors.d.cts +1 -0
- package/v4/core/errors.d.ts +1 -0
- package/v4/core/schemas.cjs +1 -0
- package/v4/core/schemas.d.cts +2 -2
- package/v4/core/schemas.d.ts +2 -2
- package/v4/core/schemas.js +1 -0
- package/v4/core/versions.cjs +1 -1
- package/v4/core/versions.js +1 -1
package/package.json
CHANGED
|
@@ -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
|
{
|
package/src/v4/core/errors.ts
CHANGED
|
@@ -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 {
|
package/src/v4/core/schemas.ts
CHANGED
|
@@ -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 {
|
package/src/v4/core/versions.ts
CHANGED
package/v4/core/errors.d.cts
CHANGED
|
@@ -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";
|
package/v4/core/errors.d.ts
CHANGED
|
@@ -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";
|
package/v4/core/schemas.cjs
CHANGED
package/v4/core/schemas.d.cts
CHANGED
|
@@ -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";
|
package/v4/core/schemas.d.ts
CHANGED
|
@@ -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";
|
package/v4/core/schemas.js
CHANGED
package/v4/core/versions.cjs
CHANGED
package/v4/core/versions.js
CHANGED