Exemplo n.º 1
0
 def get_required_bool_dict_property(properties: dict,
                                     key: str,
                                     required_error=None) -> bool:
     """
     Get the required dictionary value and cast it to 'bool'
     :param properties: dict data
     :param key: key
     :param required_error: error message if parameter is none
     :return: bool object
     """
     value = DictUtils.get_required_dict_property(properties, key,
                                                  required_error)
     status, result = ParseUtils.try_parse_bool(value)
     if status:
         return result
     else:
         raise InvalidParameterError(
             f'Parameter "{key}" could not be converted to a bool')
Exemplo n.º 2
0
    def get_bool_dict_property(properties: dict,
                               key: str,
                               default_value=None) -> bool:
        """
        Get the dictionary value and cast it to 'bool'
        :param properties: dict data
        :param key: key
        :param default_value: default value
        :return: bool object
        """
        value = DictUtils.get_dict_property(properties, key)

        if DictUtils.str_is_null_or_empty(value):
            value = default_value

        status, result = ParseUtils.try_parse_bool(value)
        if status:
            return result
        else:
            raise InvalidParameterError(
                f'Parameter "{key}" could not be converted to a bool')