Skip to main content

Class: ZodSchema<OBJECT>

Validates that the structure of a value matches this schema.

Type parameters

Name
OBJECT

Implements

Constructors

constructor

new ZodSchema<OBJECT>(zodSchema): ZodSchema<OBJECT>

Type parameters

Name
OBJECT

Parameters

NameType
zodSchemaZodType<OBJECT, ZodTypeDef, OBJECT>

Returns

ZodSchema<OBJECT>

Defined in

packages/modelfusion/src/core/schema/ZodSchema.ts:14

Methods

getJsonSchema

getJsonSchema(): unknown

Returns the JSON schema for this schema. The schema has to be a valid JSON schema in object form.

Returns

unknown

Implementation of

JsonSchemaProducer.getJsonSchema

Defined in

packages/modelfusion/src/core/schema/ZodSchema.ts:28


validate

validate(value): { success: true ; value: OBJECT } | { error: unknown ; success: false }

Validates that the structure of a value matches this schema, and returns a typed version of the value if it does.

Parameters

NameType
valueunknown

Returns

{ success: true ; value: OBJECT } | { error: unknown ; success: false }

Implementation of

Schema.validate

Defined in

packages/modelfusion/src/core/schema/ZodSchema.ts:18

Properties

_partialType

Readonly _partialType: PartialDeep<OBJECT, { recurseIntoArrays: true }>

Use only for typing purposes. The value is always undefined.

Defined in

packages/modelfusion/src/core/schema/ZodSchema.ts:40


_type

Readonly _type: OBJECT

Use only for typing purposes. The value is always undefined.

Implementation of

Schema._type

Defined in

packages/modelfusion/src/core/schema/ZodSchema.ts:35


zodSchema

Readonly zodSchema: ZodType<OBJECT, ZodTypeDef, OBJECT>

Defined in

packages/modelfusion/src/core/schema/ZodSchema.ts:12