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

createArraySchema

A function that creates a JSON array schema.

The Gist

import { createArraySchema, createStringSchema } from '@weser/schema'

const stringSchema = createStringSchema()

const schema = createArraySchema(stringSchema)
const schemaWithOptions = createArraySchema(stringSchema, {
  default: ['foo', 'bar'],
})

Parameters

ParameterTypeDescription
itemsT_JSONSchemaThe JSON schema of the items in the array.
optionsOptions?The options for the array schema.

Options

ParameterTypeDescription
descriptionstring?The description of the array schema.
defaultArray<T>?The default value of the array schema.

Returns

(T_JSONSchemaArray) A JSON array schema.

On this page