throwIfDoesNotContain
Stentor API Reference / stentor-utils/src / throwIfDoesNotContain
Function: throwIfDoesNotContain()
throwIfDoesNotContain(
obj,requiredAttrs,undefinedPermitted?,onError?):void
Defined in: packages/stentor-utils/src/object/index.ts:131
A validation function that can check if an object contains the required attributes and throws an error if they are not part of it.
Parametersβ
objβ
object
Object to check
requiredAttrsβ
string[]
The attributes in the object that are required.
undefinedPermitted?β
boolean
True if the object is allowed to be undefined. Default is false in which case an error will be thrown.
onError?β
ValidationErrorHandler = defaultValidationErrorHandler
An optional error handler that allows for custom messages or actions. The keys passed in will be the keys that were required but are not inside the object.
Returnsβ
void