question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ignoring the fact condition when the fact is not passed in

See original GitHub issue

Hi:

I would have liked the rule engine to ignore the fact condition if it is in “ANY” when the fact is not passed in, e.g.,

If my facts are these:

let facts = {
    gameDuration: 40
  };

And my rule is:

engine.addRule({
    conditions: {
      any: [{
        fact: 'personalFoulCount',
        operator: 'greaterThanInclusive',
        value: 5
      },
        {
          fact: 'gameDuration',
          operator: 'equal',
          value: 40
        }]
    },
    event: {  // define the event to fire when the conditions evaluate truthy
      type: 'fouledOut',
      params: {
        message: 'Player has fouled out!'
      }
    }
  });

I would have preferred the rule engine would not have errored out and ignore the fact that personalFoulCount is not there as it was in ANY condition clause.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
CacheControlcommented, Jan 23, 2017

@arsalans this feature is now available in 1.4.0 as an allowUndefinedFacts engine option. Please see the updated docs

0reactions
CacheControlcommented, Jan 20, 2017

@arsalans yep, we’re aligned. Any unregistered fact will simply be treated as a falsey condition. This could mean a rule still evaluates truthy, as in the ANY scenario you mentioned. I’ll attempt to come up with a better term than ignoreUnregisteredFacts that better explains the behavior

Read more comments on GitHub >

github_iconTop Results From Across the Web

Rule 401. Test for Relevant Evidence - Law.Cornell.Edu
Evidence is relevant if: (a) it has any tendency to make a fact more or less ... Passing mention should be made of...
Read more >
Writing a Statement of Facts in an Appellate Brief
Ignoring a harmful fact does not make it go away; it simply leaves the problem unexplained and undefended. • Emphasize the strengths and...
Read more >
Why People Ignore Facts | Psychology Today
When it comes to reasoning, identity trumps truth.
Read more >
Master List of Logical Fallacies
Fallacies are fake or deceptive arguments, "junk cognition," that is, arguments that seem irrefutable but prove nothing. Fallacies often seem superficially ...
Read more >
How to force clips to ignore a certain fact for a rule?
I want to retract fact-1 and fact-3 because they include 1 and 5 uniquely. I'm trying to achieve it using a rule like...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found