Home > llm-ops > createJsonValidator
createJsonValidator() function
Returns a JSON validator for a given TypeScript schema. Validation is performed by an in-memory instance of the TypeScript compiler. The specified type argument T
must be the same type as typeName
in the given schema
.
Signature:
typescript
export declare function createJsonValidator<T extends object = object>(schema: string, typeName: string): TypeChatJsonValidator<T>;
export declare function createJsonValidator<T extends object = object>(schema: string, typeName: string): TypeChatJsonValidator<T>;
Parameters
Parameter | Type | Description |
---|---|---|
schema | string | A string containing the TypeScript source code for the JSON schema. |
typeName | string | The name of the JSON target type in the schema. |
Returns:
A TypeChatJsonValidator<T>
instance.