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

toZodString

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

The Gist

import { toZodString, T_JSONSchemaString } from '@weser/schema'

const json: T_JSONSchemaString = {
  type: 'string',
}

const schema = toZodString(json)

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

Parameters

ParameterTypeDescription
schemaT_JSONSchemaStringThe JSON string schema to convert to a Zod string schema.

Returns

(ZodString) A Zod string schema.

On this page