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 class for value coercion/validation. |
|
|
Logical AND for constraints. |
|
Logical OR for constraints. |
A constraint that represents no constraints |
|
|
Constraint that wraps another constraint and replaces its description |
|
Exception type raised by constraints when their conditions are violated |
|
Exception type raised on violating any command parameter constraints |
|
Representation of a parameter constraint context |
|
Ensure an absent/present Dataset from any path or Dataset instance |
|
Utility class to report an original and resolve dataset parameter value |
Ensure that an input is a bool. |
|
Ensure an input is a callable object |
|
|
Ensure an input is element of a set of possible values |
Ensure that an input (or several inputs) are of a data type 'float'. |
|
Ensure an input matches a name of a |
|
|
Ensure that an input (or several inputs) are of a particular data type. |
Ensure that an input (or several inputs) are of a data type 'int'. |
|
|
Ensure value under a key in an input is in a set of possible values |
Ensure an input is of value None |
|
|
Ensures input is convertible to a (platform) path and returns a Path |
|
Ensure an input is a string of some min. |
|
Ensure an input is a string that starts with a given prefix. |
|
Ensure an input is within a particular range |
|
Ensure an input is a particular value |
|
Ensure that an input is a list of a particular data type |
|
|
|
|
|
Ensure a mapping of a key to a value of a specific nature |
|
Ensure a constraint for each item read from a file-like. |
Ensures that string is JSON formatted and can be deserialized. |
|
|
Ensures that a string is a valid URL with a select set of components |
|
Like EnsureURL, but returns a parsed URL |
|
Ensures that a reference name is well formed |
|
Ensures a valid remote name, and optionally if such a remote is known |
|
Identical to |
|
Base class for ValidatedInterface parameter validators |