Options
All
  • Public
  • Public/Protected
  • All
Menu

Or/Union field. Union (| in TypeScript) between multiple fields.

example
const schema = fields.or(fields.number(), fields.constant("hello" as const));

schema.create(1);
schema.create("hello");

Type parameters

Hierarchy

Index

Constructors

Properties

Accessors

Methods

Constructors

constructor

  • new OrField<T>(...models: T): OrField<T>

Properties

models

models: T

Accessors

name

  • get name(): string

type

  • get type(): string

Methods

check

  • check(value: unknown): boolean

create

  • create(value: { [ M in string | number | symbol]: T[M] extends FieldModel<U> ? U : never }[number]): { [ M in string | number | symbol]: T[M] extends FieldModel<U> ? U : never }[number]

validate

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

Generated using TypeDoc