1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
//! Graph metadata validation. use crate::{ValidationError, ValidationResult}; use agileplus_domain::intent_graph::GraphMetadata; /// Validate graph metadata fields (version, schema_uri, created_at, counts). pub fn validate_metadata(metadata: &GraphMetadata) -> ValidationResult { let mut errors = Vec::new(); if metadata.version.trim().is_empty() { errors.push(ValidationError::MetadataError( "Metadata version is empty".to_string(), )); } if metadata.schema_uri.trim().is_empty() { errors.push(ValidationError::MetadataError( "Metadata schema_uri is empty".to_string(), )); } if metadata.created_at.trim().is_empty() { errors.push(ValidationError::MetadataError( "Metadata created_at is empty".to_string(), )); } if let Some(c) = metadata.node_count { if c > 0 && metadata.edge_count.is_none() { errors.push(ValidationError::MetadataError( "Metadata has node_count but no edge_count".to_string(), )); } } if errors.is_empty() { Ok(()) } else { Err(errors) } }