optionsGuard<T>
Builds a guard accepting an options bag: an object whose every option may be absent, or undefined, and must otherwise pass its guard. A key no guard names is let through unless OptionsGuardOptions.shouldRejectUnknownKeys is set. It expects the options and what each expects: { prefix?: a string; isHidden?: a boolean }, after the OptionsGuardOptions.description when one is given.
Import:
import { optionsGuard } from '@mnaoumov/typescript-lib/api-contract';Signature:
function optionsGuard(optionGuards: OptionGuards<T>, options: OptionsGuardOptions | undefined): ExpectedTypeGuard<T>Parameters:
| Parameter | Type | Description |
|---|---|---|
optionGuards |
OptionGuards<T> | One guard per option of T, for a present value. |
options |
OptionsGuardOptions | undefined | The options for the guard. |
Returns: ExpectedTypeGuard<T> — The guard.
Links to this page: