Hello,

What is the best practice for reusing rules?  I've got a license number
validation rule that I need to reuse for different fact types.  For example,
the first rule uses the license number in a CitationDTO fact:
rule "Citation DL Number"
   ruleflow-group "CitationEntryValidationFlow"
    when
        CitationDTO($dln :
citationSubject.driverLicense.driverAuthorizationId not matches "^.{5,15}$")
    then
        resultHolder.setMessage(GenericCitationFieldIds.DLN,"DLN [{0}] must
be at least 5 characters long and no more than 15 characters long.", new
Object[]{$dln});
end

Then I have another rule that uses the license number from the
InCourtSearchDTO:
rule "InCourt DL Number"
    ruleflow-group "InCourtSearchValidationGroup"
    when
        InCourtSearchDTO( $d : dln not matches "^.{5,15}$")
    then
        resultHolder.setMessage(UserLogonFieldIds.END_DT,"DLN [{0}] must be
at least 5 characters long and no more than 15 characters long.", new
Object[]{$d});
end

Obviously this is a poor implementation because the license number check
'not matches "^.{5,15}$"' is duplicated.  Is there a way I can reuse this
rule?

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

Reply via email to