我正在使用ilog规则。我想验证一个数组对象列表中的字段。
喜欢,
class Company {
List<Employee> employee;
}
class Employee {
String Name;
int age;
}
这里我要验证年龄字段是否为负数。我将公司对象作为输入参数传递,
definitions
set 'Company' to 'The Company to validate' ;
set 'Employees' to employee working for 'Company'
现在我如何迭代员工,这是一个arraylist并检查年龄验证。请帮帮我。
答案 0 :(得分:0)
使用&#39; in&#39; BAL构造将您的集合中的单个员工绑定到 definitions 语句中的变量,然后为该员工编写验证规则。
有关您的IBM ODM版本,请参阅知识中心/信息中心,例如:
您可以尝试以下方式:
definitions
set 'employee' to an employee in the employees of 'the company' ;
if
the age of employee is less than 0
then
print "Age of employee " + the name of employee + "' is negative: " + the age of employee ;
else
print "Age of employee " + the name of employee + "' is OK: " + the age of employee ;