pub struct ValidationCollector { /* private fields */ }Expand description
Helper for collecting multiple validation results
Implementations§
Source§impl ValidationCollector
impl ValidationCollector
Sourcepub fn new() -> ValidationCollector
pub fn new() -> ValidationCollector
Create a new collector
Sourcepub fn collect<T>(&mut self, result: Result<T, ValidationErrors>) -> Option<T>
pub fn collect<T>(&mut self, result: Result<T, ValidationErrors>) -> Option<T>
Add a validation result, collecting any errors
Sourcepub fn collect_field<T>(
&mut self,
field: impl Into<String>,
result: Result<T, ValidationErrors>,
) -> Option<T>
pub fn collect_field<T>( &mut self, field: impl Into<String>, result: Result<T, ValidationErrors>, ) -> Option<T>
Add a validation result for a specific field
Sourcepub fn has_errors(&self) -> bool
pub fn has_errors(&self) -> bool
Check if any errors were collected
Sourcepub fn errors(&self) -> &ValidationErrors
pub fn errors(&self) -> &ValidationErrors
Get the collected errors
Sourcepub fn finish(self) -> Result<(), ValidationErrors>
pub fn finish(self) -> Result<(), ValidationErrors>
Finish collecting and return the result
Sourcepub fn finish_with<T>(self, value: T) -> Result<T, ValidationErrors>
pub fn finish_with<T>(self, value: T) -> Result<T, ValidationErrors>
Finish with a value if no errors
Trait Implementations§
Source§impl Default for ValidationCollector
impl Default for ValidationCollector
Source§fn default() -> ValidationCollector
fn default() -> ValidationCollector
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ValidationCollector
impl RefUnwindSafe for ValidationCollector
impl Send for ValidationCollector
impl Sync for ValidationCollector
impl Unpin for ValidationCollector
impl UnwindSafe for ValidationCollector
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