in src/rules.js [218:272]
parseCondition(condition, shownMap) {
if (typeof condition === 'boolean') {
return condition;
}
const type = getConditionType(condition, this.registeredRuleCondtions);
switch (type) {
case conditionTypes.ALL:
return this.all(shownMap)(...condition[conditionTypes.ALL]);
case conditionTypes.ANY:
return this.any(shownMap)(...condition[conditionTypes.ANY]);
case conditionTypes.NOT:
return this.not(shownMap)(condition[conditionTypes.NOT]);
default: {
const params = condition[type];
if (!type || !params) {
return false;
}
let fieldValue;
let isFieldShown = true;
// IF PATH CORRESPONDS TO A FIELD IN THIS FORM:
// Continue normally
// IF PATH IS NOT IN FORM:
// Get that value from 'context', value is undefined if not found
if (this.pathsToTreeMap[params.fieldPath]) {
if (typeof params.fieldPath !== 'undefined') {
fieldValue = getIn(this.formValues, params.fieldPath);
}
if (shownMap && !shownMap[params.fieldPath]) {
fieldValue = undefined;
isFieldShown = false;
}
} else {
fieldValue = getIn(this.config.context, params.fieldPath);
}
const conditionFn = this.registeredRuleCondtions[type];
if (conditionFn) {
return conditionFn({
fieldValue,
isFieldShown,
params,
});
}
return false;
}
}
}