Skip to main content

ValidationError

Enum ValidationError 

Source
pub enum ValidationError {
Show 22 variants InvalidRef { instance_path: JsonPointer, ref_str: String, reason: String, }, ExpectedObject { instance_path: JsonPointer, got: String, }, ExpectedString { instance_path: JsonPointer, got: String, }, ExpectedInteger { instance_path: JsonPointer, got: String, }, ExpectedNumber { instance_path: JsonPointer, got: String, }, ExpectedArray { instance_path: JsonPointer, got: String, }, ExpectedBoolean { instance_path: JsonPointer, got: String, }, DuplicateArrayItems { instance_path: JsonPointer, duplicate_value: String, }, TooFewItems { instance_path: JsonPointer, min_items: u64, actual_count: u64, }, TooManyItems { instance_path: JsonPointer, max_items: u64, actual_count: u64, }, MissingRequired { instance_path: JsonPointer, property: String, }, DisallowedAdditionalProperty { instance_path: JsonPointer, property: String, }, NotInEnum { instance_path: JsonPointer, invalid_value: String, allowed: Vec<String>, }, NotConst { instance_path: JsonPointer, expected: String, actual: String, }, BelowMinimum { instance_path: JsonPointer, minimum: OrderedF64, actual: OrderedF64, }, AboveMaximum { instance_path: JsonPointer, maximum: OrderedF64, actual: OrderedF64, }, TooShort { instance_path: JsonPointer, min_length: u64, actual_length: u64, }, TooLong { instance_path: JsonPointer, max_length: u64, actual_length: u64, }, PatternMismatch { instance_path: JsonPointer, pattern: String, value: String, }, InvalidPatternInSchema { instance_path: JsonPointer, pattern: String, }, NoSubschemaMatched { instance_path: JsonPointer, subschema_count: usize, }, MultipleSubschemasMatched { instance_path: JsonPointer, subschema_count: usize, match_count: usize, },
}
Expand description

A single validation failure: kind and instance location.

Variants§

§

InvalidRef

Schema had an invalid or unsupported $ref, or the reference could not be resolved.

Fields

§instance_path: JsonPointer

JSON Pointer to the instance location where the referenced schema was applied.

§ref_str: String

The $ref string from the schema.

§reason: String

Human-readable reason (for user-facing context).

§

ExpectedObject

Schema had type: "object" but the instance was not an object.

Fields

§instance_path: JsonPointer

JSON Pointer to the instance that failed.

§got: String

JSON type of the instance (for user-facing context).

§

ExpectedString

Schema had type: "string" but the instance was not a string.

Fields

§instance_path: JsonPointer

JSON Pointer to the instance that failed.

§got: String

JSON type of the instance (for user-facing context).

§

ExpectedInteger

Schema had type: "integer" but the instance was not an integer (e.g. float, string, or non-number).

Fields

§instance_path: JsonPointer

JSON Pointer to the instance that failed.

§got: String

JSON type of the instance (for user-facing context).

§

ExpectedNumber

Schema had type: "number" but the instance was not a number (e.g. string, null, or non-number).

Fields

§instance_path: JsonPointer

JSON Pointer to the instance that failed.

§got: String

JSON type of the instance (for user-facing context).

§

ExpectedArray

Schema had type: "array" but the instance was not an array.

Fields

§instance_path: JsonPointer

JSON Pointer to the instance that failed.

§got: String

JSON type of the instance (for user-facing context).

§

ExpectedBoolean

Schema had type: "boolean" but the instance was not a boolean.

Fields

§instance_path: JsonPointer

JSON Pointer to the instance that failed.

§got: String

JSON type of the instance (for user-facing context).

§

DuplicateArrayItems

Schema had uniqueItems: true but the array contained duplicate elements.

Fields

§instance_path: JsonPointer

JSON Pointer to the array instance that failed.

§duplicate_value: String

Serialized duplicate value (for user-facing context).

§

TooFewItems

Schema had minItems but the array had fewer elements.

Fields

§instance_path: JsonPointer

JSON Pointer to the array instance that failed.

§min_items: u64

The schema’s minItems value.

