Skip to content

bagof.validators.common

Common validators (any, union, etc.)

Classes

IsAny

IsAny(hint: Any = UNSET, compose: bool = False)

Bases: Validator[T]

Validator for Any.

IsNone

IsNone(hint: Any = UNSET, compose: bool = False)

Bases: Validator[NONE]

Validator for None.

IsUnion

IsUnion(*a, **k)

Bases: Validator[T]

Validator for Union.

IsLiteral

IsLiteral(hint: Any = UNSET, compose: bool = False)

Bases: Validator[T]

Validator for Literal.

IsTypeVar

IsTypeVar(hint: Any = UNSET, compose: bool = False)

Bases: Validator[T]

Validator for TypeVar.

IsAnnotated

IsAnnotated(hint: Any = UNSET, compose: bool = False)

Bases: Validator[T]

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 classmethod
register(*hints: Unpack[tuple[Any]]) -> ClassDecorator

Decorator to register a validator class for one or more Annotated metadata hints (e.g. re.Pattern).

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.