Skip to content

Commit

Permalink
fix: add exception type in Resource check_all_values validator
Browse files Browse the repository at this point in the history
  • Loading branch information
impocode committed Oct 15, 2022
1 parent bca7ded commit 9d2a125
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions jsonapi_pydantic/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from jsonapi_pydantic import v1_0
from jsonapi_pydantic import constants, v1_0

__version__ = "0.1.1"
__version__ = "0.1.2"

__all__ = ["v1_0"]
__all__ = ["constants", "v1_0"]
6 changes: 3 additions & 3 deletions jsonapi_pydantic/v1_0/resource/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ class Resource(BaseModel):
@root_validator
def check_all_values(cls, values: dict) -> dict:
# More about these restrictions: https://jsonapi.org/format/#document-resource-object-fields
attributes, relationships = values.get("attributes"), values.get("relationships")
try:
attributes, relationships = dict(attributes), dict(relationships)
except ValueError:
attributes = dict(values.get("attributes"))
relationships = dict(values.get("relationships"))
except (ValueError, TypeError):
raise ValueError("Attributes and relationships must be json objects.")

if attributes and (attributes.get("id") or attributes.get("type")):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "jsonapi-pydantic"
version = "0.1.1"
version = "0.1.2"
description = "JSON:API implementation with pydantic."

authors = ["impocode <[email protected]>"]
Expand Down

0 comments on commit 9d2a125

Please sign in to comment.