Skip to main content

isNumberConstraint()

isNumberConstraint(schema): schema is NumberConstraint

Type guard for NumberConstraint. Checks that the schema is a number type and has constraint methods.


Parametersโ€‹

schema: GenericSchemaโ€‹

The schema to check


Returns: schema is NumberConstraintโ€‹

True if the schema is a NumberConstraint with constraint methods


Sinceโ€‹

2.0.0


Exampleโ€‹

const schema = number().min(0);
if (isNumberConstraint(schema)) {
// schema is narrowed to NumberConstraint
schema.max(100); // constraint methods available
}