pub struct Errors<T>{ /* private fields */ }
Expand description
A collection of errors returned by a failed validation.
Implementations§
Source§impl<T> Errors<T>
impl<T> Errors<T>
Sourcepub fn add_error(&mut self, error: Error<T>)
pub fn add_error(&mut self, error: Error<T>)
Adds a validation error that is not specific to any field.
Sourcepub fn add_field_error<S>(&mut self, field: S, error: Error<T>)
pub fn add_field_error<S>(&mut self, field: S, error: Error<T>)
Adds a validation error for the given field.
Calling this method will overwrite any errors assigned via set_field_errors
.
Sourcepub fn base<'a>(&'a self) -> Option<&'a [Error<T>]>
pub fn base<'a>(&'a self) -> Option<&'a [Error<T>]>
A slice of non-field-specific errors, if any.
Sourcepub fn field<F>(&self, field: F) -> Option<&Box<Errors<T>>>
pub fn field<F>(&self, field: F) -> Option<&Box<Errors<T>>>
The Errors
for the given field, if any.
Sourcepub fn set_field_errors<S>(&mut self, field: S, errors: Errors<T>)
pub fn set_field_errors<S>(&mut self, field: S, errors: Errors<T>)
Sets the given field’s errors to the given Errors
.
This is useful if the field itself implements Validate
. In that case, the parent type can
simply delegate to the field to validate itself and assign the resulting errors using this
method.
Calling this method will overwrite any field errors previously added with
add_field_error
.
Trait Implementations§
Source§impl<T> Error for Errors<T>
impl<T> Error for Errors<T>
Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
Auto Trait Implementations§
impl<T> Freeze for Errors<T>
impl<T> RefUnwindSafe for Errors<T>where
T: RefUnwindSafe,
impl<T> Send for Errors<T>where
T: Send,
impl<T> Sync for Errors<T>where
T: Sync,
impl<T> Unpin for Errors<T>where
T: Unpin,
impl<T> UnwindSafe for Errors<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more