Defjs
Core

struct.or

Struct that accepts a value matching any one of several structs.

@defjs/core · Function

Signature

function or<const T extends readonly [StructLike, ...StructLike[]]>(
  ...options: T
): UnionStruct<T>;

struct.or is variadic: pass each option as its own argument.

  • Tries the options in order and returns the result of the first one that parses.

  • If none matches, it fails with one invalid_union issue at the union's own path. The issues of the individual options are not reported.

  • Throws TypeError when an option is not a struct.

UnionStruct<T> is not exported. It is a Struct whose input and output are the unions of the option types, without undefined. For tagged objects prefer struct.discriminatedUnion(), which reports the issue of the selected option.

Parameters

Prop

Type

...options? T
Edit this page on GitHub
Released under the MIT License. · Copyright © 2026 MunMunMiao