datalad_next.constraints
Data validation, coercion, and parameter documentation
This module provides a set of uniform classes to validate and document
particular aspects of inputs. In a nutshell, each of these
Constraint
class:
focuses on a specific aspect, such as data type coercion, or checking particular input properties
is instantiated with a set of parameters to customize such an instance for a particular task
performs its task by receiving an input via its
__call__()
methodprovides default auto-documentation that can be customized by wrapping an instance in
WithDescription
Individual Constraint
instances can be combined with logical AND
(AllOf
) and OR
(AnyOf
) operations to form arbitrarily
complex constructs.
On (validation/coercion) error, instances raise
ConstraintError
) via their
raise_for()
method. This approach to error reporting helps to communicate
standard (yet customizable) error messages, aids structured error reporting,
and is capable of communication the underlying causes of an error in full
detail without the need to generate long textual descriptions.
EnsureCommandParameterization
is a
particular variant of a Constraint
that is capable of validating a complete
parameterization of a command (or function), for each parameter individually,
and for arbitrary combinations of parameters. It puts a particular emphasis on
structured error reporting.
Base classes for constraints and their logical connectives |
|
Basic constraints for declaring essential data types, values, and ranges |
|
Constraints that wrap or contain other constraints |
|
Constraints for particular formats or protocols |
|
Constraints for command/function parameters |
|
Constraints for Git-related concepts and parameters |
|
Constraints for DataLad datasets |
|
Custom exceptions raised by |