Skip to content

Commit 1d093c9

Browse files
committed
add validation
1 parent ea04bd8 commit 1d093c9

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/main/java/com/github/sidhant92/boolparser/operator/OperatorService.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ public boolean evaluateLogicalOperator(final Operator operator, final ContainerD
3333
if (!containerDataType.isValid(leftOperandDataType, leftOperand)) {
3434
throw new InvalidDataType(String.format("Validation failed for the operator %s for the operand %s", operator, leftOperand));
3535
}
36+
rightOperands.forEach(rightOperand -> {
37+
if (!abstractOperator.getAllowedDataTypes().contains(rightOperand.getRight())) {
38+
throw new InvalidDataType(String.format("Invalid right operand data type %s for operator %s", rightOperand.getRight(), operator));
39+
}
40+
});
3641
return OperatorFactory.getLogicalOperator(operator).evaluate(containerDataType, leftOperand, leftOperandDataType, rightOperands);
3742
}
3843

0 commit comments

Comments
 (0)