I am working in ilog rules. I want to validate a field which is inside an array list of objects.
Like,
class Company {
List<Employee> employee;
}
class Employee {
String Name;
int age;
}
Here I want to validate the age field is not negative. I have company object passed as input parameter,
definitions
set 'Company' to 'The Company to validate' ;
set 'Employees' to employee working for 'Company'
Now how can I iterate employee which is an arraylist and check for age validations.
Use the 'in' BAL construct to bind a single employee from your collection to a variable in your definitions statement, then write your validation rule for this employee.
See the Knowledge Center / infocenter for your IBM ODM version, for instance:
You could try something like:
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 ;