diff --git a/src/caoscrawler/transformer_functions.py b/src/caoscrawler/transformer_functions.py index 03f017b12dc0fe9ffdbab452433e1e961eb74b55..117d0b021d4ec0b0efc79c5db0d7ed397207933f 100644 --- a/src/caoscrawler/transformer_functions.py +++ b/src/caoscrawler/transformer_functions.py @@ -127,11 +127,20 @@ def cast_to_bool(in_value: Any, params: dict) -> bool: """ Cast the `in_value` to bool. + This is done by comparing `in_value` to "True". + Only "true", "True", "False" and "false" are accepted as possible values. + All other input values raise an error. + Parameters ========== No parameters. """ - return bool(in_value) + val = str(in_value).lower() + if val == "true": + return True + if val == "false": + return False + raise ValueError("Invalid value for type cast to bool: {}".format(in_value)) def cast_to_str(in_value: Any, params: dict) -> str: