scirs2_core/validation/data/
config.rs1use std::collections::HashMap;
7
8use serde::{Deserialize, Serialize};
9
10#[derive(Debug, Clone, Serialize, Deserialize)]
12pub struct ValidationConfig {
13 pub strict_mode: bool,
15 pub max_depth: usize,
17 pub enable_caching: bool,
19 pub cache_size_limit: usize,
21 pub enable_parallel_validation: bool,
23 pub custom_rules: HashMap<String, String>,
25 pub detailederrors: bool,
27 pub performance_mode: bool,
29}
30
31impl Default for ValidationConfig {
32 fn default() -> Self {
33 Self {
34 strict_mode: false,
35 max_depth: 100,
36 enable_caching: true,
37 cache_size_limit: 1000,
38 enable_parallel_validation: false, custom_rules: HashMap::new(),
40 detailederrors: true,
41 performance_mode: false,
42 }
43 }
44}
45
46#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
48pub enum ErrorSeverity {
49 Warning,
51 Error,
53 Critical,
55}
56
57#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
59pub enum QualityIssueType {
60 MissingData,
62 InvalidNumeric,
64 OutOfRange,
66 FormatInconsistency,
68 Outlier,
70 Duplicate,
72 TypeMismatch,
74 ConstraintViolation,
76 Performance,
78}
79
80#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
82pub enum ValidationErrorType {
83 MissingRequiredField,
85 TypeMismatch,
87 ConstraintViolation,
89 InvalidFormat,
91 OutOfRange,
93 InvalidArraySize,
95 DuplicateValues,
97 IntegrityFailure,
99 CustomRuleFailure,
101 SchemaError,
103 ShapeError,
105 InvalidNumeric,
107 StatisticalViolation,
109 Performance,
111 IntegrityError,
113 TypeConversion,
115}
116
117#[cfg(test)]
118mod tests {
119 use super::*;
120
121 #[test]
122 fn test_default_config() {
123 let config = ValidationConfig::default();
124 assert!(!config.strict_mode);
125 assert_eq!(config.max_depth, 100);
126 assert!(config.enable_caching);
127 assert_eq!(config.cache_size_limit, 1000);
128 assert!(!config.enable_parallel_validation);
129 assert!(config.detailederrors);
130 assert!(!config.performance_mode);
131 }
132
133 #[test]
134 fn testerror_severity_ordering() {
135 assert!(ErrorSeverity::Warning < ErrorSeverity::Error);
136 assert!(ErrorSeverity::Error < ErrorSeverity::Critical);
137 }
138
139 #[test]
140 fn test_quality_issue_types() {
141 let issue_type = QualityIssueType::MissingData;
142 assert_eq!(issue_type, QualityIssueType::MissingData);
143 }
144
145 #[test]
146 fn test_validationerrortypes() {
147 let errortype = ValidationErrorType::TypeMismatch;
148 assert_eq!(errortype, ValidationErrorType::TypeMismatch);
149 }
150}