Skip to content

Commit

Permalink
jsonschema_validation: Show/Hide links
Browse files Browse the repository at this point in the history
  • Loading branch information
odscjames committed Nov 18, 2022
1 parent 043df78 commit d19b160
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 62 deletions.
40 changes: 20 additions & 20 deletions cove_ofds/templates/cove_ofds/jsonschema_validation_panel.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,55 +3,55 @@
{% if 'Valuedoesnotmatchconstant' in validation_errors %}
<h4>{% trans 'Value does not match constant' %}</h4>
<p>You must update each value to match the constant specified in the schema.</p>
{% include "cove_ofds/jsonschema_validation_table.html" with validation_errors_for_table=validation_errors.Valuedoesnotmatchconstant col_instance=True col_validator_value=True col_validator_value_label="Constant" %}
{% include "cove_ofds/jsonschema_validation_table.html" with validation_errors_for_table=validation_errors.Valuedoesnotmatchconstant col_instance=True col_validator_value=True col_validator_value_label="Constant" error_table_id="Valuedoesnotmatchconstant" %}
{% endif %}


{% if 'prefixItems' in validation_errors %}
<h4>{% trans 'Empty array' %}</h4>
<p>You must omit empty arrays from your data in their entirety (key and value).</p>
{% include "cove_ofds/jsonschema_validation_table.html" with validation_errors_for_table=validation_errors.Emptyarray col_instance=True %}
{% include "cove_ofds/jsonschema_validation_table.html" with validation_errors_for_table=validation_errors.Emptyarray col_instance=True error_table_id="Emptyarray" %}
{% endif %}


{% if 'Nonuniqueitems' in validation_errors %}
<h4>{% trans 'Non-unique items' %}</h4>
<p>You must ensure that the items in each array are unique.</p>
{% include "cove_ofds/jsonschema_validation_table.html" with validation_errors_for_table=validation_errors.Nonuniqueitems col_instance=True %}
{% include "cove_ofds/jsonschema_validation_table.html" with validation_errors_for_table=validation_errors.Nonuniqueitems col_instance=True error_table_id="Nonuniqueitems" %}
{% endif %}


{% if 'Fieldnamedoesnotmatchpattern' in validation_errors %}
<h4>{% trans 'Field name does not match pattern' %}</h4>
<p>You must ensure that fields in `Node.location` and `Span.route` are not named 'properties' or 'nodes'.</p>
{% include "cove_ofds/jsonschema_validation_table.html" with validation_errors_for_table=validation_errors.Fieldnamedoesnotmatchpattern %}
{% include "cove_ofds/jsonschema_validation_table.html" with validation_errors_for_table=validation_errors.Fieldnamedoesnotmatchpattern error_table_id="Fieldnamedoesnotmatchpattern" %}
{% endif %}

{% if 'Valuedoesnotmatchpattern' in validation_errors %}
<h4>{% trans 'Value does not match pattern' %}</h4>
<p>You must ensure that only the first item in the `links` array has `.rel` set to 'describedBy`.</p>
{% include "cove_ofds/jsonschema_validation_table.html" with validation_errors_for_table=validation_errors.Fieldnamedoesnotmatchpattern col_instance=True %}
{% include "cove_ofds/jsonschema_validation_table.html" with validation_errors_for_table=validation_errors.Fieldnamedoesnotmatchpattern col_instance=True error_table_id="Fieldnamedoesnotmatchpattern" %}
{% endif %}


{% if 'Emptystring' in validation_errors %}
<h4>{% trans 'Empty string' %}</h4>
<p>You must omit empty strings from your data in their entirety (key and value).</p>
{% include "cove_ofds/jsonschema_validation_table.html" with validation_errors_for_table=validation_errors.Emptystring col_instance=True %}
{% include "cove_ofds/jsonschema_validation_table.html" with validation_errors_for_table=validation_errors.Emptystring col_instance=True error_table_id="Emptystring" %}
{% endif %}


