fix(linkageRules): support empty condiction (#1496)

* fix: condiction suport empty

* fix: condiction suport empty

* fix: condiction suport empty

* fix: condiction suport empty
This commit is contained in:
katherinehhh 2023-02-25 15:18:54 +08:00 committed by GitHub
parent 9d1b10d635
commit e7e1436422
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -49,8 +49,15 @@ export const conditionAnalyse = (rules, values) => {
const operator = jsonlogic.operator;
const value = getValue(jsonlogic.value, values);
const targetField = Object.keys(flat(c))[0]?.replace?.(`.${operator}`, '');
if (!operator) {
return true;
}
try {
const result = jsonLogic.apply({ [operator]: [flat(values)?.[targetField], value] });
return result;
} catch (error) {
console.error(error);
}
});
if (type === '$and') {
return every(results, (v) => v);