Skip to main content

A rule engine where rules are written in JSON format

Project description

python-rule-engine

pypi versions license Downloads Downloads Month

A rule engine where rules are defined in JSON format. The syntax of the rules belongs to the json-rules-engine javascript library though it contains some changes to make it more powerfull.

Installation

pip install python-rule-engine

Quick Example

from python_rule_engine import RuleEngine

rule = {
    "name": "basic_rule",
    "conditions": {
        "all": [
            {
                # JSONPath support
                "path": "$.person.name",
                "operator": "equal",
                "value": "Lionel"
            },
            {
                "path": "$.person.last_name",
                "operator": "equal",
                "value": "Messi"
            }
        ]
    }
}

obj = {
    "person": {
        "name": "Lionel",
        "last_name": "Messi"
    }
}

engine = RuleEngine([rule])

results = engine.evaluate(obj)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python_rule_engine-1.0.0.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_rule_engine-1.0.0-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file python_rule_engine-1.0.0.tar.gz.

File metadata

  • Download URL: python_rule_engine-1.0.0.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.23

File hashes

Hashes for python_rule_engine-1.0.0.tar.gz
Algorithm Hash digest
SHA256 13368b7d8b263e0a054f4518f39e42487d217a75e1448b514c6f341021a3228b
MD5 a4e5c26ae2953e754f4b33477005f56c
BLAKE2b-256 ef5b6056e01a358049b3b362d9d8e9f9003c89c84254a3e81db24bfeecf60d41

See more details on using hashes here.

File details

Details for the file python_rule_engine-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for python_rule_engine-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e45a1c55ce87ecef7d401ccf7fe4a969f116445d43d40fcb12c77b1e35d77a8f
MD5 7dade407c772f7cc1051db00037dbbec
BLAKE2b-256 9d2586077b41376255c79ed9ea0feda630d1116afab619a0fcaa101bedf84511

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page