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

createEnumSchema

A function that creates a JSON enum schema.

The Gist

import { createEnumSchema } from '@weser/schema'

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

Parameters

ParameterTypeDescription
valuesArray<string>The values of the enum schema.
optionsOptions?The options for the enum schema.

Options

ParameterTypeDescription
descriptionstring?The description of the enum schema.
defaultstring?The default value of the enum schema.
On this page