1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
use crate::error::ValidationError;
/// Macro to return a new `ValidationError` with an optional message
#[macro_export]
macro_rules! invalid {
() => { $crate::ValidationError::from(None) };
($($arg:tt)+) => {
$crate::ValidationError::from(format!($($arg)+))
};
}
/// Trait for data types which need validation after being loaded from external sources
pub trait Validatable {
fn validate(&self) -> Result<(), ValidationError> {
Ok(())
}
}
