Aller au contenu principal

isSetConstraint()

isSetConstraint<T>(schema): schema is SetConstraint<T>

Type guard for SetConstraint. Checks that the schema is a set type and has constraint methods.


Type Parameters

T: T extends GenericSchema


Parameters

schema: GenericSchema

The schema to check


Returns: schema is SetConstraint<T>

True if the schema is a SetConstraint with constraint methods


Since

2.0.0


Example

const schema = set(string()).minSize(1);
if (isSetConstraint(schema)) {
// schema is narrowed to SetConstraint
schema.maxSize(10); // constraint methods available
}