function strictObjectValidator<T>(validatorStructure): (subject) => subject is DestructureGuardedTypeObj<T>
Similar to objectValidator, but if the object has any non-undefined keys, they must also be present in the validator structure.
This is useful for things where extra data is unwanted, like Property serialization.
the loose version is often prefered because this one makes backwards compatible changes to the data harder,
because it requires an additional PR when the data transfers between services:
- A PR that adds the option() to this validator; 2. A PR that sends the new data; 3. A PR to remove the option();
compared to the (non-strict)objectValidator steps: - A PR that adds the option() to this validator and sends the new data; 2. A PR to remove the option();
Type parameters
Type parameter |
---|
T extends object |
Parameters
Parameter | Type |
---|---|
validatorStructure | T |
Returns
Function
Parameters
Parameter | Type |
---|---|
subject | unknown |
Returns
subject is DestructureGuardedTypeObj<T>