zod 3.25.26 → 3.25.27
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/dist/cjs/v4/classic/schemas.js +8 -0
- package/dist/cjs/v4/core/to-json-schema.js +1 -1
- package/dist/esm/v4/classic/schemas.js +8 -0
- package/dist/esm/v4/core/to-json-schema.js +1 -1
- package/dist/types/v4/classic/schemas.d.ts +2 -0
- package/dist/types/v4/core/schemas.d.ts +1 -1
- package/dist/types/v4/core/to-json-schema.d.ts +2 -2
- package/package.json +1 -1
|
@@ -828,6 +828,14 @@ exports.ZodLiteral = core.$constructor("ZodLiteral", (inst, def) => {
|
|
|
828
828
|
core.$ZodLiteral.init(inst, def);
|
|
829
829
|
exports.ZodType.init(inst, def);
|
|
830
830
|
inst.values = new Set(def.values);
|
|
831
|
+
Object.defineProperty(inst, "value", {
|
|
832
|
+
get() {
|
|
833
|
+
if (def.values.length > 1) {
|
|
834
|
+
throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");
|
|
835
|
+
}
|
|
836
|
+
return def.values[0];
|
|
837
|
+
},
|
|
838
|
+
});
|
|
831
839
|
});
|
|
832
840
|
function literal(value, params) {
|
|
833
841
|
return new exports.ZodLiteral({
|
|
@@ -725,6 +725,14 @@ export const ZodLiteral = /*@__PURE__*/ core.$constructor("ZodLiteral", (inst, d
|
|
|
725
725
|
core.$ZodLiteral.init(inst, def);
|
|
726
726
|
ZodType.init(inst, def);
|
|
727
727
|
inst.values = new Set(def.values);
|
|
728
|
+
Object.defineProperty(inst, "value", {
|
|
729
|
+
get() {
|
|
730
|
+
if (def.values.length > 1) {
|
|
731
|
+
throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");
|
|
732
|
+
}
|
|
733
|
+
return def.values[0];
|
|
734
|
+
},
|
|
735
|
+
});
|
|
728
736
|
});
|
|
729
737
|
export function literal(value, params) {
|
|
730
738
|
return new ZodLiteral({
|
|
@@ -527,6 +527,8 @@ export declare function nativeEnum<T extends util.EnumLike>(entries: T, params?:
|
|
|
527
527
|
export interface ZodLiteral<T extends util.Primitive = util.Primitive> extends ZodType {
|
|
528
528
|
_zod: core.$ZodLiteralInternals<T>;
|
|
529
529
|
values: Set<T>;
|
|
530
|
+
/** @legacy Use `.values` instead. Accessing this property will throw an error if the literal accepts multiple values. */
|
|
531
|
+
value: T;
|
|
530
532
|
}
|
|
531
533
|
export declare const ZodLiteral: core.$constructor<ZodLiteral>;
|
|
532
534
|
export declare function literal<const T extends Array<util.Literal>>(value: T, params?: string | core.$ZodLiteralParams): ZodLiteral<T[number]>;
|
|
@@ -715,7 +715,7 @@ export interface $ZodLiteralDef extends $ZodTypeDef {
|
|
|
715
715
|
}
|
|
716
716
|
export interface $ZodLiteralInternals<T extends util.Primitive = util.Primitive> extends $ZodTypeInternals<T, T> {
|
|
717
717
|
def: $ZodLiteralDef;
|
|
718
|
-
values:
|
|
718
|
+
values: Set<T>;
|
|
719
719
|
pattern: RegExp;
|
|
720
720
|
isst: errors.$ZodIssueInvalidValue;
|
|
721
721
|
}
|
|
@@ -15,7 +15,7 @@ interface JSONSchemaGeneratorParams {
|
|
|
15
15
|
unrepresentable?: "throw" | "any";
|
|
16
16
|
/** Arbitrary custom logic that can be used to modify the generated JSON Schema. */
|
|
17
17
|
override?: (ctx: {
|
|
18
|
-
zodSchema: schemas.$
|
|
18
|
+
zodSchema: schemas.$ZodTypes;
|
|
19
19
|
jsonSchema: JSONSchema.BaseSchema;
|
|
20
20
|
}) => void;
|
|
21
21
|
/** Whether to extract the `"input"` or `"output"` type. Relevant to transforms, Error converting schema to JSONz, defaults, coerced primitives, etc.
|
|
@@ -60,7 +60,7 @@ export declare class JSONSchemaGenerator {
|
|
|
60
60
|
target: "draft-7" | "draft-2020-12";
|
|
61
61
|
unrepresentable: "throw" | "any";
|
|
62
62
|
override: (ctx: {
|
|
63
|
-
zodSchema: schemas.$
|
|
63
|
+
zodSchema: schemas.$ZodTypes;
|
|
64
64
|
jsonSchema: JSONSchema.BaseSchema;
|
|
65
65
|
}) => void;
|
|
66
66
|
io: "input" | "output";
|
package/package.json
CHANGED