pub fn validate_agent_data(data: &AgentData) -> Result<(), ValidationError>Expand description
Validates all fields of AgentData to ensure they meet required constraints.
This function performs comprehensive validation including:
- DID format validation
- Date validation (no future dates)
- Rating bounds and consistency
- Review count consistency
- MCP level validation
ยงExample
use reputation_core::validation::validate_agent_data;
use reputation_types::AgentData;
use chrono::Utc;
let agent = AgentData {
did: "did:example:123".to_string(),
created_at: Utc::now(),
mcp_level: Some(2),
identity_verified: true,
security_audit_passed: false,
open_source: true,
total_interactions: 100,
total_reviews: 50,
average_rating: Some(4.2),
positive_reviews: 40,
negative_reviews: 10,
};
match validate_agent_data(&agent) {
Ok(()) => println!("Agent data is valid"),
Err(e) => println!("Validation failed: {}", e),
}