BaseAttributeValidation
- class dtaianomaly.type_validation.BaseAttributeValidation[source]
Base class for Attribute validation.
This abstract class offers the base functionality to check if a value is valid according to some rules. These rules are defined within the implementing classes. The
BaseAttributeValidationchecks both the type and value for some attribute, and raises a human-readable error message if anything is wrong.- raise_error_if_invalid(value, name: str, class_name: str) None[source]
Raise an error if the given value is invalid.
Check if the type and the exact value are permitted, according to the rules of this attribute validation. If either the type or the value is invalid, an error is raised accordingly. Otherwise, nothing happens.
- Parameters:
- valueany
The value to verify.
- namestr
The name of the attribute that is being checked. Used for generating clear error messages, if needed.
- class_namestr
The name of the class to which the attribute belongs. Used for generating clear error messages, if needed.
- Raises:
- TypeError
If the type of the given value is invalid according to the rules of this BaseAttributeValidation.
- ValueError
If the value of the given value is invalid according to the rules of this BaseAttributeValidation.