1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
//! Core validation types for the Term data quality library.
//!
//! This module provides the fundamental types for defining and executing
//! data validation suites, including checks, constraints, and results.
//!
//! ## Overview
//!
//! The core module contains the essential building blocks for data validation:
//!
//! - **[`ValidationSuite`]**: A collection of checks to run against your data
//! - **[`Check`]**: A named group of related constraints with a severity level
//! - **[`Constraint`]**: Individual validation rules (implemented in the `constraints` module)
//! - **[`Level`]**: Severity levels for checks (Error, Warning, Info)
//! - **[`ValidationResult`]**: Results from running a validation suite
//!
//! ## Architecture
//!
//! ```text
//! ValidationSuite
//! ├── Check (Level: Error)
//! │ ├── Constraint 1
//! │ └── Constraint 2
//! └── Check (Level: Warning)
//! ├── Constraint 3
//! └── Constraint 4
//! ```
//!
//! ## Example
//!
//! ```rust
//! use term_guard::core::{ValidationSuite, Check, Level, ValidationResult};
//! use term_guard::core::builder_extensions::{CompletenessOptions, StatisticalOptions};
//! use term_guard::constraints::{Assertion, FormatType, FormatOptions};
//! use datafusion::prelude::*;
//!
//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
//! // Build a validation suite using the unified API
//! let suite = ValidationSuite::builder("customer_validation")
//! .description("Validate customer data quality")
//! .check(
//! Check::builder("critical_fields")
//! .level(Level::Error)
//! .description("Critical fields must be valid")
//! // Unified API for completeness
//! .completeness("customer_id", CompletenessOptions::full().into_constraint_options())
//! .completeness("email", CompletenessOptions::threshold(0.99).into_constraint_options())
//! // Convenience method for primary key validation
//! .primary_key(vec!["customer_id"])
//! .build()
//! )
//! .check(
//! Check::builder("data_quality")
//! .level(Level::Warning)
//! // Format validation API
//! .has_format("email", FormatType::Email, 0.95, FormatOptions::default())
//! // Combined statistics in one query
//! .statistics(
//! "age",
//! StatisticalOptions::new()
//! .min(Assertion::GreaterThanOrEqual(18.0))
//! .max(Assertion::LessThan(120.0))
//! )?
//! .build()
//! )
//! .build();
//!
//! // Create context and register data
//! let ctx = SessionContext::new();
//! // ... register your customer table ...
//!
//! // Run validation
//! let results = suite.run(&ctx).await?;
//!
//! // Process results
//! match results {
//! ValidationResult::Success { report, .. } => {
//! println!("All validations passed!");
//! for issue in &report.issues {
//! if issue.level == Level::Warning {
//! println!("Warning: {}", issue.message);
//! }
//! }
//! }
//! ValidationResult::Failure { report } => {
//! println!("Validation failures:");
//! for issue in &report.issues {
//! if issue.level == Level::Error {
//! println!("Error in '{}': {}", issue.check_name, issue.message);
//! }
//! }
//! }
//! }
//! # Ok(())
//! # }
//! ```
//!
//! ## Constraint Status
//!
//! Each constraint evaluation returns a status:
//!
//! - **Success**: The constraint passed
//! - **Failure**: The constraint failed
//! - **Skipped**: The constraint was skipped (e.g., no data)
//!
//! ## Performance Considerations
//!
//! - Constraints within a check may be optimized to run in a single query
//! - Use the `with_optimizer(true)` option on ValidationSuite for best performance
//! - Group related constraints in the same Check when possible
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use Level;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;