diff --git a/pydantic_jsonlogic/__init__.py b/pydantic_jsonlogic/__init__.py index 4575c0d..1fcea7a 100644 --- a/pydantic_jsonlogic/__init__.py +++ b/pydantic_jsonlogic/__init__.py @@ -133,3 +133,9 @@ class In(BaseModel): model_config = ConfigDict(strict=True) in_: tuple[str, list[str] | str] = Field(validation_alias="in") + + +class Cat(BaseModel): + model_config = ConfigDict(strict=True) + + cat: int | str | list[int | str] diff --git a/tests/test_fields.py b/tests/test_fields.py index 69685ba..8a9f94e 100644 --- a/tests/test_fields.py +++ b/tests/test_fields.py @@ -2,6 +2,7 @@ from pydantic_jsonlogic import ( Add, + Cat, Divide, Equals, GreaterThan, @@ -284,3 +285,18 @@ def test_modulo(json: str) -> None: ) def test_in(json: str) -> None: In.model_validate_json(json) + + +@pytest.mark.parametrize( + "json", + [ + '{"cat":"ice"}', + '{"cat":["ice"]}', + '{"cat":["ice","cream"]}', + '{"cat":[1,2]}', + '{"cat":["Robocop",2]}', + '{"cat":["we all scream for ","ice","cream"]}', + ], +) +def test_cat(json: str) -> None: + Cat.model_validate_json(json)