diff --git a/src/openjd/model/v2023_09/_model.py b/src/openjd/model/v2023_09/_model.py index 1255017c..6ad0a86a 100644 --- a/src/openjd/model/v2023_09/_model.py +++ b/src/openjd/model/v2023_09/_model.py @@ -1363,8 +1363,8 @@ class JobStringParameterDefinition(OpenJDModel_v2023_09, JobParameterInterface): def _validate_min_length(cls, value: Optional[int]) -> Optional[int]: if value is None: return value - if value <= 0: - raise ValueError("Required: 0 < minLength.") + if value < 0: + raise ValueError("Required: 0 <= minLength.") return value @field_validator("maxLength") @@ -1607,8 +1607,8 @@ class JobPathParameterDefinition(OpenJDModel_v2023_09, JobParameterInterface): def _validate_min_length(cls, value: Optional[int]) -> Optional[int]: if value is None: return value - if value <= 0: - raise ValueError("Required: 0 < minLength.") + if value < 0: + raise ValueError("Required: 0 <= minLength.") return value @field_validator("maxLength") diff --git a/test/openjd/model/v2023_09/test_job_parameters.py b/test/openjd/model/v2023_09/test_job_parameters.py index cc8bf96b..5adacfe6 100644 --- a/test/openjd/model/v2023_09/test_job_parameters.py +++ b/test/openjd/model/v2023_09/test_job_parameters.py @@ -26,9 +26,7 @@ class TestJobStringParameterDefinition: pytest.param( {"name": "Foo", "type": "STRING", "default": "some value"}, id="has default" ), - pytest.param( - {"name": "Foo", "type": "STRING", "minLength": 1}, id="smallest min length" - ), + pytest.param({"name": "Foo", "type": "STRING", "minLength": 0}, id="minLength zero"), pytest.param( {"name": "Foo", "type": "STRING", "maxLength": 1}, id="smallest max length" ), @@ -215,7 +213,9 @@ def test_parse_success(self, data: dict[str, Any]) -> None: id="allowedValues item not string", ), # - pytest.param({"name": "Foo", "type": "STRING", "minLength": 0}, id="0 < min"), + pytest.param( + {"name": "Foo", "type": "STRING", "minLength": -1}, id="negative minLength" + ), pytest.param({"name": "Foo", "type": "STRING", "maxLength": 0}, id="0 < max"), pytest.param( {"name": "Foo", "type": "STRING", "minLength": 2, "maxLength": 1}, id="min > max" @@ -495,7 +495,7 @@ class TestJobPathParameterDefinition: pytest.param( {"name": "Foo", "type": "PATH", "default": "some value"}, id="has default" ), - pytest.param({"name": "Foo", "type": "PATH", "minLength": 1}, id="smallest min length"), + pytest.param({"name": "Foo", "type": "PATH", "minLength": 0}, id="minLength zero"), pytest.param({"name": "Foo", "type": "PATH", "maxLength": 1}, id="smallest max length"), pytest.param( {"name": "Foo", "type": "PATH", "allowedValues": ["a"]}, id="has allowedValues" @@ -709,7 +709,7 @@ def test_parse_success(self, data: dict[str, Any]) -> None: id="allowedValues item not string", ), # - pytest.param({"name": "Foo", "type": "PATH", "minLength": 0}, id="0 < min"), + pytest.param({"name": "Foo", "type": "PATH", "minLength": -1}, id="negative minLength"), pytest.param({"name": "Foo", "type": "PATH", "maxLength": 0}, id="0 < max"), pytest.param( {"name": "Foo", "type": "PATH", "minLength": 2, "maxLength": 1}, id="min > max"