Rule Engine Documentation

This project provides a library for creating general purpose “Rule” objects from a logical expression which can then be applied to arbitrary objects to evaluate whether or not they match.

Documentation is available at

Rule Engine expressions are written in their own language, defined as strings in Python. Some features of this language includes:

  • Optional type hinting

  • Matching strings with regular expressions

  • Datetime datatypes

  • Data attributes

Usage Example

import rule_engine
# match a literal first name and applying a regex to the email
rule = rule_engine.Rule(
    'first_name == "Luke" and email =~ ".*$"'
) # => <Rule text='first_name == "Luke" and email =~ ".*$"' >
    'first_name': 'Luke', 'last_name': 'Skywalker', 'email': ''
}) # => True
   'first_name': 'Darth', 'last_name': 'Vader', 'email': ''
}) # => False

See the examples folder for more.

Indices and tables