Skip to main content

Each

Struct Each 

Source
pub struct Each<V>(/* private fields */);
Expand description

Validates every item of a collection with V.

The violation of the first invalid item is reported with its index as parameter index, its code is the code of the violation of the item. For an Option the value is validated if there is one.

use deser_validate::{Each, Email, Validator};

let emails = vec!["jane@example.com".to_string(), "nope".to_string()];
let violation = Each::<Email>::validate(&emails).unwrap_err();
assert_eq!(violation.message(), "item 1: must be an email address");
assert!(Each::<Email>::validate(&None::<String>).is_ok());

Trait Implementations§

Source§

impl<V: Validator<T>, T> Validator<BTreeSet<T>> for Each<V>

Source§

fn validate(value: &BTreeSet<T>) -> Result<(), Violation>

Validates the value.
Source§

impl<V: Validator<T>, T, S> Validator<HashSet<T, S>> for Each<V>

Source§

fn validate(value: &HashSet<T, S>) -> Result<(), Violation>

Validates the value.
Source§

impl<V: Validator<T>, T> Validator<Option<T>> for Each<V>

Source§

fn validate(value: &Option<T>) -> Result<(), Violation>

Validates the value.
Source§

impl<V: Validator<T>, T> Validator<Vec<T>> for Each<V>

Source§

fn validate(value: &Vec<T>) -> Result<(), Violation>

Validates the value.
Source§

impl<V: Validator<T>, T> Validator<VecDeque<T>> for Each<V>

Source§

fn validate(value: &VecDeque<T>) -> Result<(), Violation>

Validates the value.
Source§

impl<V: Validator<T>, T, const N: usize> Validator<[T; N]> for Each<V>

Source§

fn validate(value: &[T; N]) -> Result<(), Violation>

Validates the value.
Source§

impl<V: Validator<T>, T> Validator<[T]> for Each<V>

Source§

fn validate(value: &[T]) -> Result<(), Violation>

Validates the value.

Auto Trait Implementations§

§

impl<V> Freeze for Each<V>
where PhantomData<fn() -> V>: Freeze,

§

impl<V> RefUnwindSafe for Each<V>
where PhantomData<fn() -> V>: RefUnwindSafe,

§

impl<V> Send for Each<V>
where PhantomData<fn() -> V>: Send,

§

impl<V> Sync for Each<V>
where PhantomData<fn() -> V>: Sync,

§

impl<V> Unpin for Each<V>
where PhantomData<fn() -> V>: Unpin,

§

impl<V> UnsafeUnpin for Each<V>
where PhantomData<fn() -> V>: UnsafeUnpin,

§

impl<V> UnwindSafe for Each<V>
where PhantomData<fn() -> V>: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.