use std::fmt;
use crate::CaseStyle;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct CaseStyleValidationError {
style: CaseStyle,
value: String,
}
impl CaseStyleValidationError {
#[inline]
pub fn new(style: CaseStyle, value: impl Into<String>) -> Self {
Self {
style,
value: value.into(),
}
}
#[inline]
pub const fn style(&self) -> CaseStyle {
self.style
}
#[inline]
pub fn value(&self) -> &str {
&self.value
}
}
impl fmt::Display for CaseStyleValidationError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"Value '{}' does not match case style '{}'.",
self.value,
self.style.name(),
)
}
}
impl std::error::Error for CaseStyleValidationError {}