pub struct ValidationError {
pub code: ValidationErrorCode,
pub field: String,
pub message: String,
pub expected: Option<String>,
pub actual: Option<Value>,
pub context: Option<Value>,
}Available on non-WebAssembly only.
Expand description
Structured validation error with elicitation support
Fields§
§code: ValidationErrorCodeThe error code
field: StringThe field that failed validation
message: StringHuman-readable error message
expected: Option<String>Expected format/value description
actual: Option<Value>The actual value that failed (for debugging)
context: Option<Value>Additional context for the error
Implementations§
Source§impl ValidationError
impl ValidationError
Sourcepub fn new(code: ValidationErrorCode, field: impl Into<String>) -> Self
pub fn new(code: ValidationErrorCode, field: impl Into<String>) -> Self
Create a new validation error
Sourcepub fn expected(self, expected: impl Into<String>) -> Self
pub fn expected(self, expected: impl Into<String>) -> Self
Set the expected value/format description
Trait Implementations§
Source§impl Clone for ValidationError
impl Clone for ValidationError
Source§fn clone(&self) -> ValidationError
fn clone(&self) -> ValidationError
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 moreAuto Trait Implementations§
impl Freeze for ValidationError
impl RefUnwindSafe for ValidationError
impl Send for ValidationError
impl Sync for ValidationError
impl Unpin for ValidationError
impl UnsafeUnpin for ValidationError
impl UnwindSafe for ValidationError
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