Skip to content

Commit

Permalink
Add "in" model
Browse files Browse the repository at this point in the history
  • Loading branch information
4c0n committed Aug 27, 2024
1 parent b704933 commit ce88ee3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pydantic_jsonlogic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,9 @@ class Modulo(BaseModel):
model_config = ConfigDict(strict=True)

modulo: tuple[int, int] = Field(validation_alias="%")


class In(BaseModel):
model_config = ConfigDict(strict=True)

in_: tuple[str, list[str] | str] = Field(validation_alias="in")
12 changes: 12 additions & 0 deletions tests/test_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
Equals,
GreaterThan,
GreaterThanOrEqual,
In,
LessThan,
LessThanOrEqual,
Max,
Expand Down Expand Up @@ -272,3 +273,14 @@ def test_divide(json: str) -> None:
)
def test_modulo(json: str) -> None:
Modulo.model_validate_json(json)


@pytest.mark.parametrize(
"json",
[
'{"in":["Bart",["Bart","Homer","Lisa","Marge","Maggie"]]}',
'{"in":["i","team"]}',
],
)
def test_in(json: str) -> None:
In.model_validate_json(json)

0 comments on commit ce88ee3

Please sign in to comment.