Skip to content

Commit

Permalink
jsonschema_validation: Add additional properties UI
Browse files Browse the repository at this point in the history
#99

0.8.3 of libcoveofds needed for this
  • Loading branch information
odscjames committed Jun 28, 2023
1 parent 0eb06e6 commit 23e7d7d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cove_ofds/jsonschema_validation_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ def add_type_to_json_schema_validation_error(data: dict) -> dict:
elif data["validator"] == "minProperties":
data["cove_type"] = "Emptyobject"

elif data["validator"] == "additionalProperties":
data["cove_type"] = "Additionalproperties"

elif data["validator"] == "format" and data["validator_value"] == "date":
data["cove_type"] = "Incorrectlyformatteddate"

Expand Down
12 changes: 12 additions & 0 deletions cove_ofds/templates/cove_ofds/jsonschema_validation_panel.html
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,18 @@ <h4 class="validation-title">
{% include "cove_ofds/jsonschema_validation_table.html" with validation_errors_for_table=validation_errors.Incorrectlyformatteduuid col_instance=True error_table_id="Incorrectlyformatteduuid" %}
{% endif %}

{% if 'Additionalproperties' in validation_errors %}
<h4 class="validation-title">
{% trans 'Additional properties within Geometry object' %}
{% include 'cove_ofds/jsonschema_validation_table_error_counter.html' with count=validation_errors.Additionalproperties|length error_table_id="Additionalproperties" %}
</h4>
<p>
Additional properties are not permitted within Geometry objects. You must remove any additional properties.
For more information, see <a href="https://open-fibre-data-standard.readthedocs.io/en/latest/reference/schema.html#geometry" target="_blank">Geometry</a>.
</p>
{% include "cove_ofds/jsonschema_validation_table.html" with validation_errors_for_table=validation_errors.Additionalproperties error_table_id="Additionalproperties" col_extra_additional_properties=True %}
{% endif %}


{% if 'unknown' in validation_errors %}
<h4 class="validation-title">
Expand Down
10 changes: 10 additions & 0 deletions cove_ofds/templates/cove_ofds/jsonschema_validation_table.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
{% if col_validator_value %}
<th>{{ col_validator_value_label }}</Th>
{% endif %}
{% if col_extra_additional_properties %}
<th>{% trans 'Additional properties' %}</th>
{% endif %}
</tr>
</thead>
<tbody>
Expand Down Expand Up @@ -46,6 +49,13 @@
{% include "libcoveweb2/show_json_value.html" with value=error.validator_value %}
</td>
{% endif %}
{% if col_extra_additional_properties %}
<td>
{% for a_p in error.extra.additional_properties %}
<div>{{ a_p }}</div>
{% endfor %}
</td>
{% endif %}
</tr>
{% endfor %}
</tbody>
Expand Down

0 comments on commit 23e7d7d

Please sign in to comment.