pub struct ValidationErrors {
pub field_errors: HashMap<String, Vec<String>>,
pub form_errors: Vec<String>,
}Expand description
Validation errors for a form
Fieldsยง
ยงfield_errors: HashMap<String, Vec<String>>ยงform_errors: Vec<String>Implementationsยง
Sourceยงimpl ValidationErrors
impl ValidationErrors
Sourcepub fn add_field_error(&mut self, field_name: &str, error: String)
pub fn add_field_error(&mut self, field_name: &str, error: String)
Add a field error
Sourcepub fn add_form_error(&mut self, error: String)
pub fn add_form_error(&mut self, error: String)
Add a form-level error
Sourcepub fn has_errors(&self) -> bool
pub fn has_errors(&self) -> bool
Check if there are any errors
Sourcepub fn has_field_error(&self, field: &str) -> bool
pub fn has_field_error(&self, field: &str) -> bool
Check if a specific field has errors
Sourcepub fn get_field_error(&self, field: &str) -> Option<&Vec<String>>
pub fn get_field_error(&self, field: &str) -> Option<&Vec<String>>
Get errors for a specific field
Sourcepub fn clear_field(&mut self, field: &str)
pub fn clear_field(&mut self, field: &str)
Clear errors for a specific field
Sourcepub fn remove_field_error(&mut self, field: &str)
pub fn remove_field_error(&mut self, field: &str)
Remove field errors (alias for clear_field)
Sourcepub fn to_field_errors(&self) -> Vec<FieldError>
pub fn to_field_errors(&self) -> Vec<FieldError>
Convert to field errors for compatibility
Sourcepub fn merge(&mut self, other: ValidationErrors)
pub fn merge(&mut self, other: ValidationErrors)
Merge another ValidationErrors into this one
Sourcepub fn get_error_fields(&self) -> Vec<String>
pub fn get_error_fields(&self) -> Vec<String>
Get all field names that have errors
Sourcepub fn error_count(&self) -> usize
pub fn error_count(&self) -> usize
Get total error count
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 (const: unstable) ยท 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 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 PartialEq for ValidationErrors
impl PartialEq for ValidationErrors
Sourceยงfn eq(&self, other: &ValidationErrors) -> bool
fn eq(&self, other: &ValidationErrors) -> bool
Tests for
self and other values to be equal, and is used by ==.impl StructuralPartialEq for ValidationErrors
Auto Trait Implementationsยง
impl Freeze for ValidationErrors
impl RefUnwindSafe for ValidationErrors
impl Send for ValidationErrors
impl Sync for ValidationErrors
impl Unpin for ValidationErrors
impl UnsafeUnpin 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
Sourceยงimpl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Sourceยงimpl<T> IntoEither for T
impl<T> IntoEither for T
Sourceยงfn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSourceยงfn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSourceยงimpl<T> SerializableKey for T
impl<T> SerializableKey for T
Sourceยงimpl<T> StorageAccess<T> for T
impl<T> StorageAccess<T> for T
Sourceยงfn as_borrowed(&self) -> &T
fn as_borrowed(&self) -> &T
Borrows the value.
Sourceยงfn into_taken(self) -> T
fn into_taken(self) -> T
Takes the value.