Skip to main content

Variable: stripOptionalNulls

const stripOptionalNulls: (value, jsonSchema) => unknown = restorePortableValue

Defined in: packages/workflow-engine/src/ai/schema-portability.ts:472

The 1.0.0-alpha.4 name of restorePortableValue; same function.

value (a model's parsed JSON reply) brought back to the shape of the ORIGINAL schema — the one toPortableJsonSchema(…, "openai") was fed — so the caller's Zod schema parses it: every null is removed where the schema has an optional, non-nullable property, and every record the target received as { key, value } pairs is rebuilt into an object. Nested objects, arrays, union members and $defs are covered; a null the original schema admits (required or .nullable()) is kept. Never mutates its input.

Parameters​

value​

unknown

jsonSchema​

unknown

Returns​

unknown