← @mortar-kit/core

validateDocfunction

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

function validateDoc(collection: AnyCollection, bricks: readonly AnyBrick[], raw: unknown): ValidateDocResult

Checks a document before it is saved: its id and slug (not one of the collection's reserved slugs), its fields against the collection's schema (issues at ['fields', ...]), and with a body its entries. Unknown top-level keys are dropped, and so is position (createContent keeps the stored one). Whether the slug is free is the store's question, not this one.

Parameters

collection: AnyCollection
bricks: readonly AnyBrick[]
raw: unknown

Returns

ValidateDocResult