Skip to content

TypeScript API / @laikacms/astro/loader / jsonSchemaToZod

Function: jsonSchemaToZod() ​

ts
function jsonSchemaToZod(schema, z): ZodTypeLike;

Convert a collection's JSON Schema into a Zod object schema.

Only the top level is special-cased: Astro expects an object schema for a collection, so a non-object schema (or one with no properties) yields a passthrough rather than an error.

Parameters ​

ParameterType
schemaJSONSchema7
zZodNamespace

Returns ​

ZodTypeLike

Released under the MIT License.