{% if 'Valuedoesnotmatchanycodes' in validation_errors %}
<h4>{% trans 'Value does not match any codes.' %}</h4>
<p>You must update each value to match a code from the codelist specified in the schema.</p>
{% include "cove_ofds/jsonschema_validation_table.html" with validation_errors_for_table=validation_errors.Valuedoesnotmatchanycodes col_instance=Trues col_validator_value=True col_validator_value_label="Codelist" %}
{% include "cove_ofds/jsonschema_validation_table.html" with validation_errors_for_table=validation_errors.Valuedoesnotmatchanycodes col_instance=Trues col_validator_value=True col_validator_value_label="Codelist" error_table_id="Valuedoesnotmatchanycodes" %}
{% endif %}


{% if 'Valueisnotaboolean' in validation_errors %}
<h4>{% trans 'Value is not a boolean' %}</h4>
<p>You must ensure that each value is either `true` or `false`. You should check that values are not enclosed in qoute characters (`"`).</p>
{% include "cove_ofds/jsonschema_validation_table.html" with validation_errors_for_table=validation_errors.Valueisnotaboolean col_instance=True %}
{% include "cove_ofds/jsonschema_validation_table.html" with validation_errors_for_table=validation_errors.Valueisnotaboolean col_instance=True error_table_id="Valueisnotaboolean" %}
{% endif %}


Expand All @@ -61,70 +61,70 @@ <h4>{% trans 'Value is not an integer' %}</h4>
You must ensure that each value contains only digits (`0-9`) and, optionally, the dot character (`.`). Integer values must have either no fractional part (e.g. `1`) or a zero fractional part (e.g. `1.0`).
You should check that values are not enclosed in quote characters, e.g. `1` is an integer, but `"1"` is a string.
</p>
{% include "cove_ofds/jsonschema_validation_table.html" with validation_errors_for_table=validation_errors.Valueisnotaninteger col_instance=True %}
{% include "cove_ofds/jsonschema_validation_table.html" with validation_errors_for_table=validation_errors.Valueisnotaninteger col_instance=True error_table_id="Valueisnotaninteger" %}
{% endif %}


{% if 'Valueisnotanumber' in validation_errors %}
<h4>{% trans 'Value is not a number' %}</h4>
<p>You must ensure that each value contains only digits (`0-9`) and, optionally, the dot character (`.`). You should check that values are not enclosed in quote characters, e.g. `1` is an integer, but `"1"` is a string.</p>
{% include "cove_ofds/jsonschema_validation_table.html" with validation_errors_for_table=validation_errors.Valueisnotanumber col_instance=True %}
{% include "cove_ofds/jsonschema_validation_table.html" with validation_errors_for_table=validation_errors.Valueisnotanumber col_instance=True error_table_id="Valueisnotanumber" %}
{% endif %}


