Refactor form property logic rule to load condition mapping from external JSON file (#698)

* Refactor form property logic rule to load condition mapping from external JSON file

* fix CONDITION_MAPPING

* use config file for load mapping

* Simplify condition mapping retrieval in FormPropertyLogicRule

---------

Co-authored-by: Julien Nahum <julien@nahum.net>
This commit is contained in:
Chirag Chhatrala
2025-02-15 04:02:55 +05:30
committed by GitHub
parent 82fae97a3e
commit e7585c32d3
5 changed files with 23 additions and 664 deletions

View File

@@ -58,21 +58,21 @@ class IntegrationLogicRule implements DataAwareRule, ValidationRule
$operator = $condition['value']['operator'];
$value = $condition['value']['value'];
if (!isset(FormPropertyLogicRule::CONDITION_MAPPING[$typeField])) {
if (!isset(FormPropertyLogicRule::getConditionMapping()[$typeField])) {
$this->isConditionCorrect = false;
$this->conditionErrors[] = 'configuration not found for condition type';
return;
}
if (!isset(FormPropertyLogicRule::CONDITION_MAPPING[$typeField]['comparators'][$operator])) {
if (!isset(FormPropertyLogicRule::getConditionMapping()[$typeField]['comparators'][$operator])) {
$this->isConditionCorrect = false;
$this->conditionErrors[] = 'configuration not found for condition operator';
return;
}
$type = FormPropertyLogicRule::CONDITION_MAPPING[$typeField]['comparators'][$operator]['expected_type'];
$type = FormPropertyLogicRule::getConditionMapping()[$typeField]['comparators'][$operator]['expected_type'];
if (is_array($type)) {
$foundCorrectType = false;