[rules-users] Rule Reuse Best Practice

Jason Davidson jljdavidson at gmail.com
Tue Dec 15 14:36:30 EST 2009


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!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20091215/ca33ff27/attachment.html 


More information about the rules-users mailing list