I think what you are looking for is the forall. The forall Conditional Element will evaluate to true when all facts that match the first pattern match all the remaining patterns. E.g.,,

rule "No fields can be blank"
when
forall ($i : Insurance( name != null || street != null || city != null ||
county != null || state != null || country != null ||
zip != null)
Insurance(this == $i, name == null || street == null || city == null ||
county == null || state == null || country == null ||
zip == null) )
then
<Report error>
end


Brian Enderle wrote:
I have a test case that says that if any one field is present then all must be present and then verified. The items in question are for an Insurance object and are Name, Street, City, County, State, Country and Zip. If one of the these 7 fields is present (not null/blank) then it and all the other fields need to be verified. This needs to be done on a per object basis as not all InsuranceCarrier objects will have these fields filled in.

Just to clarify I need rules for each field similar to the following:

rule "Name cannot be blank"
   when
$i : Insurance( name == null, street != null || city != null || county != null || state != null || country != null || zip != null)
   then
      <Report error>
end

Ithere a simple way to check all the values and then execute all the rules for that object?
THanks in advance,
Brian Enderle

_______________________________________________
rules-users mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users

_______________________________________________
rules-users mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to