pub trait Validate {
type Invalidity: Invalidity;
// Required method
fn validate(&self) -> ValidationResult<Self::Invalidity>;
}
Expand description
A trait for validating types
Validation is expected to be an expensive operation that should only be invoked when crossing boundaries between independent components.
Required Associated Types§
sourcetype Invalidity: Invalidity
type Invalidity: Invalidity
Invalidity objectives
Required Methods§
sourcefn validate(&self) -> ValidationResult<Self::Invalidity>
fn validate(&self) -> ValidationResult<Self::Invalidity>
Perform the validation
§Errors
Returns Err
with the collected invalidities if one or more
validations failed.
Implementations on Foreign Types§
source§impl<'a, V> Validate for Cow<'a, V>
impl<'a, V> Validate for Cow<'a, V>
type Invalidity = <V as Validate>::Invalidity
fn validate(&self) -> ValidationResult<Self::Invalidity>
source§impl<'a, V> Validate for &'a V
impl<'a, V> Validate for &'a V
Validate
is implemented for any reference of a type
that implements Validate
.
type Invalidity = <V as Validate>::Invalidity
fn validate(&self) -> ValidationResult<Self::Invalidity>
source§impl<V> Validate for Option<V>where
V: Validate,
impl<V> Validate for Option<V>where
V: Validate,
Validate Some
or otherwise implicitly evaluate to Ok
in case of None
If the absence of an optional value is considered a validation error this must be checked separately.
type Invalidity = <V as Validate>::Invalidity
fn validate(&self) -> ValidationResult<Self::Invalidity>
source§impl<V> Validate for [V]where
V: Validate,
impl<V> Validate for [V]where
V: Validate,
Validate all elements of a slice