use std::collections::HashMap;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ValidationConfig {
pub strict_mode: bool,
pub max_depth: usize,
pub enable_caching: bool,
pub cache_size_limit: usize,
pub enable_parallel_validation: bool,
pub custom_rules: HashMap<String, String>,
pub detailederrors: bool,
pub performance_mode: bool,
}
impl Default for ValidationConfig {
fn default() -> Self {
Self {
strict_mode: false,
max_depth: 100,
enable_caching: true,
cache_size_limit: 1000,
enable_parallel_validation: false, custom_rules: HashMap::new(),
detailederrors: true,
performance_mode: false,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
pub enum ErrorSeverity {
Warning,
Error,
Critical,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum QualityIssueType {
MissingData,
InvalidNumeric,
OutOfRange,
FormatInconsistency,
Outlier,
Duplicate,
TypeMismatch,
ConstraintViolation,
Performance,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum ValidationErrorType {
MissingRequiredField,
TypeMismatch,
ConstraintViolation,
InvalidFormat,
OutOfRange,
InvalidArraySize,
DuplicateValues,
IntegrityFailure,
CustomRuleFailure,
SchemaError,
ShapeError,
InvalidNumeric,
StatisticalViolation,
Performance,
IntegrityError,
TypeConversion,
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_default_config() {
let config = ValidationConfig::default();
assert!(!config.strict_mode);
assert_eq!(config.max_depth, 100);
assert!(config.enable_caching);
assert_eq!(config.cache_size_limit, 1000);
assert!(!config.enable_parallel_validation);
assert!(config.detailederrors);
assert!(!config.performance_mode);
}
#[test]
fn testerror_severity_ordering() {
assert!(ErrorSeverity::Warning < ErrorSeverity::Error);
assert!(ErrorSeverity::Error < ErrorSeverity::Critical);
}
#[test]
fn test_quality_issue_types() {
let issue_type = QualityIssueType::MissingData;
assert_eq!(issue_type, QualityIssueType::MissingData);
}
#[test]
fn test_validationerrortypes() {
let errortype = ValidationErrorType::TypeMismatch;
assert_eq!(errortype, ValidationErrorType::TypeMismatch);
}
}