Skip to main content

hoist_core/constraints/
mod.rs

1//! Constraint validation for Azure AI Search resources
2
3pub mod dependencies;
4pub mod immutability;
5
6pub use dependencies::{check_dependencies, DependencyViolation};
7pub use immutability::{check_immutability, ImmutabilityViolation, ViolationSeverity};
8
9use thiserror::Error;
10
11/// Constraint violation errors
12#[derive(Debug, Error)]
13pub enum ConstraintError {
14    #[error("Immutability violation: {0}")]
15    Immutability(#[from] ImmutabilityViolation),
16    #[error("Dependency violation: {0}")]
17    Dependency(#[from] DependencyViolation),
18}
19
20/// Result of constraint validation
21#[derive(Debug)]
22pub struct ValidationResult {
23    pub errors: Vec<ConstraintError>,
24    pub warnings: Vec<String>,
25}
26
27impl ValidationResult {
28    pub fn new() -> Self {
29        Self {
30            errors: Vec::new(),
31            warnings: Vec::new(),
32        }
33    }
34
35    pub fn is_valid(&self) -> bool {
36        self.errors.is_empty()
37    }
38
39    pub fn add_error(&mut self, error: ConstraintError) {
40        self.errors.push(error);
41    }
42
43    pub fn add_warning(&mut self, warning: String) {
44        self.warnings.push(warning);
45    }
46}
47
48impl Default for ValidationResult {
49    fn default() -> Self {
50        Self::new()
51    }
52}