MCPcopy
hub / github.com/colinhacks/zod / nullableProcessor

Function nullableProcessor

packages/zod/src/v4/core/json-schema-processors.ts:477–487  ·  view source on GitHub ↗
(schema, ctx, json, params)

Source from the content-addressed store, hash-verified

475};
476
477export const nullableProcessor: Processor<schemas.$ZodNullable> = (schema, ctx, json, params) => {
478 const def = schema._zod.def as schemas.$ZodNullableDef;
479 const inner = process(def.innerType, ctx as any, params);
480 const seen = ctx.seen.get(schema)!;
481 if (ctx.target === "openapi-3.0") {
482 seen.ref = def.innerType;
483 json.nullable = true;
484 } else {
485 json.anyOf = [inner, { type: "null" }];
486 }
487};
488
489export const nonoptionalProcessor: Processor<schemas.$ZodNonOptional> = (schema, ctx, _json, params) => {
490 const def = schema._zod.def as schemas.$ZodNonOptionalDef;

Callers

nothing calls this directly

Calls 2

processFunction · 0.90
getMethod · 0.80

Tested by

no test coverage detected