-
-
Notifications
You must be signed in to change notification settings - Fork 41
Open
Description
I need to run a ruleset, and for each rule that doesn't pass, I need to know why (via error message). Is it possible to implement rules which pass when finding facts, but generate an error when they don't? At first I thought it was a simple as this:
engine = Wongi::Engine.create
debit_rule = engine.rule "transaction type is debit" do
forall {
has :TRANSACTION, :transaction_type, :TX_TYPE
equal :TX_TYPE, 2
}
make {
error "Transaction is not a debit"
}
end
engine << ["A", :transaction_type, 1]
But after scratching my head for a while, I eventually learned that this will throw an error if the forall finds those facts. I could negate the conditions in the forall, but I'd really rather have the conditions in the positive, since I feel like it reads better.
Any ideas?
Metadata
Metadata
Assignees
Labels
No labels