我必须验证一些元素是否为空,然后如果它们为空则停止执行。
我几乎没有像下面这样检查一些空值并添加错误的规则
rule "Require begin date for Service Period"
salience 100
when
$servicePeriod : ServicePeriod(beginDate == null)
// check this to avoid the infinite loop
eval(!$servicePeriod.getValidationErrors().contains("Begin date is required."))
then
$servicePeriod.getValidationErrors().add("Begin date is required.");update($servicePeriod);
end
我有一些如下规则,首先检查'validationErrors.size() == 0'。即使验证错误大小大于零,它也会继续检查其他验证并失败,因为它们为空。请让我知道如何修改这些规则以避免异常。
// Rules for Firefighter deduction calculation
rule "Firefighter Annual Salary Deposit Calculation"
salience 50
when
$servicePeriod : ServicePeriod(validationErrors.size() == 0 , periodType.name == "DEPOSIT" , payType.name == "ANNUAL SALARY" , serviceType.name == "FIREFIGHTER" )
then
calculateDeduction($servicePeriod, 0.075);
end