From c11a228fe3b0e85b48a71efd5a28e5c77775e53b Mon Sep 17 00:00:00 2001 From: Daniel <d.hornung@indiscale.com> Date: Tue, 7 Jan 2025 14:44:47 +0100 Subject: [PATCH] WIP: Fixing validation of to_dict() result. --- src/caosadvancedtools/table_json_conversion/convert.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/caosadvancedtools/table_json_conversion/convert.py b/src/caosadvancedtools/table_json_conversion/convert.py index beb7841a..ab259812 100644 --- a/src/caosadvancedtools/table_json_conversion/convert.py +++ b/src/caosadvancedtools/table_json_conversion/convert.py @@ -329,7 +329,12 @@ class XLSXConverter: for e in exceptions]) raise jsonschema.ValidationError(mess) if validate: - jsonschema.validate(self._result, self._schema) + for dtype, items in self._result.items(): + sub_schema = self._schema["properties"].get(dtype) + if dtype is None: + raise KeyError(f"Type not found in schema's properties: {dtype}") + for item in items: + jsonschema.validate(item, sub_schema) if self._errors: raise RuntimeError("There were error while handling the XLSX file.") return self._result -- GitLab