diff --git a/src/screens/HyperSwitch/Routing/RoutingUtils.res b/src/screens/HyperSwitch/Routing/RoutingUtils.res index 9ab52b411..6c111366c 100644 --- a/src/screens/HyperSwitch/Routing/RoutingUtils.res +++ b/src/screens/HyperSwitch/Routing/RoutingUtils.res @@ -697,8 +697,10 @@ let checkIfValuePresent = dict => { ele != ""->Js.Json.string }) ->Js.Array2.length > 0 || - valueFromObject->getString("value", "") !== "" || - valueFromObject->getFloat("value", -1.0) !== -1.0 + valueFromObject->getString("value", "")->Js.String2.length > 0 || + valueFromObject->getFloat("value", -1.0) !== -1.0 || + (valueFromObject->getDictfromDict("value")->getString("key", "")->Js.String2.length > 0 && + valueFromObject->getDictfromDict("value")->getString("value", "")->Js.String2.length > 0) } let validateConditionJsonFor3ds = json => { switch json->Js.Json.decodeObject { @@ -715,17 +717,12 @@ let validateConditions = dict => { ->Js.Array2.every(MakeRuleFieldComponent.validateConditionJson) } -let validateConditionsEvenIfOneExists = dict => { +let validateConditionsFor3ds = dict => { let conditionsArray = dict->LogicUtils.getArrayFromDict("statements", []) - let vector = Js.Vector.make(conditionsArray->Js.Array2.length, false) - conditionsArray->Array.forEachWithIndex((value, index) => { - let res = value->validateConditionJsonFor3ds - vector->Js.Vector.set(index, res) + conditionsArray->Array.every(value => { + value->validateConditionJsonFor3ds }) - - let _result = Js.Vector.filterInPlace((. val) => val == true, vector) - vector } let filterEmptyValues = (arr: array) => { diff --git a/src/screens/HyperSwitch/RoutingRevamp/AdvancedRoutingUtils.res b/src/screens/HyperSwitch/RoutingRevamp/AdvancedRoutingUtils.res index 37cb47e07..0c342c5a1 100644 --- a/src/screens/HyperSwitch/RoutingRevamp/AdvancedRoutingUtils.res +++ b/src/screens/HyperSwitch/RoutingRevamp/AdvancedRoutingUtils.res @@ -351,12 +351,13 @@ let validateStatements = statementsArray => { statementsArray->Js.Array2.every(isStatementMandatoryFieldsPresent) } -let initialValueForStatement: AdvancedRoutingTypes.statementSendType = { - condition: [], -} - let generateStatements = statements => { open LogicUtils + + let initialValueForStatement: AdvancedRoutingTypes.statementSendType = { + condition: [], + } + statements->Array.reduce([initialValueForStatement], (acc, statement) => { let statementDict = statement->getDictFromJsonObject let logicalOperator = statementDict->getString("logical", "")->Js.String2.toLowerCase diff --git a/src/screens/HyperSwitch/ThreeDSFlow/HSwitchThreeDS.res b/src/screens/HyperSwitch/ThreeDSFlow/HSwitchThreeDS.res index 0398d7bcb..50da84b8b 100644 --- a/src/screens/HyperSwitch/ThreeDSFlow/HSwitchThreeDS.res +++ b/src/screens/HyperSwitch/ThreeDSFlow/HSwitchThreeDS.res @@ -215,9 +215,9 @@ let make = () => { } else { rules->Array.forEachWithIndex((rule, i) => { let ruleDict = rule->LogicUtils.getDictFromJsonObject - if RoutingUtils.validateConditionsEvenIfOneExists(ruleDict)->Js.Array2.length == 0 { + if !RoutingUtils.validateConditionsFor3ds(ruleDict) { errors->Js.Dict.set( - `Rule ${(i + index)->string_of_int} - Condition`, + `Rule ${(i + 1)->string_of_int} - Condition`, `Invalid`->Js.Json.string, ) }