Function rocket::form::validate::dbg_contains
source · pub fn dbg_contains<'v, V, I>(value: V, item: I) -> Result<'v, ()>where
V: Contains<I>,
I: Debug + Copy,
Expand description
Debug contains validator: like contains()
but mentions item
in the
error message.
This is the dual of dbg_omits()
. The is identical to contains()
except that item
must be Debug + Copy
and the error message is as
follows, where $item
is the Debug
representation of item
:
values must contains $item
If the collection is empty, this validator fails.
Example
use rocket::form::{FromForm, FromFormField};
#[derive(PartialEq, Debug, Clone, Copy, FromFormField)]
enum Pet { Cat, Dog }
#[derive(FromForm)]
struct Foo {
best_pet: Pet,
#[field(validate = dbg_contains(Pet::Dog))]
#[field(validate = dbg_contains(&self.best_pet))]
pets: Vec<Pet>,
}