I'd combine the pattern matching check and the Luhn check into a single boolean condition creditCardNumber ?ccn&: (and (regexp "...." ?ccn )(Functions.isNotValidCC ?ccn)) (and) uses short circuited evaluation. -W
On 11 November 2010 20:19, Donald Winston <[email protected]> wrote: > If I've two rules I'd like to turn into one doing something like "fact > pattern1 | pattern2" then if pattern1 succeeds will pattern2 be evaluated? > Pattern2 will be a function I don't want to execute if the pattern1 > succeeds. For example could I use one rule for the following? (I'd have to > use a less specific error message) > (defrule VALIDATE::purchase-info-creditCardNumber > (declare (salience 10)) > (page "purchase-subscription.xslt") > ?fact <- (purchase-info (creditCardNumber > ~~/^((67\\d{2})|(4\\d{3})|(5[1-5]\\d{2})|(6011))(\\s?\\d{4}){3}|(3[4,7])\\d{2}\\s?\\d{6}\\s?\\d{5}$/)) > => > (modify ?fact > (creditCardNumberError "credit card number format is invalid") > (has-errors TRUE))) > (defrule VALIDATE::purchase-info-creditCardNumber-Luhn > (page "purchase-subscription.xslt") > (purchase-info (creditCardNumberError nil)) > ?fact <- (purchase-info (creditCardNumber ?ccn&: (Functions.isNotValidCC > ?ccn))) > => > (modify ?fact > (creditCardNumberError "credit card number failed Luhn algorithm") > (has-errors TRUE))) > Donald Paul Winston > [email protected] > > > -------------------------------------------------------------------- To unsubscribe, send the words 'unsubscribe jess-users [email protected]' in the BODY of a message to [email protected], NOT to the list (use your own address!) List problems? Notify [email protected]. --------------------------------------------------------------------
