File tree Expand file tree Collapse file tree 2 files changed +424
-382
lines changed
src/ansys/dynamicreporting/core/utils Expand file tree Collapse file tree 2 files changed +424
-382
lines changed Original file line number Diff line number Diff line change @@ -1138,6 +1138,14 @@ def validate_tree_value(value):
11381138
11391139 @staticmethod
11401140 def validate_tree (t ):
1141+
1142+ def _has_non_empty_value (val ):
1143+ if val is None :
1144+ return False
1145+ if isinstance (val , str ):
1146+ return bool (val .strip ())
1147+ return True
1148+
11411149 if type (t ) != list :
11421150 raise ValueError ("The tree payload must be a list of dictionaries" )
11431151 for i in t :
@@ -1151,9 +1159,14 @@ def validate_tree(t):
11511159 raise ValueError ("Tree payload dictionaries must have a 'value' key" )
11521160 if "children" in i :
11531161 ItemREST .validate_tree (i ["children" ])
1162+
11541163 # 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" ])
1164+ value = i .get ("value" )
1165+ children = i .get ("children" , [])
1166+ is_leaf = len (children ) == 0
1167+
1168+ if is_leaf or _has_non_empty_value (value ):
1169+ ItemREST .validate_tree_value (value )
11571170
11581171 def set_payload_tree (self , t ):
11591172 self .validate_tree (t )
You can’t perform that action at this time.
0 commit comments