objectValidator

function objectValidator<T>(validatorStructure): (subject) => subject is DestructureGuardedTypeObj<T>

Creates a validator which tests if the target is an object
and if the structure of the object matches the structure of the passed-in
validator object. The values in the validator object are in turn
validators. This means that if the validator object has a (key,value)
pair of the form ('key', keyValidator), then in order for the target object
(x) to match, keyValidator(x['key']) must return true for all keys in the
validatorStructure.

Note that you can use lucid.validators.option to create optional parameters
in validation structure.

Type parameters

Type parameter
T extends object

Parameters

ParameterType
validatorStructureT

Returns

Function

Parameters

ParameterType
subjectunknown

Returns

subject is DestructureGuardedTypeObj<T>