objectTypeGuard<T>
Builds a guard accepting an object whose every listed property its guard accepts. A property is read with Reflect.get, so an inherited one counts and an absent one reads as undefined, unless ObjectTypeGuardOptions.exactOptionalKeys switches the guard to own keys and exact optional properties.
Import:
import { objectTypeGuard } from '@mnaoumov/typescript-lib/type-guards';Signature:
function objectTypeGuard(propertyTypeGuards: PropertyTypeGuards<T>, options: ObjectTypeGuardOptions<T> | undefined): TypeGuard<T>Parameters:
| Parameter | Type | Description |
|---|---|---|
propertyTypeGuards |
PropertyTypeGuards<T> | One guard per property of T. |
options |
ObjectTypeGuardOptions<T> | undefined | The options for the guard. |
Returns: TypeGuard<T> — The guard.
Links to this page: