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.
@@ -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({
@@ -595,7 +595,7 @@ class JSONSchemaGenerator {
595
595
  }
596
596
  if (!seen.isParent)
597
597
  this.override({
598
- zodSchema,
598
+ zodSchema: zodSchema,
599
599
  jsonSchema: schema,
600
600
  });
601
601
  };
@@ -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({
@@ -591,7 +591,7 @@ export class JSONSchemaGenerator {
591
591
  }
592
592
  if (!seen.isParent)
593
593
  this.override({
594
- zodSchema,
594
+ zodSchema: zodSchema,
595
595
  jsonSchema: schema,
596
596
  });
597
597
  };
@@ -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: util.PrimitiveSet;
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.$ZodType;
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.$ZodType;
63
+ zodSchema: schemas.$ZodTypes;
64
64
  jsonSchema: JSONSchema.BaseSchema;
65
65
  }) => void;
66
66
  io: "input" | "output";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zod",
3
- "version": "3.25.26",
3
+ "version": "3.25.27",
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",