Skip to main content

The or() Function

Tip

You can nest t.or calls. This can be useful when creating custom types.

{
age: t.or(t.str, t.or(t.int8, t.or(t.date, t.float64, t.none)))
}

Tip

You can pass an array or an object to t.or by using t.schema()

{
age: t.or(t.schema([t.str]), t.int8)
}

See more details about t.schema()

Overview

t.or(...types: TCustomType[]): TCustomType
  • The t.or() function lets you enumerate several serializable types.
  • t.or() can accept up to 255 arguments.
  • You cannot directly pass arrays or objects to t.or; you must use t.schema().

Usage Examples