Hello,<br><br>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:<br>
rule "Citation DL Number"<br> ruleflow-group "CitationEntryValidationFlow"<br> when<br> CitationDTO($dln : citationSubject.driverLicense.driverAuthorizationId not matches "^.{5,15}$")<br>
then<br> resultHolder.setMessage(GenericCitationFieldIds.DLN,"DLN [{0}] must be at least 5 characters long and no more than 15 characters long.", new Object[]{$dln});<br>end<br><br>Then I have another rule that uses the license number from the InCourtSearchDTO:<br>
rule "InCourt DL Number"<br> ruleflow-group "InCourtSearchValidationGroup"<br> when<br> InCourtSearchDTO( $d : dln not matches "^.{5,15}$")<br> then<br> resultHolder.setMessage(UserLogonFieldIds.END_DT,"DLN [{0}] must be at least 5 characters long and no more than 15 characters long.", new Object[]{$d});<br>
end<br><br>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?<br><br>Thanks!<br>