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