Skip to content

objectGuard<T>

Builds a guard accepting an object whose every listed property its guard accepts, as objectTypeGuard does, expecting the properties and what each expects: { alias?: a string; path: a string }, after the ObjectGuardOptions.description when one is given. A key is marked optional when it is listed in ObjectTypeGuardOptions.exactOptionalKeys; without that list, an optional property’s guard says or undefined itself.

Import:

import { objectGuard } from '@mnaoumov/typescript-lib/api-contract';

Signature:

function objectGuard(propertyGuards: PropertyGuards<T>, options: ObjectGuardOptions<T> | undefined): ExpectedTypeGuard<T>

Parameters:

Parameter Type Description
propertyGuards PropertyGuards<T> One guard per property of T.
options ObjectGuardOptions<T> | undefined The options for the guard.

Returns: ExpectedTypeGuard<T> — The guard.


Links to this page: