[−][src]Struct form_validation::ValidationError
An error associated with a form field.
Fields
key: Key
The key for the field that this validation error is associated with.
type_id: &'static str
An identifier for the type of error this is.
Implementations
impl<Key> ValidationError<Key>
[src]
pub fn new(key: Key, type_id: &'static str) -> Self
[src]
Create a new ValidationError
with a generic message, and
specify the type_id which allows
the error type to be identified programatically.
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_fn: F
) -> Self
[src]
self,
message_fn: F
) -> Self
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", "NOT_LESS_THAN_0") .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()); assert_eq!("NOT_LESS_THAN_0", error.type_id);
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,
fn source(&self) -> Option<&(dyn Error + 'static)>
1.30.0[src]
fn backtrace(&self) -> Option<&Backtrace>
[src]
fn description(&self) -> &str
1.0.0[src]
fn cause(&self) -> Option<&dyn Error>
1.0.0[src]
impl<Key> From<ValidationError<Key>> for ValidationErrors<Key> where
Key: Clone + PartialEq,
[src]
Key: Clone + PartialEq,
fn from(err: ValidationError<Key>) -> Self
[src]
impl<Key> PartialEq<ValidationError<Key>> for ValidationError<Key> where
Key: PartialEq,
[src]
Key: PartialEq,
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<T, U> TryInto<U> for T where
U: TryFrom<T>,
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>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,