Documentation
Functions
extractZodObject

Function: extractZodObject()

extractZodObject<Schema>(args): z.infer<Schema>

Extract an object from a JSON string and validate it against a Zod schema. Throws an error with a message optimized for GPT readability if it fails.

Type parameters

Parameter
Schema extends ZodObject<any, UnknownKeysParam, ZodTypeAny, object, object>

Parameters

ParameterType
argsobject
args.jsonstring
args.schemaSchema

Returns

z.infer<Schema>

Source

src/prompt/functions/extract-zod-object.ts:9 (opens in a new tab)