2.7. _string_constraints - Constraint Functions for Constrained String Types
This module implements constraint functions for the listed constrained string types. All types are constrained in length (min and max), RevisionType and VersionType are additionally constrained by a regular expression.
Warning
This module is intended for internal use only.
The following types aliased in the base module are constrained:
- check(value: str, type_name: str, min_length: int = 0, max_length: int | None = None, pattern: Pattern | None = None) None
- constrain_attr(pub_attr_name: str, constraint_check_fn: Callable[[str], None]) Callable[[Type[_T]], Type[_T]]
- create_check_function(min_length: int = 0, max_length: int | None = None, pattern: Pattern | None = None) Callable[[str, str], None]
Returns a new
check_typefunction with mandatorytype_namefor the given min_length, max_length and pattern constraints.This is the type-independent alternative to
check_content_type(),check_identifier(), etc. It is used for the definition of theConstrainedLangStringSets, as a “Basic” constrained string type only exists forMultiLanguageNameType, where all values areShortNames. All other:class:`ConstrainedLangStringSetsuse custom constraints.
- class _T
alias of TypeVar(‘_T’)