Skip to main content

ValidationError

Enum ValidationError 

Source
#[non_exhaustive]
pub enum ValidationError { TypeMismatch { path: String, expected: String, actual: String, source_token: String, default: Option<String>, }, EnumViolation { path: String, value: String, allowed: Vec<String>, }, FormatViolation { path: String, format: String, }, UnknownCard { path: String, card: String, }, BodyDisabled { path: String, card: String, }, NotInline { path: String, }, NotPlain { path: String, }, }
Expand description

Validation error with a structured field path.

Field-level type and presence errors carry the field path, the schema-declared type, and any verbatim YAML source token / default: enough for the Display impl to render the uniform diagnostic message described in ERROR.md (“Validation message contract”).

Two concerns are deliberately not well-formedness errors and so have no variant here: the !must_fill marker (surfaced as a non-fatal warning by Quill::validate) and field absence (an absent or present-null field zero-fills at render). Both are handled outside the value-layer checks below.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

TypeMismatch

Fields

§path: String
§expected: String

Schema-declared type (string, integer, …).

§actual: String

YAML-parsed type of the source token (integer, number, boolean, null, string, array, object).

§source_token: String

Verbatim YAML scalar that triggered the error, rendered in its canonical YAML form (42, null, "hello", "").

§default: Option<String>

Pre-rendered default token from the schema, when present. Same canonical YAML form as source_token.

§

EnumViolation

Fields

§path: String
§value: String
§allowed: Vec<String>
§

FormatViolation

Fields

§path: String
§format: String
§

UnknownCard

Fields

§path: String
§card: String
§

BodyDisabled

Fields

§path: String
§card: String
§

NotInline

An inline: true field whose content is not a single line (a block, a list/quote container, or an island). Same fatality class as TypeMismatch: the value is well-typed content but the wrong shape for an inline field. Both prose codecs declare inline, so this is one condition under one code, the validation twin of EditError::FieldNotInline.

Fields

§path: String
§

NotPlain

A plaintext field whose content carries marks, islands, or block formatting. Same fatality class as TypeMismatch: the value is a well-formed content but the wrong shape for a plaintext field, which takes prose the author navigates but no formatting.

Fields

§path: String

Implementations§

Source§

impl ValidationError

Source

pub fn path(&self) -> &str

Document-model path anchor for this error.

See crate::error module docs for the path grammar and conventions.

Source

pub fn code(&self) -> &'static str

Stable diagnostic code for this error variant. Pattern-match on this instead of the message text.

Source

pub fn args(&self) -> BTreeMap<String, Value>

The facts this error’s message interpolates. See Diagnostic::args.

path stays out: it is the diagnostic’s anchor, and an anchor reachable by two routes acquires two spellings. NotInline and NotPlain carry nothing else, so their sentence follows from the code and the anchor alone.

default is present only when the schema declares one, the same condition type_mismatch_hint branches on, so a consumer picks its own exit clause from the key’s presence instead of re-deriving the branch. Emitting null instead would read as a default spelled null.

Source

pub fn hint(&self) -> Option<String>

Actionable hint for this error, when defined for the variant: the same string the Display impl bakes in, exposed so consumers can surface it without re-parsing prose.

Source

pub fn to_diagnostic(&self) -> Diagnostic

Convert this error into a structured Diagnostic carrying the stable code, the document-model path, the canonical message, and the actionable hint (when the variant defines one).

Trait Implementations§

Source§

impl Clone for ValidationError

Source§

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)

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 Eq for ValidationError

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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.