[][src]Enum es_htmlform::types::Constraint

pub enum Constraint<'a> {
    MinLength(usize),
    MaxLength(usize),
    MinNumber(f64),
    MaxNumber(f64),
    MinDate(&'a str),
    MaxDate(&'a str),
    MinDateTime(&'a str),
    MaxDateTime(&'a str),
    MinTime(&'a str),
    MaxTime(&'a str),
    Pattern(&'a str),
    Func(Box<dyn Fn(&Value) -> Result<(), ValidationError>>),
}

Constraints on Field values, perform validation.

All of the constraints cause server-side validation to be performed, all except Constraint::Func should - assuming they're serialized properly - result in client-side validation. HTML validity is checked when adding the constraints to the fields using HtmlForm's builder methods.

Variants

MinLength(usize)

Constraint on most inputs.

MaxLength(usize)

Constraint on most inputs.

MinNumber(f64)

Constraint on number and range inputs.

MaxNumber(f64)

Constraint on number and range inputs.

MinDate(&'a str)

Constraint on date input.

MaxDate(&'a str)

Constraint on date input.

MinDateTime(&'a str)

Constraint on datetime-local input.

MaxDateTime(&'a str)

Constraint on datetime-local input.

MinTime(&'a str)

Constraint on time input.

MaxTime(&'a str)

Constraint on time input.

Pattern(&'a str)

Constraint on most Element::Input fields, causes regex pattern validation (both on the server and the client, note that the pattern therefore must execute correctly on both sides).

Func(Box<dyn Fn(&Value) -> Result<(), ValidationError>>)

Constraint on any field, is executed server-side only and not serialized.

Methods

impl<'a> Constraint<'a>[src]

pub fn validate(&self, formvalue: &Value) -> Result<(), ValidationError>[src]

Validate a single, non-empty Value.

pub fn attrpair(&self) -> Option<(String, String)>[src]

Returns the name and value of the HTML attribute of the Constraint.

Returns None for Constraint::Func, as that is only functional on the server side.

pub fn allowed_on(&self, element: &Element) -> bool[src]

Return true if this Constraint is allowed on element, false otherwise.

Trait Implementations

impl<'a> Debug for Constraint<'a>[src]

Auto Trait Implementations

impl<'a> !Send for Constraint<'a>

impl<'a> !Sync for Constraint<'a>

impl<'a> Unpin for Constraint<'a>

impl<'a> !UnwindSafe for Constraint<'a>

impl<'a> !RefUnwindSafe for Constraint<'a>

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]