Struct validator::ValidationErrors
source · pub struct ValidationErrors(pub HashMap<&'static str, ValidationErrorsKind>);
Tuple Fields§
§0: HashMap<&'static str, ValidationErrorsKind>
Implementations§
source§impl ValidationErrors
impl ValidationErrors
pub fn new() -> ValidationErrors
sourcepub fn has_error(
result: &Result<(), ValidationErrors>,
field: &'static str
) -> bool
pub fn has_error( result: &Result<(), ValidationErrors>, field: &'static str ) -> bool
Returns a boolean indicating whether a validation result includes validation errors for a given field. May be used as a condition for performing nested struct validations on a field in the absence of field-level validation errors.
pub fn merge_self( &mut self, field: &'static str, child: Result<(), ValidationErrors> ) -> &mut ValidationErrors
sourcepub fn merge(
parent: Result<(), ValidationErrors>,
field: &'static str,
child: Result<(), ValidationErrors>
) -> Result<(), ValidationErrors>
pub fn merge( parent: Result<(), ValidationErrors>, field: &'static str, child: Result<(), ValidationErrors> ) -> Result<(), ValidationErrors>
Returns the combined outcome of a struct’s validation result along with the nested validation result for one of its fields.
sourcepub fn merge_all(
parent: Result<(), ValidationErrors>,
field: &'static str,
children: Vec<Result<(), ValidationErrors>>
) -> Result<(), ValidationErrors>
pub fn merge_all( parent: Result<(), ValidationErrors>, field: &'static str, children: Vec<Result<(), ValidationErrors>> ) -> Result<(), ValidationErrors>
Returns the combined outcome of a struct’s validation result along with the nested validation result for one of its fields where that field is a vector of validating structs.
sourcepub fn errors(&self) -> &HashMap<&'static str, ValidationErrorsKind>
pub fn errors(&self) -> &HashMap<&'static str, ValidationErrorsKind>
Returns a map of field-level validation errors found for the struct that was validated and any of it’s nested structs that are tagged for validation.
sourcepub fn errors_mut(&mut self) -> &mut HashMap<&'static str, ValidationErrorsKind>
pub fn errors_mut(&mut self) -> &mut HashMap<&'static str, ValidationErrorsKind>
Returns a mutable map of field-level validation errors found for the struct that was validated and any of it’s nested structs that are tagged for validation.
sourcepub fn into_errors(self) -> HashMap<&'static str, ValidationErrorsKind>
pub fn into_errors(self) -> HashMap<&'static str, ValidationErrorsKind>
Consume the struct, returning the validation errors found
sourcepub fn field_errors(&self) -> HashMap<&'static str, &Vec<ValidationError>>
pub fn field_errors(&self) -> HashMap<&'static str, &Vec<ValidationError>>
Returns a map of only field-level validation errors found for the struct that was validated.
pub fn add(&mut self, field: &'static str, error: ValidationError)
pub fn is_empty(&self) -> bool
Trait Implementations§
source§impl Clone for ValidationErrors
impl Clone for ValidationErrors
source§fn clone(&self) -> ValidationErrors
fn clone(&self) -> ValidationErrors
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ValidationErrors
impl Debug for ValidationErrors
source§impl Default for ValidationErrors
impl Default for ValidationErrors
source§fn default() -> ValidationErrors
fn default() -> ValidationErrors
source§impl Display for ValidationErrors
impl Display for ValidationErrors
source§impl Error for ValidationErrors
impl Error for ValidationErrors
source§fn description(&self) -> &str
fn description(&self) -> &str
source§fn cause(&self) -> Option<&dyn Error>
fn cause(&self) -> Option<&dyn Error>
source§impl PartialEq for ValidationErrors
impl PartialEq for ValidationErrors
source§fn eq(&self, other: &ValidationErrors) -> bool
fn eq(&self, other: &ValidationErrors) -> bool
self
and other
values to be equal, and is used
by ==
.