From 0e3c0b1c2e2bb45836c4e488808152fda106b9ee Mon Sep 17 00:00:00 2001 From: Stephen Crowe <6042774+crowecawcaw@users.noreply.github.com> Date: Wed, 11 Feb 2026 13:55:05 -0800 Subject: [PATCH] fix: allow minLength of 0 for strings and paths Signed-off-by: Stephen Crowe <6042774+crowecawcaw@users.noreply.github.com> --- src/openjd/model/v2023_09/_model.py | 8 ++++---- test/openjd/model/v2023_09/test_job_parameters.py | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) 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"