Skip to content

Commit f74857b

Browse files
committed
fix: fix checking keys in TopLevel model
1 parent 20a2ace commit f74857b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

jsonapi_pydantic/v1_0/toplevel.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ class TopLevel(BaseModel):
3838
@model_validator(mode="before")
3939
def check_all_values(cls, data: dict) -> dict:
4040
# More about these restrictions: https://jsonapi.org/format/#document-top-level
41-
if data.get("data") and data.get("errors"):
41+
if "data" in data and "errors" in data:
4242
raise ValueError("The members data and errors MUST NOT coexist in the same document.")
43-
if data.get("included") and not data.get("data"):
43+
if "included" in data and "data" not in data:
4444
raise ValueError(
4545
"If a document does not contain a top-level data key, the included member MUST NOT be present either."
4646
)
47-
if not data.get("data") and not data.get("errors") and not data.get("meta"):
47+
if "data" not in data and "errors" not in data and "meta" not in data:
4848
raise ValueError(
4949
"A document MUST contain at least one of the following top-level members: data, errors, meta."
5050
)

0 commit comments

Comments
 (0)