Skip to content

Commit 9e69f27

Browse files
authored
Modify tree validator (#430)
When a tree has multiple levels, it is possible that a top node has "value" empty. That should be accepted. Check for the validity of 'value' only if it's not empty, or if it's at the last level of the tree hierarchy.
1 parent ead301d commit 9e69f27

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/ansys/dynamicreporting/core/utils/report_objects.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,8 +1151,9 @@ def validate_tree(t):
11511151
raise ValueError("Tree payload dictionaries must have a 'value' key")
11521152
if "children" in i:
11531153
ItemREST.validate_tree(i["children"])
1154-
# validate tree value
1155-
ItemREST.validate_tree_value(i["value"])
1154+
# validate tree value, only at the last level of the tree or if value is not empty
1155+
if len(i.get("children", [])) == 0 or (i.get("value") or "").strip():
1156+
ItemREST.validate_tree_value(i["value"])
11561157

11571158
def set_payload_tree(self, t):
11581159
self.validate_tree(t)

0 commit comments

Comments
 (0)