Skip to main content

Module: Guard

Type Aliases

GuardQualifier

Ƭ GuardQualifier<Function, Validator>: [validator: Validator, executor: Function]

Type parameters

NameType
Functionextends VariadicFunction
Validatorextends (...args: Parameters<Function>) => boolean

Functions

guard

guard<Function, Validators>(...qualifiers): Function

A function which accepts the pairs of guards: the first one is the validator, expected to return a boolean value.

If the value is true, it's executor should run with the provided args and return from the guards function. If the value is false, the process continues to the next validator.

When no validator succeeds, the default executor is run.

Type parameters

NameType
Functionextends VariadicFunction
Validatorsextends (...args: Parameters<Function>) => boolean[]

Parameters

NameType
...qualifiers[...GuardQualifier<Function, Validators[number]>[], Function]

Returns

Function