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

createObjectSchema

A function that creates a JSON object schema.

The Gist

import { createObjectSchema } from '@weser/schema'

const schema = createObjectSchema({
  name: createStringSchema(),
})
const schemaWithOptions = createObjectSchema(
  {
    name: createStringSchema(),
  },
  {
    required: ['name'],
    default: {
      name: 'John Doe',
    },
  }
)

Parameters

ParameterTypeDescription
propertiesRecord<string, T_JSONSchema>The properties of the object schema.
optionsOptions?The options for the object schema.

Options

ParameterTypeDescription
requiredArray<keyof T>?The required properties of the object schema.
descriptionstring?The description of the object schema.
defaultT?The default value of the object schema.
On this page