Schema
/ API Reference / ConvertersSchema
/ API Reference / ConverterstoZodNumber
A function that converts a JSON number schema to a Zod number schema.
The Gist
import { toZodNumber, T_JSONSchemaNumber } from '@weser/schema'
const json: T_JSONSchemaNumber = {
type: 'number',
}
const schema = toZodNumber(json)
// You can now use the schema as is
schema.safeParse(3)
Parameters
Parameter | Type | Description |
---|---|---|
schema | T_JSONSchemaNumber | The JSON number schema to convert to a Zod number schema. |
Returns
(ZodNumber
) A Zod number schema.
© 2024-present Robin Weser. All Rights Reserved.