<br>   2 ways:<br><br>1. If you have a common superclass/interface for your objects and the superclass/interface has the method to return your dln, just make use of inheritance:<br><br>when<br>    MyDTOInterface( dln not matches &quot;^.{5,15}$&quot;)<br>
then<br>   // do something<br><br>2. If you want to use composition instead, make dln a top level fact:<br><br>when<br>   DLN( id not matches &quot;^.{5,15}$&quot;)<br>then<br>   // do something<br><br>   Edson<br><br><div class="gmail_quote">
2009/12/15 Jason Davidson <span dir="ltr">&lt;<a href="mailto:jljdavidson@gmail.com">jljdavidson@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hello,<br><br>What is the best practice for reusing rules?  I&#39;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:<br>

rule &quot;Citation DL Number&quot;<br>   ruleflow-group &quot;CitationEntryValidationFlow&quot;<br>    when<br>        CitationDTO($dln : citationSubject.driverLicense.driverAuthorizationId not matches &quot;^.{5,15}$&quot;)<br>

    then<br>        resultHolder.setMessage(GenericCitationFieldIds.DLN,&quot;DLN [{0}] must be at least 5 characters long and no more than 15 characters long.&quot;, new Object[]{$dln});<br>end<br><br>Then I have another rule that uses the license number from the InCourtSearchDTO:<br>

rule &quot;InCourt DL Number&quot;<br>    ruleflow-group &quot;InCourtSearchValidationGroup&quot;<br>    when<br>        InCourtSearchDTO( $d : dln not matches &quot;^.{5,15}$&quot;)<br>    then<br>        resultHolder.setMessage(UserLogonFieldIds.END_DT,&quot;DLN [{0}] must be at least 5 characters long and no more than 15 characters long.&quot;, new Object[]{$d});<br>

end<br><br>Obviously this is a poor implementation because the license number check &#39;not matches &quot;^.{5,15}$&quot;&#39; is duplicated.  Is there a way I can reuse this rule?<br><br>Thanks!<br>
<br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>  Edson Tirelli<br>  JBoss Drools Core Development<br>  JBoss by Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>