isMapConstraint()
isMapConstraint<
K,V>(schema):schema is MapConstraint<K, V>
Type guard for MapConstraint. Checks that the schema is a map type and has constraint methods.
Type Parametersβ
K: K extends GenericSchemaβ
V: V extends GenericSchemaβ
Parametersβ
schema: GenericSchemaβ
The schema to check
Returns: schema is MapConstraint<K, V>β
True if the schema is a MapConstraint with constraint methods
Sinceβ
2.0.0
Exampleβ
const schema = map(string(), number()).minSize(1);
if (isMapConstraint(schema)) {
// schema is narrowed to MapConstraint
schema.maxSize(10); // constraint methods available
}