Skip to content

Commit

Permalink
refactor: improve logic readability for validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Jtang-1 committed Dec 12, 2023
1 parent 2d28e06 commit 0b0d35e
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions corehq/apps/app_manager/helpers/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,17 +538,15 @@ def validate_search_config(self):
"module": self.get_module_info(),
"details": search_config.get_instance_name()
}

contains_ungrouped_properties = any(not prop.group_key for prop in search_config.properties)
contains_grouping_property = any(prop.is_group for prop in search_config.properties)
if contains_ungrouped_properties and contains_grouping_property:
for prop in search_config.properties:
if not prop.group_key:
yield {
"type": "invalid grouping from ungrouped search property",
"module": self.get_module_info(),
"property": prop.name,
}
module_contains_grouping_property = any(prop.is_group for prop in search_config.properties)
if module_contains_grouping_property:
ungrouped_properties = [prop for prop in search_config.properties if not prop.group_key]
for prop in ungrouped_properties:
yield {
"type": "invalid grouping from ungrouped search property",
"module": self.get_module_info(),
"property": prop.name,
}

def validate_case_list_field_actions(self):
if hasattr(self.module, 'case_details'):
Expand Down

0 comments on commit 0b0d35e

Please sign in to comment.