diff --git a/lib/galaxy/tool_util/parameters/__init__.py b/lib/galaxy/tool_util/parameters/__init__.py index eafe4af34b98..ffd307f98e78 100644 --- a/lib/galaxy/tool_util/parameters/__init__.py +++ b/lib/galaxy/tool_util/parameters/__init__.py @@ -58,6 +58,7 @@ flat_state_path, keys_starting_with, repeat_inputs_to_array, + validate_explicit_conditional_test_value, visit_input_values, ) @@ -100,6 +101,7 @@ "validate_test_case", "validate_workflow_step", "validate_workflow_step_linked", + "validate_explicit_conditional_test_value", "ToolState", "TestCaseToolState", "ToolParameterT", diff --git a/lib/galaxy/tool_util/parameters/visitor.py b/lib/galaxy/tool_util/parameters/visitor.py index 9e411c050d54..363dd9298bc0 100644 --- a/lib/galaxy/tool_util/parameters/visitor.py +++ b/lib/galaxy/tool_util/parameters/visitor.py @@ -105,3 +105,9 @@ def repeat_inputs_to_array(flat_state_path: str, inputs: Dict[str, KVT]) -> List except ValueError: continue return params + + +def validate_explicit_conditional_test_value(test_parameter_name: str, value: Any) -> Optional[Union[str, bool]]: + if value is not None and not isinstance(value, (str, bool)): + raise Exception(f"Invalid conditional test value ({value}) for parameter ({test_parameter_name})") + return cast(Optional[Union[str, bool]], value)