forwardAssertsSelection
Forwards Either values selected by an exhaustive information selector unchanged and throws for the others.
The selector maps every possible information of the input union to true or false. An Either mapped to true is returned intact, while an Either mapped to false throws a ForwardAssertsSelectionError. Any value that is not an Either passes through unchanged.
Interactive example
Syntax
Classic signature
typescript
function forwardAssertsSelection<
GenericInput extends unknown,
GenericSelector extends Record<Information, boolean>,
>(
input: GenericInput,
selector: GenericSelector,
): SelectedInputCurried signature
typescript
function forwardAssertsSelection<
GenericInput extends unknown,
GenericSelector extends Record<Information, boolean>,
>(
selector: GenericSelector,
): (input: GenericInput) => SelectedInputParameters
selector: Exhaustive object where every possibleEitherinformation from the input is mapped totrueorfalse.input: Value to check immediately, or later through the curried form.
Return value
Returns the input unchanged when it is not an Either or when its information is selected with true. If an Either information is mapped to false, the function throws E.ForwardAssertsSelectionError.
The return type excludes branches explicitly mapped to false. A selector entry typed as boolean keeps its branch in the return type because it may be true at runtime.
See also
unwrapSelectionOrThrow– Exhaustive selection that unwraps allowed payloads.unwrapSelection– Non-throwing exhaustive selection that unwraps allowed branches.forwardAsserts– Generic assertion that forwards the validated value.
