[−][src]Struct form_validation::ValidationError
An error associated with a form field.
Fields
key: KeyThe key for the field that this validation error is associated with.
Implementations
impl<Key> ValidationError<Key>[src]
pub fn new(key: Key) -> Self[src]
Create a new ValidationError with a generic message.
pub fn message<S: Into<String>>(self, message: S) -> Self[src]
Factory method to set the message for this error.
pub fn with_message<F: Fn(&Key) -> String + 'static>(self, message: F) -> Self[src]
Factory method to set the message for this error from a
function that returns a String.
Example
use form_validation::ValidationError; let value = -10; let error = ValidationError::new("field1").with_message(move |key| { format!( "The value of {} ({}) cannot be less than 0", key, value) }); assert_eq!("The value of field1 (-10) cannot be less than 0", error.to_string());
Trait Implementations
impl<Key> Clone for ValidationError<Key> where
Key: Clone, [src]
Key: Clone,
fn clone(&self) -> Self[src]
fn clone_from(&mut self, source: &Self)1.0.0[src]
impl<Key> Debug for ValidationError<Key> where
Key: Debug, [src]
Key: Debug,
impl<Key> Display for ValidationError<Key>[src]
impl<Key> Error for ValidationError<Key> where
Key: Debug, [src]
Key: Debug,
Auto Trait Implementations
impl<Key> !RefUnwindSafe for ValidationError<Key>
impl<Key> !Send for ValidationError<Key>
impl<Key> !Sync for ValidationError<Key>
impl<Key> Unpin for ValidationError<Key> where
Key: Unpin,
Key: Unpin,
impl<Key> !UnwindSafe for ValidationError<Key>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T[src]
fn clone_into(&self, target: &mut T)[src]
impl<T> ToString for T where
T: Display + ?Sized, [src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,