Skip to main content

constr

A wrapper around str that allows for additional constraints.

def constr(
strip_whitespace: bool | None = None,
to_upper: bool | None = None,
to_lower: bool | None = None,
strict: bool | None = None,
min_length: int | None = None,
max_length: int | None = None,
pattern: str | Pattern[str] | None = None,
ascii_only: bool | None = None
) - > type[str]

A wrapper around str that allows for additional constraints.

Parameters

NameTypeDescription
strip_whitespace`boolNone` = None
to_upper`boolNone` = None
to_lower`boolNone` = None
strict`boolNone` = None
min_length`intNone` = None
max_length`intNone` = None
pattern`strPattern[str]
ascii_only`boolNone` = None

Returns

TypeDescription
type[str]The wrapped string type.