pub struct ValidationErrors { /* private fields */ }Expand description
A non-empty collection of ValidationErrors, rendered as a Pydantic-style report.
Extends the Pydantic report with:
fitness— Van der Aalst alignment conformance scorevariant_id— fingerprint for recurring failure patternsby_section— object-centric grouping
2 validation errors for Server
host
must not be empty (got: `""`) [empty]
port
input must be in range 1..=65535 (got: `0`) [out_of_range]Implementations§
Source§impl ValidationErrors
impl ValidationErrors
Sourcepub fn errors(&self) -> &[ValidationError]
pub fn errors(&self) -> &[ValidationError]
The individual errors, in the order they were discovered (depth-first).
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Always false — ValidationErrors only exists when there is ≥ 1 error.
Sourcepub fn set_title_for<T: ?Sized>(&mut self)
pub fn set_title_for<T: ?Sized>(&mut self)
Set the report title to the short name of T (e.g. ServerConfig).
Sourcepub fn has_fatal(&self) -> bool
pub fn has_fatal(&self) -> bool
Whether any error is Severity::Fatal (requires immediate halt).
Sourcepub fn errors_above(
&self,
min: Severity,
) -> impl Iterator<Item = &ValidationError>
pub fn errors_above( &self, min: Severity, ) -> impl Iterator<Item = &ValidationError>
Errors at or above the given severity threshold.
Sourcepub fn fitness(&self) -> f64
pub fn fitness(&self) -> f64
Van der Aalst alignment fitness — proportion of checks that passed.
Returns 1.0 when all checks pass (no errors), 0.0 when every check failed. Analogous to the replay-fitness metric from conformance checking: how well does the observed config align to the declared validation model?
§Example
use star_toml::{Validate, Validator};
struct Pair { a: u32, b: u32 }
impl Validate for Pair {
fn validate(&self, v: &mut Validator) {
v.check_range("a", self.a, 1..=10); // passes
v.check_range("b", self.b, 1..=10); // fails
}
}
let errs = Pair { a: 5, b: 0 }.check().unwrap_err();
assert_eq!(errs.fitness(), 0.5); // 1 of 2 checks passedSourcepub fn variant_id(&self) -> u64
pub fn variant_id(&self) -> u64
Variant fingerprint — a deterministic hash of the failure pattern.
Two ValidationErrors instances with the same set of (location, code)
pairs produce the same variant ID, regardless of message text or input
values. Useful for deduplicating recurring failure patterns across runs.
Uses FNV-1a over the sorted "loc:code" pairs.
Sourcepub fn by_section(&self) -> BTreeMap<String, Vec<&ValidationError>>
pub fn by_section(&self) -> BTreeMap<String, Vec<&ValidationError>>
Object-centric grouping — errors indexed by their top-level config section.
Implements Van der Aalst’s object-centric view: each top-level TOML table is an “object type”; this groups all its constraint violations together.
Root-level errors are keyed "(root)".
Trait Implementations§
Source§impl Clone for ValidationErrors
impl Clone for ValidationErrors
Source§fn clone(&self) -> ValidationErrors
fn clone(&self) -> ValidationErrors
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ValidationErrors
impl Debug for ValidationErrors
Source§impl Display for ValidationErrors
impl Display for ValidationErrors
impl Eq for ValidationErrors
Source§impl Error for ValidationErrors
impl Error for ValidationErrors
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<ValidationErrors> for Error
impl From<ValidationErrors> for Error
Source§fn from(source: ValidationErrors) -> Self
fn from(source: ValidationErrors) -> Self
Source§impl PartialEq for ValidationErrors
impl PartialEq for ValidationErrors
Source§fn eq(&self, other: &ValidationErrors) -> bool
fn eq(&self, other: &ValidationErrors) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for ValidationErrors
Auto Trait Implementations§
impl Freeze for ValidationErrors
impl RefUnwindSafe for ValidationErrors
impl Send for ValidationErrors
impl Sync for ValidationErrors
impl Unpin for ValidationErrors
impl UnsafeUnpin for ValidationErrors
impl UnwindSafe for ValidationErrors
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<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
key and return true if they are equal.