Skip to content

Commit

Permalink
jsonschema_validation: Add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jarofgreen committed Nov 10, 2022
1 parent b4d46a8 commit 93ade9f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cove_ofds/jsonschema_validation_errors.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# This function may be a candidate to move to libcoveofds?
# It could do with some testing, wherever it ends up
def add_type_to_json_schema_validation_error(data: dict) -> dict:

if data["validator"] == "prefixItems":
Expand All @@ -12,6 +14,8 @@ def add_type_to_json_schema_validation_error(data: dict) -> dict:
elif data["validator"] == "uniqueItems":
data["cove_type"] = "Nonuniqueitems"

# these 2 pattern checks are brittle
# using instance is not a great choice as that may easily change if the schema changes. TODO
elif data["validator"] == "pattern" and data["instance"] in [
"properties",
"features",
Expand Down Expand Up @@ -66,7 +70,7 @@ def add_type_to_json_schema_validation_error(data: dict) -> dict:
else:
data["cove_type"] = "unknown"

# TODO this should be in lib
# TODO this should be in libcoveofds
data["path_no_num"] = tuple(key for key in data["path"] if isinstance(key, str))

return data

0 comments on commit 93ade9f

Please sign in to comment.