diff --git a/src/immoney/_pydantic.py b/src/immoney/_pydantic.py index 8aabce1..90312ba 100644 --- a/src/immoney/_pydantic.py +++ b/src/immoney/_pydantic.py @@ -254,7 +254,7 @@ def schema(currency_schema: core_schema.CoreSchema) -> core_schema.CoreSchema: wrapped=core_schema.typed_dict_schema( { "overdraft_subunits": core_schema.typed_dict_field( - core_schema.int_schema(gt=0), + core_schema.int_schema(ge=0), required=True, ), "currency": core_schema.typed_dict_field( diff --git a/tests/test_pydantic.py b/tests/test_pydantic.py index b0e89ae..f54bca4 100644 --- a/tests/test_pydantic.py +++ b/tests/test_pydantic.py @@ -681,14 +681,14 @@ def test_can_roundtrip_valid_data( assert instance.overdraft == expected assert json.loads(instance.model_dump_json()) == data - @pytest.mark.parametrize("value", (0, -1, -1024)) - def test_parsing_raises_validation_error_for_non_positive_value( + @pytest.mark.parametrize("value", (-1, -1024)) + def test_parsing_raises_validation_error_for_negative_value( self, value: int, ) -> None: with pytest.raises( ValidationError, - match=r"Input should be greater than 0", + match=r"Input should be greater than or equal to 0", ): DefaultOverdraftModel.model_validate( { @@ -736,7 +736,7 @@ def test_can_generate_schema(self) -> None: "overdraft_subunits": { "title": "Overdraft Subunits", "type": "integer", - "exclusiveMinimum": 0, + "minimum": 0, }, }, "required": sorted_items_equal(["overdraft_subunits", "currency"]), @@ -806,7 +806,7 @@ def test_can_generate_schema(self) -> None: "overdraft_subunits": { "title": "Overdraft Subunits", "type": "integer", - "exclusiveMinimum": 0, + "minimum": 0, }, }, "required": sorted_items_equal(["overdraft_subunits", "currency"]), @@ -872,7 +872,7 @@ def test_can_generate_schema(self) -> None: "overdraft_subunits": { "title": "Overdraft Subunits", "type": "integer", - "exclusiveMinimum": 0, + "minimum": 0, }, }, "required": sorted_items_equal(["overdraft_subunits", "currency"]),