Skip to content

Commit

Permalink
feat: Update resolveBinaryExpression
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhaoBingyu committed Aug 1, 2023
1 parent 00876fc commit aed2e00
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion clients/components/form-builder/resolve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,14 @@ function resolveBinaryExpression({ left, right, operator }: ResolveBinaryExpress
case '>':
return resolvedLeft > resolvedRight;
case '==':
if (!isNaN(Number(resolvedLeft)) && !isNaN(Number(resolvedRight)) ) {
return Number(resolvedLeft) === Number(resolvedRight);
}
return resolvedLeft === resolvedRight;
case '!=':
if (!isNaN(Number(resolvedLeft)) && !isNaN(Number(resolvedRight)) ) {
return Number(resolvedLeft) !== Number(resolvedRight);
}
return resolvedLeft !== resolvedRight;
case '+':
return Number(resolvedLeft) + Number(resolvedRight);
Expand Down Expand Up @@ -124,7 +130,7 @@ function resolveOperand(operand: StringLiteral | NumberLiteral | Variable | Bina
if (value === undefined || value === null) {
throw new Error(`variable name [${operand.name}] undefined`);
}
return Number(value);
return value;
}

if (operand.type === 'NumberLiteral') {
Expand Down

0 comments on commit aed2e00

Please sign in to comment.