Skip to content

Commit

Permalink
Merge pull request #45 from episerver/bugfix/AFORM-3738-Form-depend-c…
Browse files Browse the repository at this point in the history
…ondition-check-statisfied-should-return-false-when-value-is-undefined

Check statisfied condition should return false when value is undefined
  • Loading branch information
hungoptimizely authored Dec 4, 2023
2 parents 1edd16d + a4d511e commit 5ce4043
Showing 1 changed file with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,14 @@ export class FormDependConditions {
for (let i = 0; i < conditionProps.conditions.length; i++) {
const condition = conditionProps.conditions[i]
const fieldValue = formSubmissions.filter(s => equals(s.elementKey, condition.field))[0]?.value as string
if (!isNull(fieldValue)) {
const conditionFunction = ConditionFunctions[condition.operator];
if (!isNull(conditionFunction)){
var checkResult = conditionFunction(fieldValue, condition.fieldValue)
if (conditionProps.conditionCombination === ConditionCombinationType.Any && checkResult) {
return true
}
if (conditionProps.conditionCombination !== ConditionCombinationType.Any && !checkResult) {
return false
}
const conditionFunction = ConditionFunctions[condition.operator];
if (!isNull(conditionFunction)){
let checkResult = conditionFunction(fieldValue, condition.fieldValue)
if (conditionProps.conditionCombination === ConditionCombinationType.Any && checkResult) {
return true
}
if (conditionProps.conditionCombination !== ConditionCombinationType.Any && !checkResult) {
return false
}
}
}
Expand Down

0 comments on commit 5ce4043

Please sign in to comment.