← @mortar-kit/core

SchemaOpsinterface

import { SchemaOps } from '@mortar-kit/core'

interface SchemaOps<F extends Fields>

What bricks and collections share: defaults, validation and normalization for a record of fields.

Properties

defaults: () => InferFields<F>

Fresh default data.

validate: (data: unknown) => ValidateResult<InferFields<F>>

Validates (and fills defaults into) unknown data.

normalize: (data: unknown) => InferFields<F>

Coerces unknown data into the schema's shape for rendering: missing fields get defaults, and fields of the wrong type are replaced by their default. Values that are the right type but break a rule (an empty required text) are kept, so a preview shows what the editor typed.