bagof.validators.collections
Validators for collection types (list, tuple, dict, etc.).
Classes
IsIterable
Validator for abc.Iterable.
Note
When parameterized (e.g. Iterable[int]), each element is
validated against the argument type. This requires the value
to be an abc.Sequence (e.g. a list), since a one-shot
iterator or generator cannot be safely re-validated; a bare
generator raises a TypeValidationError in that case.
IsSequence
IsMapping
IsTupleIsh
IsTuple
IsDict
IsTypedDict
HasLength
Bases: IsSequence[ITERABLE]
Validator for abc.Sequence, that checks its length.
Note
This validator is not registered by default, so it is only used
when instantiated explicitly, e.g. HasLength(3).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
length
|
int
|
The expected length of the sequence. |
required |
hint
|
Any
|
The type hint to validate against. |
UNSET
|
compose
|
bool
|
Whether to compose this validator with others, when they are
found in |
False
|