zod 4.1.0-canary.20250711T052917 → 4.1.0-canary.20250711T200924
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.1.0-canary.
|
|
3
|
+
"version": "4.1.0-canary.20250711T200924",
|
|
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",
|
|
@@ -1224,6 +1224,7 @@ export interface ZodDiscriminatedUnion<Options extends readonly core.SomeType[]
|
|
|
1224
1224
|
extends ZodUnion<Options>,
|
|
1225
1225
|
core.$ZodDiscriminatedUnion<Options> {
|
|
1226
1226
|
_zod: core.$ZodDiscriminatedUnionInternals<Options>;
|
|
1227
|
+
def: core.$ZodDiscriminatedUnionDef<Options>;
|
|
1227
1228
|
}
|
|
1228
1229
|
export const ZodDiscriminatedUnion: core.$constructor<ZodDiscriminatedUnion> = /*@__PURE__*/ core.$constructor(
|
|
1229
1230
|
"ZodDiscriminatedUnion",
|
|
@@ -646,3 +646,15 @@ test("pipes", () => {
|
|
|
646
646
|
v: 2,
|
|
647
647
|
});
|
|
648
648
|
});
|
|
649
|
+
|
|
650
|
+
test("def", () => {
|
|
651
|
+
const schema = z.discriminatedUnion(
|
|
652
|
+
"type",
|
|
653
|
+
[z.object({ type: z.literal("play") }), z.object({ type: z.literal("pause") })],
|
|
654
|
+
{ unionFallback: true }
|
|
655
|
+
);
|
|
656
|
+
|
|
657
|
+
expect(schema.def).toBeDefined();
|
|
658
|
+
expect(schema.def.discriminator).toEqual("type");
|
|
659
|
+
expect(schema.def.unionFallback).toEqual(true);
|
|
660
|
+
});
|
package/v4/classic/schemas.d.cts
CHANGED
|
@@ -446,6 +446,7 @@ export declare const ZodUnion: core.$constructor<ZodUnion>;
|
|
|
446
446
|
export declare function union<const T extends readonly core.SomeType[]>(options: T, params?: string | core.$ZodUnionParams): ZodUnion<T>;
|
|
447
447
|
export interface ZodDiscriminatedUnion<Options extends readonly core.SomeType[] = readonly core.$ZodType[]> extends ZodUnion<Options>, core.$ZodDiscriminatedUnion<Options> {
|
|
448
448
|
_zod: core.$ZodDiscriminatedUnionInternals<Options>;
|
|
449
|
+
def: core.$ZodDiscriminatedUnionDef<Options>;
|
|
449
450
|
}
|
|
450
451
|
export declare const ZodDiscriminatedUnion: core.$constructor<ZodDiscriminatedUnion>;
|
|
451
452
|
export declare function discriminatedUnion<Types extends readonly [core.$ZodTypeDiscriminable, ...core.$ZodTypeDiscriminable[]]>(discriminator: string, options: Types, params?: string | core.$ZodDiscriminatedUnionParams): ZodDiscriminatedUnion<Types>;
|
package/v4/classic/schemas.d.ts
CHANGED
|
@@ -446,6 +446,7 @@ export declare const ZodUnion: core.$constructor<ZodUnion>;
|
|
|
446
446
|
export declare function union<const T extends readonly core.SomeType[]>(options: T, params?: string | core.$ZodUnionParams): ZodUnion<T>;
|
|
447
447
|
export interface ZodDiscriminatedUnion<Options extends readonly core.SomeType[] = readonly core.$ZodType[]> extends ZodUnion<Options>, core.$ZodDiscriminatedUnion<Options> {
|
|
448
448
|
_zod: core.$ZodDiscriminatedUnionInternals<Options>;
|
|
449
|
+
def: core.$ZodDiscriminatedUnionDef<Options>;
|
|
449
450
|
}
|
|
450
451
|
export declare const ZodDiscriminatedUnion: core.$constructor<ZodDiscriminatedUnion>;
|
|
451
452
|
export declare function discriminatedUnion<Types extends readonly [core.$ZodTypeDiscriminable, ...core.$ZodTypeDiscriminable[]]>(discriminator: string, options: Types, params?: string | core.$ZodDiscriminatedUnionParams): ZodDiscriminatedUnion<Types>;
|