Function rocket::form::validate::dbg_omits

source ·
pub fn dbg_omits<'v, V, I>(value: V, item: I) -> Result<'v, ()>
where V: Contains<I>, I: Copy + Debug,
Expand description

Debug omits validator: like omits() but mentions item in the error message.

This is the dual of dbg_contains(). The is identical to omits() except that item must be Debug + Copy and the error message is as follows, where $item is the Debug representation of item:

value cannot contain $item

If the collection is empty, this validator succeeds.

§Example

use rocket::form::{FromForm, FromFormField};

#[derive(PartialEq, Debug, Clone, Copy, FromFormField)]
enum Pet { Cat, Dog }

#[derive(FromForm)]
struct Foo<'r> {
    #[field(validate = dbg_omits(Pet::Cat))]
    pets: Vec<Pet>,
    #[field(validate = dbg_omits('@'))]
    not_email: &'r str,
    #[field(validate = dbg_omits("@gmail.com"))]
    non_gmail_email: &'r str,
}