json-eval-rs 0.0.113

High-performance JSON Logic evaluator with schema validation and dependency tracking. Built on blazing-fast Rust engine.
Documentation
use json_eval_rs::JSONEval;
use serde_json::json;

#[test]
fn computed_value_refreshes_earlier_hidden_condition() {
    let schema = json!({
        "type": "object",
        "properties": {
            "dependent": {
                "type": "string",
                "condition": {
                    "hidden": {
                        "$evaluation": {
                            "!=": [{ "$ref": "#/properties/source" }, true]
                        }
                    }
                }
            },
            "source": {
                "type": "boolean",
                "value": { "$evaluation": true }
            }
        }
    })
    .to_string();

    let mut eval = JSONEval::new(&schema, None, Some("{}")).unwrap();
    eval.evaluate("{}", None, None, None).unwrap();

    assert_eq!(
        eval.get_evaluated_schema()
            .pointer("/properties/dependent/condition/hidden"),
        Some(&json!(false)),
        "computed source must refresh earlier condition depending on it"
    );
}