hvl_ccb.utils.validation
- validate_and_resolve_host(host: str | IPv4Address | IPv6Address, logger: Logger | None = None) str [source]
- validate_bool(x_name: str, x: object, logger: Logger | None = None) None [source]
Validate if given input x is a bool.
- Parameters:
x_name – string name of the validate input, use for the error message
x – an input object to validate as boolean
logger – logger of the calling submodule
- Raises:
TypeError – when the validated input does not have boolean type
- validate_number(x_name: str, x: object, limits: tuple | None = (None, None), number_type: type[int | float] | tuple[type[int | float], ...] = (<class 'int'>, <class 'float'>), logger: ~logging.Logger | None = None) None [source]
Validate if given input x is a number of given number_type type, with value between given limits[0] and limits[1] (inclusive), if not None. For array-like objects (npt.NDArray, list, tuple, dict) it is checked if all elements are within the limits and have the correct type.
- Parameters:
x_name – string name of the validate input, use for the error message
x – an input object to validate as number of given type within given range
logger – logger of the calling submodule
limits – [lower, upper] limit, with None denoting no limit: [-inf, +inf]
number_type – expected type or tuple of types of a number, by default (int, float)
- Raises:
TypeError – when the validated input does not have expected type
ValueError – when the validated input has correct number type but is not within given range or has wrong input limits