Metadata-Version: 2.4
Name: json-rule-matcher
Version: 0.1.0
Summary: Rule-based matcher for list[dict] with flat DSL, AST, and operators like $in / $and / $or
Author: alex
License: MIT
Project-URL: Homepage, https://pypi.org/project/json-rule-matcher/
Keywords: json,rule,matcher,dsl,ast
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: dev
Requires-Dist: pytest>=7; extra == "dev"
Dynamic: license-file

# json-rule-matcher

按扁平规则校验 `list[dict]` 数据。支持比较运算、`$in`、`$and` / `$or`、点路径，以及自定义异常。

## 安装

```bash
pip install json-rule-matcher
```

## 用法

```python
from jsondiff import RuleMatcher, RuleMismatchError, UnsupportedCombinatorError

data = [
    {
        "name": "alex",
        "happy": "say",
        "country": {"address": "city"},
        "age": 16,
    }
]

rule = {
    "name": "alex",
    "happy": {"$in": ["say", "aa"]},
    "country.address": "city",
    "age": {"<": 18},
}

try:
    print(RuleMatcher(rule).match(data))  # (1, True)
except RuleMismatchError as e:
    print(e.reason)
```

## 规则速查

| 写法 | 含义 |
|---|---|
| `"name": "alex"` | 精确相等 |
| `"age": {"<": 18}` | 比较（`=` `!=` `<` `<=` `>` `>=`） |
| `"happy": {"$in": ["say", "aa"]}` | 标量落在列表中 |
| `"country.address": "city"` | 点路径嵌套取值 |
| `"$and": [...]` / `"$or": [...]` | 逻辑组合 |

## 开发

```bash
pip install -e ".[dev]"
pytest
```
