isObjectConstraint()
isObjectConstraint<
T>(schema):schema is ObjectConstraint<T>
Type guard for ObjectConstraint. Checks that the schema is an object type and has constraint methods.
Type Parameters
T: T extends Record<string, GenericSchema> = Record<string, GenericSchema>
Parameters
schema: GenericSchema
The schema to check
Returns: schema is ObjectConstraint<T>
True if the schema is an ObjectConstraint with constraint methods
Since
2.0.0
Example
const schema = object({ name: string() }).minKeys(1);
if (isObjectConstraint(schema)) {
// schema is narrowed to ObjectConstraint
schema.maxKeys(5); // constraint methods available
}