diff --git a/packages/zod/package.json b/packages/zod/package.json index 7affffe0de..7eb789663a 100644 --- a/packages/zod/package.json +++ b/packages/zod/package.json @@ -1,6 +1,6 @@ { "name": "zod", - "version": "3.25.61", + "version": "3.25.62", "type": "module", "author": "Colin McDonnell ", "description": "TypeScript-first schema declaration and validation library with static type inference", diff --git a/packages/zod/src/v4/core/json-schema.ts b/packages/zod/src/v4/core/json-schema.ts index aa8821613b..4b3abfbe02 100644 --- a/packages/zod/src/v4/core/json-schema.ts +++ b/packages/zod/src/v4/core/json-schema.ts @@ -10,105 +10,105 @@ export type Schema = // export type JsonType = "object" | "array" | "string" | "number" | "boolean" | "null" | "integer"; // export interface JSONSchema { -// type?: string | undefined; -// $id?: string | undefined; -// id?: string | undefined; -// $schema?: string | undefined; -// $ref?: string | undefined; -// $anchor?: string | undefined; -// $defs?: { [key: string]: JSONSchema } | undefined; -// definitions?: { [key: string]: JSONSchema } | undefined; -// $comment?: string | undefined; -// title?: string | undefined; -// description?: string | undefined; -// default?: unknown | undefined; -// examples?: unknown[] | undefined; -// readOnly?: boolean | undefined; -// writeOnly?: boolean | undefined; -// deprecated?: boolean | undefined; -// allOf?: JSONSchema[] | undefined; -// anyOf?: JSONSchema[] | undefined; -// oneOf?: JSONSchema[] | undefined; -// not?: JSONSchema | undefined; -// if?: JSONSchema | undefined; -// then?: JSONSchema | undefined; -// else?: JSONSchema | undefined; -// enum?: Array | undefined; -// const?: string | number | boolean | null | undefined; +// type?: string ; +// $id?: string ; +// id?: string ; +// $schema?: string ; +// $ref?: string ; +// $anchor?: string ; +// $defs?: { [key: string]: JSONSchema } ; +// definitions?: { [key: string]: JSONSchema } ; +// $comment?: string ; +// title?: string ; +// description?: string ; +// default?: unknown ; +// examples?: unknown[] ; +// readOnly?: boolean ; +// writeOnly?: boolean ; +// deprecated?: boolean ; +// allOf?: JSONSchema[] ; +// anyOf?: JSONSchema[] ; +// oneOf?: JSONSchema[] ; +// not?: JSONSchema ; +// if?: JSONSchema ; +// then?: JSONSchema ; +// else?: JSONSchema ; +// enum?: Array ; +// const?: string | number | boolean | null ; // [k: string]: unknown; // /** A special key used as an intermediate representation of extends-style relationships. Omitted as a $ref with additional properties. */ // // _ref?: JSONSchema; -// _prefault?: unknown | undefined; +// _prefault?: unknown ; // } export type _JSONSchema = boolean | JSONSchema; export type JSONSchema = { [k: string]: unknown; - $schema?: "https://json-schema.org/draft/2020-12/schema" | "http://json-schema.org/draft-07/schema#" | undefined; - $id?: string | undefined; - $anchor?: string | undefined; - $ref?: string | undefined; - $dynamicRef?: string | undefined; - $dynamicAnchor?: string | undefined; - $vocabulary?: Record | undefined; - $comment?: string | undefined; - $defs?: Record | undefined; - type?: "object" | "array" | "string" | "number" | "boolean" | "null" | "integer" | undefined; - additionalItems?: _JSONSchema | undefined; - unevaluatedItems?: _JSONSchema | undefined; - prefixItems?: _JSONSchema[] | undefined; - items?: _JSONSchema | _JSONSchema[] | undefined; - contains?: _JSONSchema | undefined; - additionalProperties?: _JSONSchema | undefined; - unevaluatedProperties?: _JSONSchema | undefined; - properties?: Record | undefined; - patternProperties?: Record | undefined; - dependentSchemas?: Record | undefined; - propertyNames?: _JSONSchema | undefined; - if?: _JSONSchema | undefined; - then?: _JSONSchema | undefined; - else?: _JSONSchema | undefined; - allOf?: JSONSchema[] | undefined; - anyOf?: JSONSchema[] | undefined; - oneOf?: JSONSchema[] | undefined; - not?: _JSONSchema | undefined; - multipleOf?: number | undefined; - maximum?: number | undefined; - exclusiveMaximum?: number | undefined; - minimum?: number | undefined; - exclusiveMinimum?: number | undefined; - maxLength?: number | undefined; - minLength?: number | undefined; - pattern?: string | undefined; - maxItems?: number | undefined; - minItems?: number | undefined; - uniqueItems?: boolean | undefined; - maxContains?: number | undefined; - minContains?: number | undefined; - maxProperties?: number | undefined; - minProperties?: number | undefined; - required?: string[] | undefined; - dependentRequired?: Record | undefined; - enum?: Array | undefined; - const?: string | number | boolean | null | undefined; + $schema?: "https://json-schema.org/draft/2020-12/schema" | "http://json-schema.org/draft-07/schema#"; + $id?: string; + $anchor?: string; + $ref?: string; + $dynamicRef?: string; + $dynamicAnchor?: string; + $vocabulary?: Record; + $comment?: string; + $defs?: Record; + type?: "object" | "array" | "string" | "number" | "boolean" | "null" | "integer"; + additionalItems?: _JSONSchema; + unevaluatedItems?: _JSONSchema; + prefixItems?: _JSONSchema[]; + items?: _JSONSchema | _JSONSchema[]; + contains?: _JSONSchema; + additionalProperties?: _JSONSchema; + unevaluatedProperties?: _JSONSchema; + properties?: Record; + patternProperties?: Record; + dependentSchemas?: Record; + propertyNames?: _JSONSchema; + if?: _JSONSchema; + then?: _JSONSchema; + else?: _JSONSchema; + allOf?: JSONSchema[]; + anyOf?: JSONSchema[]; + oneOf?: JSONSchema[]; + not?: _JSONSchema; + multipleOf?: number; + maximum?: number; + exclusiveMaximum?: number; + minimum?: number; + exclusiveMinimum?: number; + maxLength?: number; + minLength?: number; + pattern?: string; + maxItems?: number; + minItems?: number; + uniqueItems?: boolean; + maxContains?: number; + minContains?: number; + maxProperties?: number; + minProperties?: number; + required?: string[]; + dependentRequired?: Record; + enum?: Array; + const?: string | number | boolean | null; // metadata - id?: string | undefined; - title?: string | undefined; - description?: string | undefined; - default?: unknown | undefined; - deprecated?: boolean | undefined; - readOnly?: boolean | undefined; - writeOnly?: boolean | undefined; - examples?: unknown[] | undefined; - format?: string | undefined; - contentMediaType?: string | undefined; - contentEncoding?: string | undefined; - contentSchema?: JSONSchema | undefined; + id?: string; + title?: string; + description?: string; + default?: unknown; + deprecated?: boolean; + readOnly?: boolean; + writeOnly?: boolean; + examples?: unknown[]; + format?: string; + contentMediaType?: string; + contentEncoding?: string; + contentSchema?: JSONSchema; // internal - _prefault?: unknown | undefined; + _prefault?: unknown; }; // for backwards compatibility diff --git a/play.ts b/play.ts index a07a807805..41eb006bd0 100644 --- a/play.ts +++ b/play.ts @@ -1,10 +1,3 @@ import { z } from "zod/v4"; -const A = z.string().describe("name"); -const B = A.superRefine((val, ctx) => { - ctx.addIssue({ - message: `Invalid ${A.description}`, - }); -}); - -B.parse("test"); // Should pass +z;