hvl_ccb.utils.validation

validate_and_resolve_host(host: Union[str, IPv4Address, IPv6Address], logger: Optional[Logger] = None) str[source]
validate_bool(x_name: str, x: object, logger: Optional[Logger] = 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: ~typing.Optional[~typing.Tuple] = (None, None), number_type: ~typing.Union[~typing.Type[~typing.Union[int, float]], ~typing.Tuple[~typing.Type[~typing.Union[int, float]], ...]] = (<class 'int'>, <class 'float'>), logger: ~typing.Optional[~logging.Logger] = 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

validate_tcp_port(port: int, logger: Optional[Logger] = None)[source]