zod 4.0.4 → 4.0.5
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/compat.ts +2 -39
- package/src/v4/classic/tests/discriminated-unions.test.ts +29 -0
- package/src/v4/core/schemas.ts +3 -1
- package/src/v4/core/versions.ts +1 -1
- package/v4/classic/compat.cjs +1 -37
- package/v4/classic/compat.d.cts +1 -37
- package/v4/classic/compat.d.ts +1 -37
- package/v4/classic/compat.js +1 -37
- package/v4/core/schemas.cjs +2 -1
- package/v4/core/schemas.d.cts +1 -0
- package/v4/core/schemas.d.ts +1 -0
- package/v4/core/schemas.js +2 -1
- package/v4/core/versions.cjs +1 -1
- package/v4/core/versions.js +1 -1
package/package.json
CHANGED
package/src/v4/classic/compat.ts
CHANGED
|
@@ -66,42 +66,5 @@ export type {
|
|
|
66
66
|
/** Included for Zod 3 compatibility */
|
|
67
67
|
export type ZodRawShape = core.$ZodShape;
|
|
68
68
|
|
|
69
|
-
/** @deprecated Do not use.
|
|
70
|
-
export enum ZodFirstPartyTypeKind {
|
|
71
|
-
ZodString = "ZodString",
|
|
72
|
-
ZodNumber = "ZodNumber",
|
|
73
|
-
ZodNaN = "ZodNaN",
|
|
74
|
-
ZodBigInt = "ZodBigInt",
|
|
75
|
-
ZodBoolean = "ZodBoolean",
|
|
76
|
-
ZodDate = "ZodDate",
|
|
77
|
-
ZodSymbol = "ZodSymbol",
|
|
78
|
-
ZodUndefined = "ZodUndefined",
|
|
79
|
-
ZodNull = "ZodNull",
|
|
80
|
-
ZodAny = "ZodAny",
|
|
81
|
-
ZodUnknown = "ZodUnknown",
|
|
82
|
-
ZodNever = "ZodNever",
|
|
83
|
-
ZodVoid = "ZodVoid",
|
|
84
|
-
ZodArray = "ZodArray",
|
|
85
|
-
ZodObject = "ZodObject",
|
|
86
|
-
ZodUnion = "ZodUnion",
|
|
87
|
-
ZodDiscriminatedUnion = "ZodDiscriminatedUnion",
|
|
88
|
-
ZodIntersection = "ZodIntersection",
|
|
89
|
-
ZodTuple = "ZodTuple",
|
|
90
|
-
ZodRecord = "ZodRecord",
|
|
91
|
-
ZodMap = "ZodMap",
|
|
92
|
-
ZodSet = "ZodSet",
|
|
93
|
-
ZodFunction = "ZodFunction",
|
|
94
|
-
ZodLazy = "ZodLazy",
|
|
95
|
-
ZodLiteral = "ZodLiteral",
|
|
96
|
-
ZodEnum = "ZodEnum",
|
|
97
|
-
ZodEffects = "ZodEffects",
|
|
98
|
-
ZodNativeEnum = "ZodNativeEnum",
|
|
99
|
-
ZodOptional = "ZodOptional",
|
|
100
|
-
ZodNullable = "ZodNullable",
|
|
101
|
-
ZodDefault = "ZodDefault",
|
|
102
|
-
ZodCatch = "ZodCatch",
|
|
103
|
-
ZodPromise = "ZodPromise",
|
|
104
|
-
ZodBranded = "ZodBranded",
|
|
105
|
-
ZodPipeline = "ZodPipeline",
|
|
106
|
-
ZodReadonly = "ZodReadonly",
|
|
107
|
-
}
|
|
69
|
+
/** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
|
|
70
|
+
export enum ZodFirstPartyTypeKind {}
|
|
@@ -617,3 +617,32 @@ test("readonly literal discriminator", () => {
|
|
|
617
617
|
discUnion.parse({ type: "c", a: "hello" });
|
|
618
618
|
}).toThrow();
|
|
619
619
|
});
|
|
620
|
+
|
|
621
|
+
test("pipes", () => {
|
|
622
|
+
const schema = z
|
|
623
|
+
.object({
|
|
624
|
+
type: z.literal("foo"),
|
|
625
|
+
})
|
|
626
|
+
.transform((s) => ({ ...s, v: 2 }));
|
|
627
|
+
|
|
628
|
+
expect(schema._zod.propValues).toMatchInlineSnapshot(`
|
|
629
|
+
{
|
|
630
|
+
"type": Set {
|
|
631
|
+
"foo",
|
|
632
|
+
},
|
|
633
|
+
}
|
|
634
|
+
`);
|
|
635
|
+
|
|
636
|
+
const schema2 = z.object({
|
|
637
|
+
type: z.literal("bar"),
|
|
638
|
+
});
|
|
639
|
+
|
|
640
|
+
const combinedSchema = z.discriminatedUnion("type", [schema, schema2], {
|
|
641
|
+
unionFallback: false,
|
|
642
|
+
});
|
|
643
|
+
|
|
644
|
+
combinedSchema.parse({
|
|
645
|
+
type: "foo",
|
|
646
|
+
v: 2,
|
|
647
|
+
});
|
|
648
|
+
});
|
package/src/v4/core/schemas.ts
CHANGED
|
@@ -2039,7 +2039,7 @@ export const $ZodDiscriminatedUnion: core.$constructor<$ZodDiscriminatedUnion> =
|
|
|
2039
2039
|
const opts = def.options as $ZodTypeDiscriminable[];
|
|
2040
2040
|
const map: Map<util.Primitive, $ZodType> = new Map();
|
|
2041
2041
|
for (const o of opts) {
|
|
2042
|
-
const values = o._zod.propValues[def.discriminator];
|
|
2042
|
+
const values = o._zod.propValues?.[def.discriminator];
|
|
2043
2043
|
if (!values || values.size === 0)
|
|
2044
2044
|
throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
|
|
2045
2045
|
for (const v of values) {
|
|
@@ -3429,6 +3429,7 @@ export interface $ZodPipeInternals<A extends SomeType = $ZodType, B extends Some
|
|
|
3429
3429
|
values: A["_zod"]["values"];
|
|
3430
3430
|
optin: A["_zod"]["optin"];
|
|
3431
3431
|
optout: B["_zod"]["optout"];
|
|
3432
|
+
propValues: A["_zod"]["propValues"];
|
|
3432
3433
|
}
|
|
3433
3434
|
|
|
3434
3435
|
export interface $ZodPipe<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodType {
|
|
@@ -3440,6 +3441,7 @@ export const $ZodPipe: core.$constructor<$ZodPipe> = /*@__PURE__*/ core.$constru
|
|
|
3440
3441
|
util.defineLazy(inst._zod, "values", () => def.in._zod.values);
|
|
3441
3442
|
util.defineLazy(inst._zod, "optin", () => def.in._zod.optin);
|
|
3442
3443
|
util.defineLazy(inst._zod, "optout", () => def.out._zod.optout);
|
|
3444
|
+
util.defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
|
|
3443
3445
|
|
|
3444
3446
|
inst._zod.parse = (payload, ctx) => {
|
|
3445
3447
|
const left = def.in._zod.run(payload, ctx);
|
package/src/v4/core/versions.ts
CHANGED
package/v4/classic/compat.cjs
CHANGED
|
@@ -55,43 +55,7 @@ function setErrorMap(map) {
|
|
|
55
55
|
function getErrorMap() {
|
|
56
56
|
return core.config().customError;
|
|
57
57
|
}
|
|
58
|
-
/** @deprecated Do not use.
|
|
58
|
+
/** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
|
|
59
59
|
var ZodFirstPartyTypeKind;
|
|
60
60
|
(function (ZodFirstPartyTypeKind) {
|
|
61
|
-
ZodFirstPartyTypeKind["ZodString"] = "ZodString";
|
|
62
|
-
ZodFirstPartyTypeKind["ZodNumber"] = "ZodNumber";
|
|
63
|
-
ZodFirstPartyTypeKind["ZodNaN"] = "ZodNaN";
|
|
64
|
-
ZodFirstPartyTypeKind["ZodBigInt"] = "ZodBigInt";
|
|
65
|
-
ZodFirstPartyTypeKind["ZodBoolean"] = "ZodBoolean";
|
|
66
|
-
ZodFirstPartyTypeKind["ZodDate"] = "ZodDate";
|
|
67
|
-
ZodFirstPartyTypeKind["ZodSymbol"] = "ZodSymbol";
|
|
68
|
-
ZodFirstPartyTypeKind["ZodUndefined"] = "ZodUndefined";
|
|
69
|
-
ZodFirstPartyTypeKind["ZodNull"] = "ZodNull";
|
|
70
|
-
ZodFirstPartyTypeKind["ZodAny"] = "ZodAny";
|
|
71
|
-
ZodFirstPartyTypeKind["ZodUnknown"] = "ZodUnknown";
|
|
72
|
-
ZodFirstPartyTypeKind["ZodNever"] = "ZodNever";
|
|
73
|
-
ZodFirstPartyTypeKind["ZodVoid"] = "ZodVoid";
|
|
74
|
-
ZodFirstPartyTypeKind["ZodArray"] = "ZodArray";
|
|
75
|
-
ZodFirstPartyTypeKind["ZodObject"] = "ZodObject";
|
|
76
|
-
ZodFirstPartyTypeKind["ZodUnion"] = "ZodUnion";
|
|
77
|
-
ZodFirstPartyTypeKind["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
|
|
78
|
-
ZodFirstPartyTypeKind["ZodIntersection"] = "ZodIntersection";
|
|
79
|
-
ZodFirstPartyTypeKind["ZodTuple"] = "ZodTuple";
|
|
80
|
-
ZodFirstPartyTypeKind["ZodRecord"] = "ZodRecord";
|
|
81
|
-
ZodFirstPartyTypeKind["ZodMap"] = "ZodMap";
|
|
82
|
-
ZodFirstPartyTypeKind["ZodSet"] = "ZodSet";
|
|
83
|
-
ZodFirstPartyTypeKind["ZodFunction"] = "ZodFunction";
|
|
84
|
-
ZodFirstPartyTypeKind["ZodLazy"] = "ZodLazy";
|
|
85
|
-
ZodFirstPartyTypeKind["ZodLiteral"] = "ZodLiteral";
|
|
86
|
-
ZodFirstPartyTypeKind["ZodEnum"] = "ZodEnum";
|
|
87
|
-
ZodFirstPartyTypeKind["ZodEffects"] = "ZodEffects";
|
|
88
|
-
ZodFirstPartyTypeKind["ZodNativeEnum"] = "ZodNativeEnum";
|
|
89
|
-
ZodFirstPartyTypeKind["ZodOptional"] = "ZodOptional";
|
|
90
|
-
ZodFirstPartyTypeKind["ZodNullable"] = "ZodNullable";
|
|
91
|
-
ZodFirstPartyTypeKind["ZodDefault"] = "ZodDefault";
|
|
92
|
-
ZodFirstPartyTypeKind["ZodCatch"] = "ZodCatch";
|
|
93
|
-
ZodFirstPartyTypeKind["ZodPromise"] = "ZodPromise";
|
|
94
|
-
ZodFirstPartyTypeKind["ZodBranded"] = "ZodBranded";
|
|
95
|
-
ZodFirstPartyTypeKind["ZodPipeline"] = "ZodPipeline";
|
|
96
|
-
ZodFirstPartyTypeKind["ZodReadonly"] = "ZodReadonly";
|
|
97
61
|
})(ZodFirstPartyTypeKind || (exports.ZodFirstPartyTypeKind = ZodFirstPartyTypeKind = {}));
|
package/v4/classic/compat.d.cts
CHANGED
|
@@ -45,42 +45,6 @@ ZodType as ZodSchema,
|
|
|
45
45
|
ZodType as Schema, };
|
|
46
46
|
/** Included for Zod 3 compatibility */
|
|
47
47
|
export type ZodRawShape = core.$ZodShape;
|
|
48
|
-
/** @deprecated Do not use.
|
|
48
|
+
/** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
|
|
49
49
|
export declare enum ZodFirstPartyTypeKind {
|
|
50
|
-
ZodString = "ZodString",
|
|
51
|
-
ZodNumber = "ZodNumber",
|
|
52
|
-
ZodNaN = "ZodNaN",
|
|
53
|
-
ZodBigInt = "ZodBigInt",
|
|
54
|
-
ZodBoolean = "ZodBoolean",
|
|
55
|
-
ZodDate = "ZodDate",
|
|
56
|
-
ZodSymbol = "ZodSymbol",
|
|
57
|
-
ZodUndefined = "ZodUndefined",
|
|
58
|
-
ZodNull = "ZodNull",
|
|
59
|
-
ZodAny = "ZodAny",
|
|
60
|
-
ZodUnknown = "ZodUnknown",
|
|
61
|
-
ZodNever = "ZodNever",
|
|
62
|
-
ZodVoid = "ZodVoid",
|
|
63
|
-
ZodArray = "ZodArray",
|
|
64
|
-
ZodObject = "ZodObject",
|
|
65
|
-
ZodUnion = "ZodUnion",
|
|
66
|
-
ZodDiscriminatedUnion = "ZodDiscriminatedUnion",
|
|
67
|
-
ZodIntersection = "ZodIntersection",
|
|
68
|
-
ZodTuple = "ZodTuple",
|
|
69
|
-
ZodRecord = "ZodRecord",
|
|
70
|
-
ZodMap = "ZodMap",
|
|
71
|
-
ZodSet = "ZodSet",
|
|
72
|
-
ZodFunction = "ZodFunction",
|
|
73
|
-
ZodLazy = "ZodLazy",
|
|
74
|
-
ZodLiteral = "ZodLiteral",
|
|
75
|
-
ZodEnum = "ZodEnum",
|
|
76
|
-
ZodEffects = "ZodEffects",
|
|
77
|
-
ZodNativeEnum = "ZodNativeEnum",
|
|
78
|
-
ZodOptional = "ZodOptional",
|
|
79
|
-
ZodNullable = "ZodNullable",
|
|
80
|
-
ZodDefault = "ZodDefault",
|
|
81
|
-
ZodCatch = "ZodCatch",
|
|
82
|
-
ZodPromise = "ZodPromise",
|
|
83
|
-
ZodBranded = "ZodBranded",
|
|
84
|
-
ZodPipeline = "ZodPipeline",
|
|
85
|
-
ZodReadonly = "ZodReadonly"
|
|
86
50
|
}
|
package/v4/classic/compat.d.ts
CHANGED
|
@@ -45,42 +45,6 @@ ZodType as ZodSchema,
|
|
|
45
45
|
ZodType as Schema, };
|
|
46
46
|
/** Included for Zod 3 compatibility */
|
|
47
47
|
export type ZodRawShape = core.$ZodShape;
|
|
48
|
-
/** @deprecated Do not use.
|
|
48
|
+
/** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
|
|
49
49
|
export declare enum ZodFirstPartyTypeKind {
|
|
50
|
-
ZodString = "ZodString",
|
|
51
|
-
ZodNumber = "ZodNumber",
|
|
52
|
-
ZodNaN = "ZodNaN",
|
|
53
|
-
ZodBigInt = "ZodBigInt",
|
|
54
|
-
ZodBoolean = "ZodBoolean",
|
|
55
|
-
ZodDate = "ZodDate",
|
|
56
|
-
ZodSymbol = "ZodSymbol",
|
|
57
|
-
ZodUndefined = "ZodUndefined",
|
|
58
|
-
ZodNull = "ZodNull",
|
|
59
|
-
ZodAny = "ZodAny",
|
|
60
|
-
ZodUnknown = "ZodUnknown",
|
|
61
|
-
ZodNever = "ZodNever",
|
|
62
|
-
ZodVoid = "ZodVoid",
|
|
63
|
-
ZodArray = "ZodArray",
|
|
64
|
-
ZodObject = "ZodObject",
|
|
65
|
-
ZodUnion = "ZodUnion",
|
|
66
|
-
ZodDiscriminatedUnion = "ZodDiscriminatedUnion",
|
|
67
|
-
ZodIntersection = "ZodIntersection",
|
|
68
|
-
ZodTuple = "ZodTuple",
|
|
69
|
-
ZodRecord = "ZodRecord",
|
|
70
|
-
ZodMap = "ZodMap",
|
|
71
|
-
ZodSet = "ZodSet",
|
|
72
|
-
ZodFunction = "ZodFunction",
|
|
73
|
-
ZodLazy = "ZodLazy",
|
|
74
|
-
ZodLiteral = "ZodLiteral",
|
|
75
|
-
ZodEnum = "ZodEnum",
|
|
76
|
-
ZodEffects = "ZodEffects",
|
|
77
|
-
ZodNativeEnum = "ZodNativeEnum",
|
|
78
|
-
ZodOptional = "ZodOptional",
|
|
79
|
-
ZodNullable = "ZodNullable",
|
|
80
|
-
ZodDefault = "ZodDefault",
|
|
81
|
-
ZodCatch = "ZodCatch",
|
|
82
|
-
ZodPromise = "ZodPromise",
|
|
83
|
-
ZodBranded = "ZodBranded",
|
|
84
|
-
ZodPipeline = "ZodPipeline",
|
|
85
|
-
ZodReadonly = "ZodReadonly"
|
|
86
50
|
}
|
package/v4/classic/compat.js
CHANGED
|
@@ -25,43 +25,7 @@ export function setErrorMap(map) {
|
|
|
25
25
|
export function getErrorMap() {
|
|
26
26
|
return core.config().customError;
|
|
27
27
|
}
|
|
28
|
-
/** @deprecated Do not use.
|
|
28
|
+
/** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
|
|
29
29
|
export var ZodFirstPartyTypeKind;
|
|
30
30
|
(function (ZodFirstPartyTypeKind) {
|
|
31
|
-
ZodFirstPartyTypeKind["ZodString"] = "ZodString";
|
|
32
|
-
ZodFirstPartyTypeKind["ZodNumber"] = "ZodNumber";
|
|
33
|
-
ZodFirstPartyTypeKind["ZodNaN"] = "ZodNaN";
|
|
34
|
-
ZodFirstPartyTypeKind["ZodBigInt"] = "ZodBigInt";
|
|
35
|
-
ZodFirstPartyTypeKind["ZodBoolean"] = "ZodBoolean";
|
|
36
|
-
ZodFirstPartyTypeKind["ZodDate"] = "ZodDate";
|
|
37
|
-
ZodFirstPartyTypeKind["ZodSymbol"] = "ZodSymbol";
|
|
38
|
-
ZodFirstPartyTypeKind["ZodUndefined"] = "ZodUndefined";
|
|
39
|
-
ZodFirstPartyTypeKind["ZodNull"] = "ZodNull";
|
|
40
|
-
ZodFirstPartyTypeKind["ZodAny"] = "ZodAny";
|
|
41
|
-
ZodFirstPartyTypeKind["ZodUnknown"] = "ZodUnknown";
|
|
42
|
-
ZodFirstPartyTypeKind["ZodNever"] = "ZodNever";
|
|
43
|
-
ZodFirstPartyTypeKind["ZodVoid"] = "ZodVoid";
|
|
44
|
-
ZodFirstPartyTypeKind["ZodArray"] = "ZodArray";
|
|
45
|
-
ZodFirstPartyTypeKind["ZodObject"] = "ZodObject";
|
|
46
|
-
ZodFirstPartyTypeKind["ZodUnion"] = "ZodUnion";
|
|
47
|
-
ZodFirstPartyTypeKind["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
|
|
48
|
-
ZodFirstPartyTypeKind["ZodIntersection"] = "ZodIntersection";
|
|
49
|
-
ZodFirstPartyTypeKind["ZodTuple"] = "ZodTuple";
|
|
50
|
-
ZodFirstPartyTypeKind["ZodRecord"] = "ZodRecord";
|
|
51
|
-
ZodFirstPartyTypeKind["ZodMap"] = "ZodMap";
|
|
52
|
-
ZodFirstPartyTypeKind["ZodSet"] = "ZodSet";
|
|
53
|
-
ZodFirstPartyTypeKind["ZodFunction"] = "ZodFunction";
|
|
54
|
-
ZodFirstPartyTypeKind["ZodLazy"] = "ZodLazy";
|
|
55
|
-
ZodFirstPartyTypeKind["ZodLiteral"] = "ZodLiteral";
|
|
56
|
-
ZodFirstPartyTypeKind["ZodEnum"] = "ZodEnum";
|
|
57
|
-
ZodFirstPartyTypeKind["ZodEffects"] = "ZodEffects";
|
|
58
|
-
ZodFirstPartyTypeKind["ZodNativeEnum"] = "ZodNativeEnum";
|
|
59
|
-
ZodFirstPartyTypeKind["ZodOptional"] = "ZodOptional";
|
|
60
|
-
ZodFirstPartyTypeKind["ZodNullable"] = "ZodNullable";
|
|
61
|
-
ZodFirstPartyTypeKind["ZodDefault"] = "ZodDefault";
|
|
62
|
-
ZodFirstPartyTypeKind["ZodCatch"] = "ZodCatch";
|
|
63
|
-
ZodFirstPartyTypeKind["ZodPromise"] = "ZodPromise";
|
|
64
|
-
ZodFirstPartyTypeKind["ZodBranded"] = "ZodBranded";
|
|
65
|
-
ZodFirstPartyTypeKind["ZodPipeline"] = "ZodPipeline";
|
|
66
|
-
ZodFirstPartyTypeKind["ZodReadonly"] = "ZodReadonly";
|
|
67
31
|
})(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
|
package/v4/core/schemas.cjs
CHANGED
|
@@ -984,7 +984,7 @@ core.$constructor("$ZodDiscriminatedUnion", (inst, def) => {
|
|
|
984
984
|
const opts = def.options;
|
|
985
985
|
const map = new Map();
|
|
986
986
|
for (const o of opts) {
|
|
987
|
-
const values = o._zod.propValues[def.discriminator];
|
|
987
|
+
const values = o._zod.propValues?.[def.discriminator];
|
|
988
988
|
if (!values || values.size === 0)
|
|
989
989
|
throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
|
|
990
990
|
for (const v of values) {
|
|
@@ -1617,6 +1617,7 @@ exports.$ZodPipe = core.$constructor("$ZodPipe", (inst, def) => {
|
|
|
1617
1617
|
util.defineLazy(inst._zod, "values", () => def.in._zod.values);
|
|
1618
1618
|
util.defineLazy(inst._zod, "optin", () => def.in._zod.optin);
|
|
1619
1619
|
util.defineLazy(inst._zod, "optout", () => def.out._zod.optout);
|
|
1620
|
+
util.defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
|
|
1620
1621
|
inst._zod.parse = (payload, ctx) => {
|
|
1621
1622
|
const left = def.in._zod.run(payload, ctx);
|
|
1622
1623
|
if (left instanceof Promise) {
|
package/v4/core/schemas.d.cts
CHANGED
|
@@ -935,6 +935,7 @@ export interface $ZodPipeInternals<A extends SomeType = $ZodType, B extends Some
|
|
|
935
935
|
values: A["_zod"]["values"];
|
|
936
936
|
optin: A["_zod"]["optin"];
|
|
937
937
|
optout: B["_zod"]["optout"];
|
|
938
|
+
propValues: A["_zod"]["propValues"];
|
|
938
939
|
}
|
|
939
940
|
export interface $ZodPipe<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodType {
|
|
940
941
|
_zod: $ZodPipeInternals<A, B>;
|
package/v4/core/schemas.d.ts
CHANGED
|
@@ -935,6 +935,7 @@ export interface $ZodPipeInternals<A extends SomeType = $ZodType, B extends Some
|
|
|
935
935
|
values: A["_zod"]["values"];
|
|
936
936
|
optin: A["_zod"]["optin"];
|
|
937
937
|
optout: B["_zod"]["optout"];
|
|
938
|
+
propValues: A["_zod"]["propValues"];
|
|
938
939
|
}
|
|
939
940
|
export interface $ZodPipe<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodType {
|
|
940
941
|
_zod: $ZodPipeInternals<A, B>;
|
package/v4/core/schemas.js
CHANGED
|
@@ -953,7 +953,7 @@ core.$constructor("$ZodDiscriminatedUnion", (inst, def) => {
|
|
|
953
953
|
const opts = def.options;
|
|
954
954
|
const map = new Map();
|
|
955
955
|
for (const o of opts) {
|
|
956
|
-
const values = o._zod.propValues[def.discriminator];
|
|
956
|
+
const values = o._zod.propValues?.[def.discriminator];
|
|
957
957
|
if (!values || values.size === 0)
|
|
958
958
|
throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
|
|
959
959
|
for (const v of values) {
|
|
@@ -1586,6 +1586,7 @@ export const $ZodPipe = /*@__PURE__*/ core.$constructor("$ZodPipe", (inst, def)
|
|
|
1586
1586
|
util.defineLazy(inst._zod, "values", () => def.in._zod.values);
|
|
1587
1587
|
util.defineLazy(inst._zod, "optin", () => def.in._zod.optin);
|
|
1588
1588
|
util.defineLazy(inst._zod, "optout", () => def.out._zod.optout);
|
|
1589
|
+
util.defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
|
|
1589
1590
|
inst._zod.parse = (payload, ctx) => {
|
|
1590
1591
|
const left = def.in._zod.run(payload, ctx);
|
|
1591
1592
|
if (left instanceof Promise) {
|
package/v4/core/versions.cjs
CHANGED
package/v4/core/versions.js
CHANGED