pub struct ValidationError {
pub path: String,
pub message: String,
}Expand description
A single validation finding. Carries the dotted path of the failing element and a human-readable message.
The path is built by this crate’s recursive validators using a
JSONPath-flavored syntax — # for the document root, . for
field descent, and […] for keyed map / array index segments
(e.g. #.paths[/pets].get.responses.default.content[application/json].schema).
It is not RFC 6901 JSON Pointer; there is no ~0 / ~1
escaping and / is a literal character that often appears inside
[…] segments. Downstream consumers should treat path as an
opaque human-readable locator, not a parser input for a JSON
Pointer library.
Constructed internally by the recursive validators; emitted to
callers as the elements of Error::errors after
Validate::validate returns.
The Display impl normally renders as "<path>: <message>".
As a defensive fallback, if message starts with . (rare —
the internal pusher splits leading-dot path extensions into
path at push time, so this only happens for directly-constructed
values that bypass the pusher), the rendering instead concatenates
the message directly onto the path with no separator, producing
"<path><message>" (e.g. path = "#.x", message = ".foo" →
"#.x.foo").
Fields§
§path: String§message: StringImplementations§
Source§impl ValidationError
impl ValidationError
Sourcepub fn contains(&self, needle: &str) -> bool
pub fn contains(&self, needle: &str) -> bool
Substring search across the rendered Display form, including
across the path/message boundary. Returns true if needle
appears anywhere in the rendered string.
The rendered form is normally "<path>: <message>", or
"<path><message>" if message starts with . (see the
type-level docs for that fallback).
This mirrors the old String::contains semantics used by
in-crate test patterns like
errors.iter().any(|e| e.contains("...")) against the
pre-refactor Vec<String> shape. It is not analogous to
Vec::contains, which is an exact element match — for exact
matching against the rendered string see ValidationErrorsExt::has_exact.