§actual_count: u64

Actual number of items in the array (for user-facing context).

§

TooManyItems

Schema had maxItems but the array had more elements.

Fields

§instance_path: JsonPointer

JSON Pointer to the array instance that failed.

§max_items: u64

The schema’s maxItems value.

§actual_count: u64

Actual number of items in the array (for user-facing context).

§

MissingRequired

A property listed in required was absent.

Fields

§instance_path: JsonPointer

JSON Pointer to the object (parent of the missing property).

§property: String

The required property name that was missing.

§

DisallowedAdditionalProperty

Schema had additionalProperties: false but the instance contained a property not in properties.

Fields

§instance_path: JsonPointer

JSON Pointer to the instance (the additional property).

§property: String

The property name that is not allowed.

§

NotInEnum

Schema had enum but the instance value was not one of the allowed values.

Fields

§instance_path: JsonPointer

JSON Pointer to the instance that failed.

§invalid_value: String

Serialized invalid value (for user-facing context).

§allowed: Vec<String>

Serialized allowed enum values (for user-facing context).

§

NotConst

Schema had const but the instance value was not equal to the const value.

Fields

§instance_path: JsonPointer

JSON Pointer to the instance that failed.

§expected: String

Serialized expected (const) value (for user-facing context).

§actual: String

Serialized actual instance value (for user-facing context).

§

BelowMinimum

Instance was below the schema’s minimum (inclusive lower bound).

Fields

§instance_path: JsonPointer

JSON Pointer to the instance that failed.

§minimum: OrderedF64

The schema’s minimum value.

§actual: OrderedF64

Actual instance value (for user-facing context).

§

AboveMaximum

Instance was above the schema’s maximum (inclusive upper bound).

Fields

§instance_path: JsonPointer

JSON Pointer to the instance that failed.

§maximum: OrderedF64

The schema’s maximum value.

§actual: OrderedF64

Actual instance value (for user-facing context).

§

TooShort

Schema had minLength but the string had fewer Unicode code points.

Fields

§instance_path: JsonPointer

JSON Pointer to the instance that failed.

§min_length: u64

The schema’s minLength value.

§actual_length: u64

Actual Unicode code point count (for user-facing context).

§

TooLong

Schema had maxLength but the string had more Unicode code points.

Fields

§instance_path: JsonPointer

JSON Pointer to the instance that failed.

§max_length: u64

The schema’s maxLength value.

§actual_length: u64

Actual Unicode code point count (for user-facing context).

§

PatternMismatch

Schema had pattern but the string did not match the ECMA 262 regex.

Fields

§instance_path: JsonPointer

JSON Pointer to the instance that failed.

§pattern: String

The schema’s pattern value (ECMA 262 regex string).

§value: String

The instance string value (for user-facing context).

§

InvalidPatternInSchema

Schema had an invalid pattern (not a valid ECMA 262 regex); compilation failed.

Fields

§instance_path: JsonPointer

JSON Pointer to the instance (schema location where pattern was applied).

§pattern: String

The invalid pattern string from the schema.

§

NoSubschemaMatched

Schema had anyOf but the instance did not validate against any of the subschemas.

Fields

§instance_path: JsonPointer

JSON Pointer to the instance that failed.

§subschema_count: usize

Number of subschemas in the anyOf (for user-facing context).

§

MultipleSubschemasMatched

Schema had oneOf but the instance validated against more than one subschema.

Fields

§instance_path: JsonPointer

JSON Pointer to the instance that failed.

§subschema_count: usize

Number of subschemas in the oneOf (for user-facing context).

§match_count: usize

Number of subschemas that passed validation (must be >= 2 for this error).

Implementations§

Trait Implementations§

Source§

impl Clone for ValidationError

Source§

fn clone(&self) -> ValidationError

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ValidationError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for ValidationError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for ValidationError

1.30.0 · Source§

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

👎Deprecated since 1.42.0: use the Display impl or to_string()
1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl PartialEq for ValidationError

Source§

fn eq(&self, other: &ValidationError) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for ValidationError

Source§

impl StructuralPartialEq for ValidationError

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.