Schema
/ API Reference / Converters
Schema
/ API Reference / Converters

toZodBoolean

A function that converts a JSON boolean schema to a Zod boolean schema.

The Gist

import { toZodBoolean, T_JSONSchemaBoolean } from '@weser/schema'

const json: T_JSONSchemaBoolean = {
  type: 'boolean',
}

const schema = toZodArray(json)

// You can now use the schema as is
schema.safeParse(true)

Parameters

ParameterTypeDescription
schemaT_JSONSchemaBooleanThe JSON boolean schema to convert to a Zod boolean schema.

Returns

(ZodBoolean) A Zod boolean schema.

On this page