#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub struct ValidationConfig {
pub allow_orphan_components: bool,
pub allow_dangling_references: bool,
pub allow_missing_root: bool,
}
impl ValidationConfig {
pub const STRICT: Self = Self {
allow_orphan_components: false,
allow_dangling_references: false,
allow_missing_root: false,
};
pub const RELAXED: Self = Self {
allow_orphan_components: true,
allow_dangling_references: true,
allow_missing_root: true,
};
}
pub const STRICT_VALIDATION: ValidationConfig = ValidationConfig::STRICT;
pub const RELAXED_VALIDATION: ValidationConfig = ValidationConfig::RELAXED;
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn strict_rejects_everything() {
assert!(!STRICT_VALIDATION.allow_orphan_components);
assert!(!STRICT_VALIDATION.allow_dangling_references);
assert!(!STRICT_VALIDATION.allow_missing_root);
assert_eq!(STRICT_VALIDATION, ValidationConfig::STRICT);
}
#[test]
fn relaxed_allows_everything() {
assert!(RELAXED_VALIDATION.allow_orphan_components);
assert!(RELAXED_VALIDATION.allow_dangling_references);
assert!(RELAXED_VALIDATION.allow_missing_root);
assert_eq!(RELAXED_VALIDATION, ValidationConfig::RELAXED);
}
#[test]
fn default_is_strict() {
assert_eq!(ValidationConfig::default(), ValidationConfig::STRICT);
}
}