Schema
/ API Reference / Builders
Schema
/ API Reference / Builders

createStringSchema

A function that creates a JSON string schema.

The Gist

import { createStringSchema } from '@weser/schema'

const schema = createStringSchema()
const schemaWithOptions = createStringSchema({
  minLength: 10,
})
const dateSchema = createStringSchema({
  format: 'date',
})

Parameters

ParameterTypeDescription
optionsOptions?The options for the string schema.

Options

ParameterTypeDescription
minLengthnumber?The minimum length of the string.
maxLengthnumber?The maximum length of the string.
format'date' | 'uri' | 'email'?The format of the string.
descriptionstring?The description of the string.
defaultstring?The default value of the string.

Returns

(T_JSONSchemaString) A JSON string schema.

On this page