1use std::fmt;
2
3#[derive(Debug, Clone, PartialEq)]
5pub struct ValidationError {
6 pub rule_name: String,
8 pub missing_keys: Vec<String>,
10}
11
12impl ValidationError {
13 pub(crate) fn new(rule_name: &str, missing_keys: Vec<String>) -> Self {
14 Self {
15 rule_name: rule_name.to_owned(),
16 missing_keys,
17 }
18 }
19}
20
21impl fmt::Display for ValidationError {
22 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
23 write!(
24 f,
25 "rule '{}' validation failed: missing context keys: [{}]",
26 self.rule_name,
27 self.missing_keys.join(", ")
28 )
29 }
30}
31
32impl std::error::Error for ValidationError {}