Validators
The otter.validators
package contains tools for validation of tasks, and some
built-in validators.
Module contents
Resource validators.
This module contains the validators for the resources generated by tasks.
- otter.validators.v(func: Callable[[...], bool], *args: Any, **kwargs: Any) None [source]
Validate a resource.
v is the way to run a validator inside of the validate function of a Task. Validators are meant to return a boolean, and v will take care of handling it in a common way.
v will run the validator function passed as first parameter passing any args and kwargs to it.
- Parameters:
func (Callable[..., bool]) – The validator function to run.
- Raises:
StepValidationError – If the validator returns False.
validators.file module
Validators for files.
- otter.validators.file.file_exists(path: Path) bool [source]
Check if a file exists.
- Parameters:
path (Path) – The path to the file.
- Returns:
True if the file exists, False otherwise.
- Return type:
bool
- otter.validators.file.file_size(source: str, destination: Path) bool [source]
Check if the file size of a remote file matches the local file.
- Parameters:
source (str) – The URL of the remote file.
destination (Path) – The path to the local file.
- Returns:
True if the file sizes match, False otherwise.
- Return type:
bool