Skip to content

Commit

Permalink
assert format of additional_metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
sblack-usu committed Sep 16, 2021
1 parent 2cfdf5a commit 16f7c53
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions hsmodels/schemas/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ def normalize_additional_metadata(cls, value):
if isinstance(value, list):
as_dict = {}
for val in value:
if not isinstance(val, dict):
raise ValueError(f"List entry {val} must be a dict")
if "key" not in val:
raise ValueError(f"Missing the 'key' key in {val}")
if "value" not in val:
raise ValueError(f"Missing the 'value' key in {val}")
if val["key"] in as_dict:
raise ValueError(f"Found a duplicate key {val['key']}")
as_dict[val["key"]] = val["value"]
Expand Down

0 comments on commit 16f7c53

Please sign in to comment.