pub struct ValidateErrorCollector(pub Vec<(String, Box<dyn LocaleMessage>)>);
Expand description
A struct for collecting validation errors in a list.
ValidateErrorCollector
is used to gather validation errors that can be
associated with a specific field or key. Each error is stored as a tuple containing:
- A
String
representing the field or key name where the error occurred. - A
Box<dyn LocaleMessage>
representing a localized error message.
§Fields
0
: A vector of tuples, each tuple containing a field name asString
and a localized error message asBox<dyn LocaleMessage>
.
Note: The LocaleMessage
trait is used to encapsulate errors with localization support.
Implementations of LocaleMessage
should provide mechanisms for translating error messages
to various locales.
Tuple Fields§
§0: Vec<(String, Box<dyn LocaleMessage>)>
Implementations§
Source§impl ValidateErrorCollector
impl ValidateErrorCollector
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Checks whether the container is empty.
This method returns true
if the container has no elements, and false
otherwise.
§Returns
true
- If the container is empty.false
- If the container contains one or more elements.
§Examples
use cjtoolkit_structured_validator::common::locale::ValidateErrorCollector;
let container = ValidateErrorCollector::new();
assert!(container.is_empty());
Sourcepub fn push(&mut self, error: (String, Box<dyn LocaleMessage>))
pub fn push(&mut self, error: (String, Box<dyn LocaleMessage>))
Adds an error item to the collection.
§Parameters
error
: A tuple containing:- A
String
representing the error message or identifier. - A
Box<dyn LocaleMessage>
which encapsulates a trait object implementingLocaleMessage
. This provides localized details for the error.
- A
§Behavior
Appends the given error
tuple to the internal vector storing errors.
Trait Implementations§
Source§impl Default for ValidateErrorCollector
impl Default for ValidateErrorCollector
Source§fn default() -> ValidateErrorCollector
fn default() -> ValidateErrorCollector
Returns the “default value” for a type. Read more
Source§impl Into<ValidateErrorCollector> for ValidateErrorStore
impl Into<ValidateErrorCollector> for ValidateErrorStore
Source§fn into(self) -> ValidateErrorCollector
fn into(self) -> ValidateErrorCollector
Converts this type into the (usually inferred) input type.
Source§impl Into<ValidateErrorStore> for ValidateErrorCollector
impl Into<ValidateErrorStore> for ValidateErrorCollector
Source§fn into(self) -> ValidateErrorStore
fn into(self) -> ValidateErrorStore
Converts this type into the (usually inferred) input type.
Auto Trait Implementations§
impl Freeze for ValidateErrorCollector
impl !RefUnwindSafe for ValidateErrorCollector
impl Send for ValidateErrorCollector
impl Sync for ValidateErrorCollector
impl Unpin for ValidateErrorCollector
impl !UnwindSafe for ValidateErrorCollector
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