use std::collections::HashSet;

use crate::validator::error::ValidationError;

#[derive(Debug, Default, Clone, serde::Serialize)]
pub struct ValidationResult {
  pub errors: Vec<ValidationError>,
  #[serde(skip)]
  pub evaluated_keys: HashSet<String>,
  #[serde(skip)]
  pub evaluated_indices: HashSet<usize>,
}

impl ValidationResult {
  pub fn new() -> Self {
    Self::default()
  }

  pub fn merge(&mut self, other: ValidationResult) {
    self.errors.extend(other.errors);
    self.evaluated_keys.extend(other.evaluated_keys);
    self.evaluated_indices.extend(other.evaluated_indices);
  }

  pub fn is_valid(&self) -> bool {
    self.errors.is_empty()
  }
}
