pub enum Level {
Info = 0,
Warning = 1,
Error = 2,
}Expand description
The severity level of a validation check.
This enum represents different levels of importance for validation checks, allowing users to categorize issues by their impact on data quality. Levels are ordered by severity: Error > Warning > Info.
§Usage Guidelines
-
Error: Use for critical data quality issues that prevent processing
- Missing required fields
- Primary key violations
- Data integrity violations
- Invalid data formats that break downstream systems
-
Warning: Use for issues that should be investigated but don’t block processing
- Data quality below expected thresholds
- Unusual patterns or outliers
- Missing optional but recommended fields
- Performance-impacting data issues
-
Info: Use for informational metrics and observations
- Data distribution statistics
- Row counts and cardinality metrics
- Performance benchmarks
- Data profiling results
§Examples
use term_guard::core::{Check, Level, ConstraintOptions};
use term_guard::constraints::Assertion;
// Critical validations that must pass
let critical_check = Check::builder("required_fields")
.level(Level::Error)
.completeness("transaction_id", ConstraintOptions::new().with_threshold(1.0))
.completeness("amount", ConstraintOptions::new().with_threshold(1.0))
.build();
// Quality checks that flag potential issues
let quality_check = Check::builder("data_quality")
.level(Level::Warning)
.completeness("email", ConstraintOptions::new().with_threshold(0.95))
.validates_regex("phone", r"^\+?\d{3}-\d{3}-\d{4}$", 0.90)
.build();
// Informational metrics
let metrics_check = Check::builder("data_profile")
.level(Level::Info)
.has_size(Assertion::GreaterThan(0.0))
.has_mean("order_value", Assertion::Between(10.0, 1000.0))
.build();§Comparison
use term_guard::core::Level;
let critical_level = Level::Error;
let warning_level = Level::Warning;
let info_level = Level::Info;
assert!(critical_level > warning_level);
assert!(warning_level > info_level);Variants§
Info = 0
Informational level - Used for metrics and non-critical observations
Warning = 1
Warning level - Indicates potential issues that should be reviewed
Error = 2
Error level - Indicates critical data quality issues that must be addressed
Implementations§
Source§impl Level
impl Level
Sourcepub fn is_at_least(&self, other: Level) -> bool
pub fn is_at_least(&self, other: Level) -> bool
Checks if this level is at least as severe as another level.
§Examples
use term_guard::core::Level;
assert!(Level::Error.is_at_least(Level::Warning));
assert!(Level::Warning.is_at_least(Level::Warning));
assert!(!Level::Info.is_at_least(Level::Error));Trait Implementations§
Source§impl<'de> Deserialize<'de> for Level
impl<'de> Deserialize<'de> for Level
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Ord for Level
impl Ord for Level
Source§impl PartialOrd for Level
impl PartialOrd for Level
impl Copy for Level
impl Eq for Level
impl StructuralPartialEq for Level
Auto Trait Implementations§
impl Freeze for Level
impl RefUnwindSafe for Level
impl Send for Level
impl Sync for Level
impl Unpin for Level
impl UnwindSafe for Level
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more