use thiserror::Error;
#[derive(Debug, Error, Clone, PartialEq, Eq)]
pub enum ValidationError {
#[error("Input contains {count} dangerous characters: {symbols}")]
DangerousCharacters {
symbols: String,
count: usize,
},
#[error("Input format validation failed for type {target_type}")]
InvalidFormat {
target_type: &'static str,
},
#[error("Input matches blocked pattern: {pattern}")]
BlockedPattern {
pattern: String,
},
#[error("Custom validation failed: {message}")]
Custom {
message: String,
},
}
impl ValidationError {
pub fn custom<S: Into<String>>(message: S) -> Self {
Self::Custom {
message: message.into(),
}
}
}