ChatiumFor developersPlaygroundPricing
Sign in

Heap.Literal

Declares a literal schema - a type that contains only one specific value of type string | number | boolean.

It is practically useful only in combination with Heap.Union.

Usage / Signature

import { Heap } from '@app/heap'
Heap.Literal(value)

Arguments

  • <b id="value">value</b>: string | number | boolean
    The specific value of the literal.

Return Value

A JSON schema for the given constant with a type corresponding to the type of the constant.

Examples

Union Schema with Two String Literals
const tasks = Heap.Table('tasks', {
  status: Heap.Union(
    [
      Heap.Literal('in-progress'),
      Heap.Literal('done'),
    ],
    { default: 'in-progress' },
  ),
})