a2ui_base/validate/
config.rs1#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
11pub struct ValidationConfig {
12 pub allow_orphan_components: bool,
15 pub allow_dangling_references: bool,
18 pub allow_missing_root: bool,
21}
22
23impl ValidationConfig {
24 pub const STRICT: Self = Self {
26 allow_orphan_components: false,
27 allow_dangling_references: false,
28 allow_missing_root: false,
29 };
30
31 pub const RELAXED: Self = Self {
33 allow_orphan_components: true,
34 allow_dangling_references: true,
35 allow_missing_root: true,
36 };
37}
38
39pub const STRICT_VALIDATION: ValidationConfig = ValidationConfig::STRICT;
41pub const RELAXED_VALIDATION: ValidationConfig = ValidationConfig::RELAXED;
43
44#[cfg(test)]
45mod tests {
46 use super::*;
47
48 #[test]
49 fn strict_rejects_everything() {
50 assert!(!STRICT_VALIDATION.allow_orphan_components);
51 assert!(!STRICT_VALIDATION.allow_dangling_references);
52 assert!(!STRICT_VALIDATION.allow_missing_root);
53 assert_eq!(STRICT_VALIDATION, ValidationConfig::STRICT);
54 }
55
56 #[test]
57 fn relaxed_allows_everything() {
58 assert!(RELAXED_VALIDATION.allow_orphan_components);
59 assert!(RELAXED_VALIDATION.allow_dangling_references);
60 assert!(RELAXED_VALIDATION.allow_missing_root);
61 assert_eq!(RELAXED_VALIDATION, ValidationConfig::RELAXED);
62 }
63
64 #[test]
65 fn default_is_strict() {
66 assert_eq!(ValidationConfig::default(), ValidationConfig::STRICT);
67 }
68}