dcc_json_toolkit.content_validation ¶
Functions to validate the contents of a DCC.
These functions ignore any schema rules. They all work based on the content no matter if the schema is correct or not.
extract_dcc_elements ¶
extract_dcc_elements(
data: dict | list, element_name: str, path: str = "", case_sensitive: bool = True
) -> list[tuple[str, dict]]
Extracting all elements (recursively) partially containing the name.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Examples:
Assuming a DCC data with multiple quantities, these quantities can have
units under one of the following names (ignoring the namespace import):
- 'unit'
- 'unitXMLList'
- 'unitPhase'
- 'unitPhaseXMLList'
- etc.
Invoking extract_dcc_elements(data, element_name="unit") returns a list
with the units declared under all previous listed names.
validate_dcc_content ¶
validate_dcc_content(dcc_source: DccSourceContent) -> list[str]
Checks over the contents of a DCC.
Currently only some content items are checked, as each check requires some rules identifying what is correct. The current checks are:
- Valid ISO dates in any 'date' field.
- Correctness over D-SI units.
- Check over dimension tables and their index quantities.
| Returns: |
|
|---|