solidipes.validators.validator module

class solidipes.validators.validator.ValidationResult(validator: Validator, valid: bool, errors: list[str])[source]

Bases: object

Result of a validation, evaluable as a boolean, and containing the list of errors and warnings

errors

List of errors and warnings

class solidipes.validators.validator.Validator(description: str, mandatory: bool = True)[source]

Bases: ABC, Generic[T]

Abstract class for validators

_abc_impl = <_abc._abc_data object>
abstractmethod _validate(obj: T | None = None) bool | Any[source]

Validate an object and optionally return a boolean. Can raise exceptions.

property name
validate(obj: T | None = None) ValidationResult[source]

Validate an object and return a ValidationResult, also catching exceptions

solidipes.validators.validator.add_validation_error(errors: str | list[str])[source]

Add a validation error to the current validation context

solidipes.validators.validator.validator(description: str, mandatory: bool = True) Callable[source]

Decorator to add a Validator class attribute to another class.

The decorated method should return None or a list of strings with the errors. The method can also raise exceptions.