pub struct ValidationErrorDetail {
pub loc: Vec<LocItem>,
pub msg: String,
pub error_type: String,
pub input: Option<String>,
pub expected: Option<String>,
pub ctx: Option<ValidationContext>,
}Expand description
A single validation error.
Fields§
§loc: Vec<LocItem>Location path (e.g., [“body”, “user”, “email”]).
msg: StringError message.
error_type: StringError type (e.g., “value_error”, “type_error”).
input: Option<String>The actual input value that caused the error.
expected: Option<String>Expected value or constraint (e.g., “integer”, “min: 1”, “email format”).
ctx: Option<ValidationContext>Context information (e.g., constraint values).
Implementations§
Source§impl ValidationErrorDetail
impl ValidationErrorDetail
Sourcepub fn new(
loc: Vec<LocItem>,
msg: impl Into<String>,
error_type: impl Into<String>,
) -> Self
pub fn new( loc: Vec<LocItem>, msg: impl Into<String>, error_type: impl Into<String>, ) -> Self
Create a new validation error.
Sourcepub fn input(self, input: impl Into<String>) -> Self
pub fn input(self, input: impl Into<String>) -> Self
Set the input value that caused the error.
Sourcepub fn expected(self, expected: impl Into<String>) -> Self
pub fn expected(self, expected: impl Into<String>) -> Self
Set the expected value or constraint.
Sourcepub fn ctx(self, ctx: ValidationContext) -> Self
pub fn ctx(self, ctx: ValidationContext) -> Self
Set the validation context.
Sourcepub fn format_loc(&self) -> String
pub fn format_loc(&self) -> String
Format the location path as a string.
Trait Implementations§
Source§impl Clone for ValidationErrorDetail
impl Clone for ValidationErrorDetail
Source§fn clone(&self) -> ValidationErrorDetail
fn clone(&self) -> ValidationErrorDetail
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 moreAuto Trait Implementations§
impl Freeze for ValidationErrorDetail
impl RefUnwindSafe for ValidationErrorDetail
impl Send for ValidationErrorDetail
impl Sync for ValidationErrorDetail
impl Unpin for ValidationErrorDetail
impl UnsafeUnpin for ValidationErrorDetail
impl UnwindSafe for ValidationErrorDetail
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