{% if 'Valueisnotastring' in validation_errors %}
<h4>{% trans 'Value is not a string' %}</h4>
<p>You must ensure that each value begins and ends with the quote character (`"`) and that any quotes within the value are escaped with a backslash (`\`).</p>
{% include "cove_ofds/jsonschema_validation_table.html" with validation_errors_for_table=validation_errors.Valueisnotastring col_instance=True %}
{% include "cove_ofds/jsonschema_validation_table.html" with validation_errors_for_table=validation_errors.Valueisnotastring col_instance=True error_table_id="Valueisnotastring" %}
{% endif %}


{% if 'Valueisnotanobject' in validation_errors %}
<h4>{% trans 'Value is not an object' %}</h4>
<p>You must ensure that each value is enclosed in curly braces (`{` and `}`) and contains only key/value pairs.</p>
{% include "cove_ofds/jsonschema_validation_table.html" with validation_errors_for_table=validation_errors.Valueisnotanobject col_instance=True %}
{% include "cove_ofds/jsonschema_validation_table.html" with validation_errors_for_table=validation_errors.Valueisnotanobject col_instance=True error_table_id="Valueisnotanobject" %}
{% endif %}


{% if 'Valueisnotanarray' in validation_errors %}
<h4>{% trans 'Value is not an array' %}</h4>
<p>You must ensure that each value is enclosed in square brackets (`[` and `]`).</p>
{% include "cove_ofds/jsonschema_validation_table.html" with validation_errors_for_table=validation_errors.Valueisnotanarray col_instance=True %}
{% include "cove_ofds/jsonschema_validation_table.html" with validation_errors_for_table=validation_errors.Valueisnotanarray col_instance=True error_table_id="Valueisnotanarray" %}
{% endif %}


{% if 'Missingrequiredfields' in validation_errors %}
<h4>{% trans 'Missing required fields' %}</h4>
<p>You must ensure that your data contains the required fields specified in the schema.</p>
{% include "cove_ofds/jsonschema_validation_table.html" with validation_errors_for_table=validation_errors.Missingrequiredfields col_instance=True %}
{% include "cove_ofds/jsonschema_validation_table.html" with validation_errors_for_table=validation_errors.Missingrequiredfields col_instance=True error_table_id="Missingrequiredfields" %}
{% endif %}


{% if 'Emptyobject' in validation_errors %}
<h4>{% trans 'Empty object' %}</h4>
<p>You must omit empty objects from your data in their entirety (key and value).</p>
{% include "cove_ofds/jsonschema_validation_table.html" with validation_errors_for_table=validation_errors.Emptyobject col_instance=True %}
{% include "cove_ofds/jsonschema_validation_table.html" with validation_errors_for_table=validation_errors.Emptyobject col_instance=True error_table_id="Emptyobject" %}
{% endif %}


{% if 'Incorrectlyformatteddate' in validation_errors %}
<h4>{% trans 'Incorrectly formatted date' %}</h4>
<p>You must ensure that each date is in `"YYYY-MM-DD"` format.</p>
{% include "cove_ofds/jsonschema_validation_table.html" with validation_errors_for_table=validation_errors.Incorrectlyformatteddate col_instance=True %}
{% include "cove_ofds/jsonschema_validation_table.html" with validation_errors_for_table=validation_errors.Incorrectlyformatteddate col_instance=True error_table_id="Incorrectlyformatteddate" %}
{% endif %}


{% if 'Incorrectlyformattediri' in validation_errors %}
<h4>{% trans 'Incorrectly formatted iri' %}</h4>
<p>You must ensure that each iri is formatted according to <a href="https://www.rfc-editor.org/rfc/rfc3987" target="_blank">RFC3897</a>.</p>
{% include "cove_ofds/jsonschema_validation_table.html" with validation_errors_for_table=validation_errors.Incorrectlyformattediri col_instance=True %}
{% include "cove_ofds/jsonschema_validation_table.html" with validation_errors_for_table=validation_errors.Incorrectlyformattediri col_instance=True error_table_id="Incorrectlyformattediri" %}
{% endif %}


{% if 'Incorrectlyformatteduri' in validation_errors %}
<h4>{% trans 'Incorrectly formatted uri' %}</h4>
<p>You must ensure that each uri is formatted according to <a href="https://www.rfc-editor.org/rfc/rfc3986" target="_blank">RFC3896</a>.</p>
{% include "cove_ofds/jsonschema_validation_table.html" with validation_errors_for_table=validation_errors.Incorrectlyformatteduri col_instance=True %}
{% include "cove_ofds/jsonschema_validation_table.html" with validation_errors_for_table=validation_errors.Incorrectlyformatteduri col_instance=True error_table_id="Incorrectlyformatteduri" %}
{% endif %}


Expand All @@ -134,11 +134,11 @@ <h4>{% trans 'Incorrectly formatted uuid' %}</h4>
You must ensure that each uuid is formatted according to <a href="https://datatracker.ietf.org/doc/html/rfc4122" target="_blank">RFC4122</a>.
For more information, see <a href="https://open-fibre-data-standard.readthedocs.io/en/latest/guidance/publication.html#how-to-generate-universally-unique-identifiers" target="_blank">how to generate universally unique identifiers</a>.
</p>
{% include "cove_ofds/jsonschema_validation_table.html" with validation_errors_for_table=validation_errors.Incorrectlyformatteduuid col_instance=True %}
{% include "cove_ofds/jsonschema_validation_table.html" with validation_errors_for_table=validation_errors.Incorrectlyformatteduuid col_instance=True error_table_id="Incorrectlyformatteduuid" %}
{% endif %}


{% if 'unknown' in validation_errors %}
<h4>{% trans 'unknown' %}</h4>
{% include "cove_ofds/jsonschema_validation_table.html" with validation_errors_for_table=validation_errors.unknown %}
{% include "cove_ofds/jsonschema_validation_table.html" with validation_errors_for_table=validation_errors.unknown error_table_id="unknown" %}
{% endif %}
93 changes: 51 additions & 42 deletions cove_ofds/templates/cove_ofds/jsonschema_validation_table.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,60 @@
{% load cove_tags %}
{% load ofds_cove_tags %}

<table class="table table-condensed">
<thead>
<tr>
<th>{% trans 'Identifiers' %}</th>
<th>{% trans 'Path' %}</th>
{% if col_instance %}
<th>{% trans 'Value' %}</Th>
{% endif %}
{% if col_validator_value %}
<th>{{ col_validator_value_label }}</Th>
{% endif %}
</tr>
</thead>
<tbody>
{% for error in validation_errors_for_table %}

<div style="text-align: right;">
<button class="btn btn-primary" type="button" data-toggle="collapse" data-target="#validation_error_details_{{ error_table_id }}" aria-expanded="false" aria-controls="validation_error_details_{{ error_table_id }}">
Show/Hide errors
</button>
</div>

<div class="collapse" id="validation_error_details_{{ error_table_id }}">
<table class="table table-condensed">
<thead>
<tr>
<td>
{% if error.data_ids.network_id or error.data_ids.span_id or error.data_ids.node_id %}
{% if error.data_ids.network_id %}
<div>{% trans 'Network' %}: {{ error.data_ids.network_id }}</div>
{% endif %}
{% if error.data_ids.span_id %}
<div>{% trans 'Span' %}: {{ error.data_ids.span_id }}</div>
{% endif %}
{% if error.data_ids.node_id %}
<div>{% trans 'Node' %}: {{ error.data_ids.node_id }}</div>
{% endif %}
{% else %}
N/A
{% endif %}
</td>
<td>
/{{ error.path|join:"/" }}
</td>
<th>{% trans 'Identifiers' %}</th>
<th>{% trans 'Path' %}</th>
{% if col_instance %}
<td>
{{ error.instance|error_instance_display }}
</td>
<th>{% trans 'Value' %}</Th>
{% endif %}
{% if col_validator_value %}
<td>
{{ error.validator_value }}
</td>
<th>{{ col_validator_value_label }}</Th>
{% endif %}
</tr>
{% endfor %}
</tbody>
</table>
</thead>
<tbody>
{% for error in validation_errors_for_table %}
<tr>
<td>
{% if error.data_ids.network_id or error.data_ids.span_id or error.data_ids.node_id %}
{% if error.data_ids.network_id %}
<div>{% trans 'Network' %}: {{ error.data_ids.network_id }}</div>
{% endif %}
{% if error.data_ids.span_id %}
<div>{% trans 'Span' %}: {{ error.data_ids.span_id }}</div>
{% endif %}
{% if error.data_ids.node_id %}
<div>{% trans 'Node' %}: {{ error.data_ids.node_id }}</div>
{% endif %}
{% else %}
N/A
{% endif %}
</td>
<td>
/{{ error.path|join:"/" }}
</td>
{% if col_instance %}
<td>
{{ error.instance|error_instance_display }}
</td>
{% endif %}
{% if col_validator_value %}
<td>
{{ error.validator_value }}
</td>
{% endif %}
</tr>
{% endfor %}
</tbody>
</table>
</div>

0 comments on commit d19b160

Please sign in to comment.