Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/openjd/model/v2023_09/_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down
12 changes: 6 additions & 6 deletions test/openjd/model/v2023_09/test_job_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
),
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
Loading