Aller au contenu principal

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
}