Skip to main content

Module schema

Module schema 

Source
Available on crate features functional and graph only.
Expand description

State schema validation for the functional API.

Provides validation of workflow state against a declared schema at workflow start and before applying task output reducers. Wraps the existing StateSchema from adk-graph and adds type-level validation capabilities specific to the functional API.

§Example

use adk_graph::functional::StateSchemaValidator;
use adk_graph::state::StateSchema;
use serde_json::json;
use std::collections::HashMap;

let schema = StateSchema::builder()
    .channel("counter")
    .list_channel("messages")
    .build();

let validator = StateSchemaValidator::new(schema)
    .expect_type("counter", ExpectedType::Number)
    .expect_type("messages", ExpectedType::Array);

let mut state = HashMap::new();
state.insert("counter".to_string(), json!(42));
state.insert("messages".to_string(), json!([]));

// Passes validation
validator.validate_state(&state).unwrap();

Structs§

StateSchemaValidator
Validates workflow state against a declared schema.

Enums§

ExpectedType
Expected JSON value type for a state field.