use thiserror::Error;
pub use invariant_core::models::error::AuthorityError;
#[derive(Debug, Error, PartialEq)]
pub enum ValidationError {
#[error("operation string is invalid (empty, whitespace, or disallowed characters): {0:?}")]
InvalidOperation(String),
#[error("authority chain must have at least one hop")]
EmptyAuthorityChain,
#[error("collection '{name}' has {count} elements, exceeding maximum of {max}")]
CollectionTooLarge {
name: &'static str,
count: usize,
max: usize,
},
#[error("profile field '{field}' invalid: {reason}")]
ProfileFieldInvalid {
field: &'static str,
reason: String,
},
#[error("bundle field '{field}' invalid: {reason}")]
BundleFieldInvalid {
field: &'static str,
reason: String,
},
}
pub trait Validate {
fn validate(&self) -> Result<(), ValidationError>;
}