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]