pub struct ValidationError {
pub code: String,
pub message: String,
pub path: String,
pub severity: Severity,
pub location: JsonLocation,
}Expand description
A validation error with code, message, path, and location.
This struct implements std::error::Error for integration with
Rust’s standard error handling patterns.
Fields§
§code: StringThe error code.
message: StringThe error message.
path: StringThe JSON Pointer path to the error location.
severity: SeverityThe severity of the error.
location: JsonLocationThe source location in the JSON document.
Implementations§
Source§impl ValidationError
impl ValidationError
Sourcepub fn new(
code: impl Into<String>,
message: impl Into<String>,
path: impl Into<String>,
severity: Severity,
location: JsonLocation,
) -> Self
pub fn new( code: impl Into<String>, message: impl Into<String>, path: impl Into<String>, severity: Severity, location: JsonLocation, ) -> Self
Creates a new validation error.
Sourcepub fn schema_error(
code: SchemaErrorCode,
message: impl Into<String>,
path: impl Into<String>,
location: JsonLocation,
) -> Self
pub fn schema_error( code: SchemaErrorCode, message: impl Into<String>, path: impl Into<String>, location: JsonLocation, ) -> Self
Creates a new schema error.
Sourcepub fn schema_warning(
code: SchemaErrorCode,
message: impl Into<String>,
path: impl Into<String>,
location: JsonLocation,
) -> Self
pub fn schema_warning( code: SchemaErrorCode, message: impl Into<String>, path: impl Into<String>, location: JsonLocation, ) -> Self
Creates a new schema warning.
Sourcepub fn instance_error(
code: InstanceErrorCode,
message: impl Into<String>,
path: impl Into<String>,
location: JsonLocation,
) -> Self
pub fn instance_error( code: InstanceErrorCode, message: impl Into<String>, path: impl Into<String>, location: JsonLocation, ) -> Self
Creates a new instance error.
Sourcepub fn instance_warning(
code: InstanceErrorCode,
message: impl Into<String>,
path: impl Into<String>,
location: JsonLocation,
) -> Self
pub fn instance_warning( code: InstanceErrorCode, message: impl Into<String>, path: impl Into<String>, location: JsonLocation, ) -> Self
Creates a new instance warning.
Sourcepub fn is_warning(&self) -> bool
pub fn is_warning(&self) -> bool
Returns true if this is a warning (not an error).
Sourcepub fn location(&self) -> JsonLocation
pub fn location(&self) -> JsonLocation
Returns the source location.
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 · 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 ValidationError
impl Debug for ValidationError
Source§impl Display for ValidationError
impl Display for ValidationError
Source§impl Error for ValidationError
impl Error for ValidationError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
Source§impl PartialEq for ValidationError
impl PartialEq for ValidationError
impl Eq for ValidationError
impl StructuralPartialEq for ValidationError
Auto Trait Implementations§
impl Freeze for ValidationError
impl RefUnwindSafe for ValidationError
impl Send for ValidationError
impl Sync for ValidationError
impl Unpin 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