pub struct ValidatorChain(/* private fields */);Expand description
Validator that runs several validators in order.
The value is valid when every validator accepts it; the error of the first failing
validator is returned. #[derive(Table)] uses it when a column declares more than one
#[validate(...)] attribute, keeping the declaration order (top to bottom).
§Example
use wasm_dbms_api::prelude::{
MaxStrlenValidator, MinStrlenValidator, Validate as _, ValidatorChain, Value,
};
let validator = ValidatorChain::new(vec![
Box::new(MinStrlenValidator(2)),
Box::new(MaxStrlenValidator(5)),
]);
assert!(validator.validate(&Value::Text("abc".into())).is_ok());
assert!(validator.validate(&Value::Text("a".into())).is_err());
assert!(validator.validate(&Value::Text("abcdef".into())).is_err());Implementations§
Trait Implementations§
Source§impl Debug for ValidatorChain
impl Debug for ValidatorChain
Source§impl Validate for ValidatorChain
impl Validate for ValidatorChain
Source§fn validate(&self, value: &Value) -> DbmsResult<()>
fn validate(&self, value: &Value) -> DbmsResult<()>
Validates the given
crate::prelude::Value. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for ValidatorChain
impl !Send for ValidatorChain
impl !Sync for ValidatorChain
impl !UnwindSafe for ValidatorChain
impl Freeze for ValidatorChain
impl Unpin for ValidatorChain
impl UnsafeUnpin for ValidatorChain
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more