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_unionissue at the union's own path. The issues of the individual options are not reported. -
Throws
TypeErrorwhen 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