StringConstraints
A field metadata class to apply constraints to str types. Use this class as an annotation via Annotated, as seen below.
Attributes
| Attribute | Type | Description |
|---|---|---|
| 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] |
| ascii_only | `bool | None` = None |
Constructor
Signature
def StringConstraints(
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
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| 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] |
| ascii_only | `bool | None` = None |