Skip to main content

unionOf()

unionOf<S1, S2>(schema1, schema2, message?): UnionSchema<readonly [S1, S2]>

Union schema with specific types for better ergonomics.


Type Parametersโ€‹

S1: S1 extends GenericSchemaโ€‹

S2: S2 extends GenericSchemaโ€‹


Parametersโ€‹

schema1: S1โ€‹

First schema.

schema2: S2โ€‹

Second schema.

message?: stringโ€‹

Custom error message (optional).


Returns: UnionSchema<readonly [S1, S2]>โ€‹

UnionSchema with two schemas.


Sinceโ€‹

2.0.0