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.

Does it support running rules on complex objects?

See original GitHub issue

Does it support running rules on complex objects? Like running rules on address.country == 'USA"?

{ "name": "test_user", "email_address": "test@gmail.com", "address": { "address_1": "high st", "address_2": "unit-4", "state": "AZ", "country": "USA" } }

Can you give an example as i see complex types are supported

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
zeroSteinercommented, Dec 29, 2021

Cool so it sounds like you’re all set so I’ll close this out. If you have any other questions just post them here or in a new issue if you’d like.

1reaction
zeroSteinercommented, Dec 28, 2021

Here’s a larger example using the debug repl.

PYTHONPATH=$(pwd)/lib python -m rule_engine.debug_repl --edit-console
edit the 'context' and 'thing' objects as necessary
>>> thing = { "name": "test_user", "email_address": "test@gmail.com", "address": { "address_1": "high st", "address_2": "unit-4", "state": "AZ", "country": "USA" } }
>>> exit()
exiting the edit console...
rule > address.country == 'USA'
result: 
True
rule > email_address =~ '@gmail\.com$'
result: 
False
rule > email_address =~~ '@gmail\.com$'
result: 
True
rule > 'state' in address
result: 
True
rule > address['state'].as_lower == 'az'
result: 
True
rule > 

You can access MAPPING keys using the dot syntax like mapping.key, and that’s mostly kept for backwards compatibility purposes. There could be name collisions with attributes though which is why I recommend you use the other syntax like mapping['key']. The default context should work just fine for this since it uses the getitem resolver.

Read more comments on GitHub >

github_iconTop Results From Across the Web

java - Drools - Doing Complex Stuff inside a Rule Condition or ...
My question is what should be and shouldn't be done inside a Rule Condition/Consequence. Given that we can write Java directly or call...
Read more >
Create custom actions rules in Outlook for Windows
Note: A rule with a custom action runs only on the computer where it is installed and only when Outlook is running. Click...
Read more >
Chapter 10: Object-Oriented Programming in LabVIEW
Object-oriented design is supported by a number of languages, including C++ and Java. This book tries to refrain from using rules used specifically...
Read more >
Working with objects - JavaScript - MDN Web Docs - Mozilla
An object is a collection of properties, and a property is an association between a name (or key) and a value. A property's...
Read more >
Choose when to run jobs - GitLab Docs
The rule matches and the job runs only when there are changes to the files in the branch. Complex rules. You can use...
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