pub struct ValidationErrors {
pub errors: HashMap<String, Vec<ValidationError>>,
}
Expand description
Collection of validation errors, typically one per field
Fields§
§errors: HashMap<String, Vec<ValidationError>>
Map of field names to their validation errors
Implementations§
Source§impl ValidationErrors
impl ValidationErrors
Sourcepub fn add(&mut self, error: ValidationError)
pub fn add(&mut self, error: ValidationError)
Add a single validation error
Sourcepub fn add_errors(
&mut self,
field: impl Into<String>,
errors: Vec<ValidationError>,
)
pub fn add_errors( &mut self, field: impl Into<String>, errors: Vec<ValidationError>, )
Add multiple validation errors for a field
Sourcepub fn add_error(
&mut self,
field: impl Into<String>,
message: impl Into<String>,
)
pub fn add_error( &mut self, field: impl Into<String>, message: impl Into<String>, )
Add a simple validation error with field and message
Sourcepub fn total_errors(&self) -> usize
pub fn total_errors(&self) -> usize
Get total number of validation errors across all fields
Sourcepub fn get_field_errors(&self, field: &str) -> Option<&Vec<ValidationError>>
pub fn get_field_errors(&self, field: &str) -> Option<&Vec<ValidationError>>
Get errors for a specific field
Sourcepub fn has_field_errors(&self, field: &str) -> bool
pub fn has_field_errors(&self, field: &str) -> bool
Check if a specific field has errors
Sourcepub fn merge(&mut self, other: ValidationErrors)
pub fn merge(&mut self, other: ValidationErrors)
Merge another ValidationErrors into this one
Sourcepub fn from_error(error: ValidationError) -> Self
pub fn from_error(error: ValidationError) -> Self
Create ValidationErrors from a single error
Trait Implementations§
Source§impl Clone for ValidationErrors
impl Clone for ValidationErrors
Source§fn clone(&self) -> ValidationErrors
fn clone(&self) -> ValidationErrors
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for ValidationErrors
impl Debug for ValidationErrors
Source§impl Default for ValidationErrors
impl Default for ValidationErrors
Source§impl<'de> Deserialize<'de> for ValidationErrors
impl<'de> Deserialize<'de> for ValidationErrors
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for ValidationErrors
impl Display for ValidationErrors
Source§impl Error for ValidationErrors
impl Error for ValidationErrors
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
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
Source§impl From<ValidationError> for ValidationErrors
impl From<ValidationError> for ValidationErrors
Source§fn from(error: ValidationError) -> Self
fn from(error: ValidationError) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for ValidationErrors
impl RefUnwindSafe for ValidationErrors
impl Send for ValidationErrors
impl Sync for ValidationErrors
impl Unpin for ValidationErrors
impl UnwindSafe for ValidationErrors
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