Trait semval::Validate

source ·
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§

source

type Invalidity: Invalidity

Invalidity objectives

Required Methods§

source

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>
where V: Validate + ToOwned + 'a + ?Sized,

source§

impl<'a, V> Validate for &'a V
where V: Validate + ?Sized,

Validate is implemented for any reference of a type that implements Validate.

source§

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.

source§

impl<V> Validate for [V]
where V: Validate,

Validate all elements of a slice

source§

impl<V> Validate for Vec<V>
where V: Validate,

Implementors§