guardflow 0.2.0

Validators and a retry-until-valid guard for LLM output, in Rust
Documentation
use guardflow::Guard;
use guardflow::validators::JsonSchema;
use serde_json::json;

#[test]
fn json_schema_validator_enforces_required_fields_and_types() {
    let schema = json!({
        "type": "object",
        "properties": {
            "name": { "type": "string" },
            "age": { "type": "integer", "minimum": 0 }
        },
        "required": ["name", "age"]
    });
    let guard = Guard::new().with(JsonSchema::new(&schema).unwrap());

    assert!(guard.check(r#"{"name": "Alice", "age": 30}"#).passed);
    assert!(!guard.check(r#"{"name": "Alice"}"#).passed);
    assert!(!guard.check(r#"{"name": "Alice", "age": -1}"#).passed);
    assert!(!guard.check("not json at all").passed);
}