pub struct ValidationResult {
pub valid: bool,
pub errors: Vec<ValidationError>,
pub data: Option<Value>,
}Expand description
Result of validation operation.
Fields§
§valid: boolWhether validation passed
errors: Vec<ValidationError>List of validation errors (empty if valid)
data: Option<Value>Validated/parsed data (None if invalid)
Implementations§
Source§impl ValidationResult
impl ValidationResult
Sourcepub fn failure(errors: Vec<ValidationError>) -> Self
pub fn failure(errors: Vec<ValidationError>) -> Self
Create a failed validation result.
Sourcepub fn from_error(error: ValidationError) -> Self
pub fn from_error(error: ValidationError) -> Self
Create a failure from a single error.
Sourcepub fn from_messages(messages: Vec<String>) -> Self
pub fn from_messages(messages: Vec<String>) -> Self
Create a failure from error messages (without paths).
Sourcepub fn data(&self) -> Option<&Value>
pub fn data(&self) -> Option<&Value>
Get the validated data.
Returns None if validation failed.
Sourcepub fn error_messages(&self) -> Vec<String>
pub fn error_messages(&self) -> Vec<String>
Get errors as formatted strings.
Sourcepub fn merge(results: Vec<ValidationResult>) -> Self
pub fn merge(results: Vec<ValidationResult>) -> Self
Merge multiple validation results.
Returns success only if all results are successful.
Sourcepub fn into_result(self) -> Result<Value, Vec<ValidationError>>
pub fn into_result(self) -> Result<Value, Vec<ValidationError>>
Convert to Result, merging all errors if invalid.
Trait Implementations§
Source§impl Clone for ValidationResult
impl Clone for ValidationResult
Source§fn clone(&self) -> ValidationResult
fn clone(&self) -> ValidationResult
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 ValidationResult
impl Debug for ValidationResult
Source§impl From<ValidationError> for ValidationResult
impl From<ValidationError> for ValidationResult
Source§fn from(error: ValidationError) -> Self
fn from(error: ValidationError) -> Self
Converts to this type from the input type.
Source§impl From<Vec<ValidationError>> for ValidationResult
impl From<Vec<ValidationError>> for ValidationResult
Source§fn from(errors: Vec<ValidationError>) -> Self
fn from(errors: Vec<ValidationError>) -> Self
Converts to this type from the input type.
Source§impl PartialEq for ValidationResult
impl PartialEq for ValidationResult
impl StructuralPartialEq for ValidationResult
Auto Trait Implementations§
impl Freeze for ValidationResult
impl RefUnwindSafe for ValidationResult
impl Send for ValidationResult
impl Sync for ValidationResult
impl Unpin for ValidationResult
impl UnsafeUnpin for ValidationResult
impl UnwindSafe for ValidationResult
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