Struct validations::Errors [] [src]

pub struct Errors<T> where T: Debug + Any {
    // some fields omitted
}

A collection of errors returned by a failed validation.

Methods

impl<T> Errors<T> where T: Debug + Any
[src]

fn new() -> Self

Constructs an empty Errors value.

fn add_error(&mut self, error: Error<T>)

Adds a validation error that is not specific to any field.

fn add_field_error<S>(&mut self, field: S, error: Error<T>) where S: Into<String>

Adds a validation error for the given field.

Calling this method will overwrite any errors assigned via set_field_errors.

fn base<'a>(&'a self) -> Option<&'a [Error<T>]>

A slice of non-field-specific errors, if any.

fn field<F>(&self, field: F) -> Option<&Box<Errors<T>>> where F: Into<String>

The Errors for the given field, if any.

fn is_empty(&self) -> bool

Returns true if there are no errors.

fn set_field_errors<S>(&mut self, field: S, errors: Errors<T>) where S: Into<String>

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

impl<T> Display for Errors<T> where T: Debug + Any
[src]

fn fmt(&self, f: &mut Formatter) -> FmtResult

impl<T> StdError for Errors<T> where T: Debug + Any
[src]

fn description(&self) -> &str

fn cause(&self) -> Option<&Error>
1.0.0

Derived Implementations

impl<T: Debug> Debug for Errors<T> where T: Debug + Any
[src]

fn fmt(&self, __arg_0: &mut Formatter) -> Result