either

function either<A, B>(validatorA, validatorB): (x) => x is A | B

Create a validator that merges two validators.
This is useful for validating properties that have 2 disjoint sets of possible values.
e.g. {someObject: string}|false

Type parameters

Type parameter
A
B

Parameters

ParameterType
validatorAValidator<A>
validatorBValidator<B>

Returns

Function

Parameters

ParameterType
xunknown

Returns

x is A | B