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:
parent
9d1b10d635
commit
e7e1436422
@ -49,8 +49,15 @@ export const conditionAnalyse = (rules, values) => {
|
|||||||
const operator = jsonlogic.operator;
|
const operator = jsonlogic.operator;
|
||||||
const value = getValue(jsonlogic.value, values);
|
const value = getValue(jsonlogic.value, values);
|
||||||
const targetField = Object.keys(flat(c))[0]?.replace?.(`.${operator}`, '');
|
const targetField = Object.keys(flat(c))[0]?.replace?.(`.${operator}`, '');
|
||||||
const result = jsonLogic.apply({ [operator]: [flat(values)?.[targetField], value] });
|
if (!operator) {
|
||||||
return result;
|
return true;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const result = jsonLogic.apply({ [operator]: [flat(values)?.[targetField], value] });
|
||||||
|
return result;
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
if (type === '$and') {
|
if (type === '$and') {
|
||||||
return every(results, (v) => v);
|
return every(results, (v) => v);
|
||||||
|
Loading…
Reference in New Issue
Block a user