Schema
/ API Reference / ConvertersSchema
/ API Reference / ConverterstoZodString
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
Parameter | Type | Description |
---|---|---|
schema | T_JSONSchemaString | The JSON string schema to convert to a Zod string schema. |
Returns
(ZodString
) A Zod string schema.
© 2024-present Robin Weser. All Rights Reserved.