Options
All
  • Public
  • Public/Protected
  • All
Menu

Constant field. Field matching only one pre-defined value. This uses === to compare. Try marking the value as const for the typings to work.

example
const schema1 = fields.constant("hello" as const);
const schema2 = fields.constant(1 as const);
const schema3 = fields.constant(Symbol("hello") as const);

schema1.create("hello");
schema2.create(1);
schema3.create("hello");

Type parameters

  • T: unknown

Hierarchy

Index

Constructors

Properties

Accessors

Methods

Constructors

constructor

Properties

Readonly value

value: T

Accessors

name

  • get name(): string

type

  • get type(): string

Methods

check

  • check(value: unknown): boolean

create

  • create(value: T): T

validate

  • validate(value: unknown, key?: string): true

Generated using TypeDoc