sea_core/
validation_result.rs

1use crate::policy::{Severity, Violation};
2
3/// Result object produced by `Graph::validate()` collecting the
4/// set of policy violations and a quick summary count for errors
5/// to support the CLI and tests.
6#[derive(Debug, Clone)]
7pub struct ValidationResult {
8    /// Total number of policies evaluated
9    pub total_policies: usize,
10
11    /// All policy violations collected during evaluation
12    pub violations: Vec<Violation>,
13
14    /// Number of ERROR-severity violations
15    pub error_count: usize,
16}
17
18impl ValidationResult {
19    pub fn new(total: usize, violations: Vec<Violation>) -> Self {
20        let error_count = violations
21            .iter()
22            .filter(|v| v.severity == Severity::Error)
23            .count();
24        Self {
25            total_policies: total,
26            violations,
27            error_count,
28        }
29    }
30}