assertDataProp()function

assertDataProp(data: T, key: unknown, caller: AnyCaller = assertDataProp): asserts key is DataKey<T>
ParamType
dataT
The data object to check against. required
keyunknown
The value to check as a key. required
callerAnyCaller
The function to attribute a thrown error to (defaults to assertDataProp). Defaults to assertDataProp
Return
asserts key is DataKey<T>
Throws
RequiredError
If key is not an own key of data.

Assert that an unknown value is the key for an own prop of a data object.

Examples

assertDataProp(data, key); // throws unless `key` exists in `data`