Skip to main content

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
}