File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff 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 )
You can’t perform that action at this time.
0 commit comments