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
}