fix: rule with 'any' condition does not take effect when condition li… (#6628)

* fix: rule with 'any' condition does not take effect when condition list is empty

* fix: bug
This commit is contained in:
Katherine 2025-04-07 16:02:45 +08:00 committed by GitHub
parent 46227c877f
commit aa59e0131f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -96,7 +96,6 @@ export const conditionAnalyses = async (
) => { ) => {
const type = Object.keys(ruleGroup)[0] || '$and'; const type = Object.keys(ruleGroup)[0] || '$and';
const conditions = ruleGroup[type]; const conditions = ruleGroup[type];
let results = conditions.map(async (condition) => { let results = conditions.map(async (condition) => {
if ('$and' in condition || '$or' in condition) { if ('$and' in condition || '$or' in condition) {
return await conditionAnalyses({ ruleGroup: condition, variables, localVariables }, jsonLogic); return await conditionAnalyses({ ruleGroup: condition, variables, localVariables }, jsonLogic);
@ -147,8 +146,11 @@ export const conditionAnalyses = async (
if (type === '$and') { if (type === '$and') {
return every(results, (v) => v); return every(results, (v) => v);
} else { } else {
if (results.length) {
return some(results, (v) => v); return some(results, (v) => v);
} }
return true;
}
}; };
/** /**