diff --git a/lib/galaxy/tools/parameters/validation.py b/lib/galaxy/tools/parameters/validation.py index 143b1c187029..cf02d86c56b5 100644 --- a/lib/galaxy/tools/parameters/validation.py +++ b/lib/galaxy/tools/parameters/validation.py @@ -186,7 +186,9 @@ def __init__(self, message, length_min, length_max, negate): super().__init__(message, range_min=length_min, range_max=length_max, negate=negate) def validate(self, value, trans=None): - super().validate(len(value), trans) + if value is None: + raise ValueError("No value provided") + super().validate(len(value) if value else 0, trans) class DatasetOkValidator(Validator): diff --git a/test/unit/app/tools/test_parameter_validation.py b/test/unit/app/tools/test_parameter_validation.py index 2e0bf0ffe857..bddb0e325309 100644 --- a/test/unit/app/tools/test_parameter_validation.py +++ b/test/unit/app/tools/test_parameter_validation.py @@ -186,6 +186,14 @@ def test_LengthValidator(self): p.validate("bar") p.validate("f") p.validate("foobarbaz") + p = self._parameter_for( + xml=""" + + +""" + ) + with self.assertRaisesRegex(ValueError, "No value provided"): + p.validate(None) def test_InRangeValidator(self): p = self._parameter_for(