bagof.validators.common
Common validators (any, union, etc.)
Classes
IsLiteral
IsTypeVar
IsAnnotated
Validator for Annotated.
Note
Annotated validators look for validators in the metadata of an annotated type hint and apply them in order (if they are composable).
Methods:
register_metadata
classmethod
Decorator to register a validator class for one or more
Annotated metadata hints (e.g. re.Pattern).
Distinct from Validator.register, which registers a
validator for a type hint in the global registry; this one
registers it for a piece of Annotated metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*hints
|
Unpack[tuple[Any, ...]]
|
One or more metadata hints to register the validator class for. |
()
|
Returns:
| Type | Description |
|---|---|
ClassDecorator
|
A decorator that registers the validator class for the given metadata hints. |