pub struct VldError {
pub issues: Vec<ValidationIssue>,
}Expand description
Collection of validation errors.
Errors are accumulated (not short-circuited), so all issues are reported at once.
Fields§
§issues: Vec<ValidationIssue>Every issue found, in input order.
Implementations§
Source§impl VldError
impl VldError
Sourcepub fn issue(&mut self, code: IssueCode) -> IssueBuilder<'_>
pub fn issue(&mut self, code: IssueCode) -> IssueBuilder<'_>
Start building a new issue with the fluent API.
Call .message(...), .path_field(...), .received(...) etc., then
.finish() to push the issue.
§Example
use vld::prelude::*;
let mut errors = VldError::new();
errors
.issue(IssueCode::Custom { code: "my_check".into() })
.message("something went wrong")
.path_field("field_name")
.finish();Source§impl VldError
impl VldError
Sourcepub fn from_code(code: IssueCode) -> VldError
pub fn from_code(code: IssueCode) -> VldError
Error with a single issue and its default English message.
Sourcepub fn from_code_with_value(code: IssueCode, received: &Value) -> VldError
pub fn from_code_with_value(code: IssueCode, received: &Value) -> VldError
Error with a single issue, its default English message and the received value.
Sourcepub fn single(code: IssueCode, message: impl Into<String>) -> VldError
pub fn single(code: IssueCode, message: impl Into<String>) -> VldError
Create an error with a single issue (no received value).
Sourcepub fn single_with_value(
code: IssueCode,
message: impl Into<String>,
received: &Value,
) -> VldError
pub fn single_with_value( code: IssueCode, message: impl Into<String>, received: &Value, ) -> VldError
Create an error with a single issue and the received value.
Sourcepub fn with_prefix(self, segment: PathSegment) -> VldError
pub fn with_prefix(self, segment: PathSegment) -> VldError
Prepend a path segment to all issues (used for nested objects/arrays).
Sourcepub fn push(&mut self, code: IssueCode, message: impl Into<String>)
pub fn push(&mut self, code: IssueCode, message: impl Into<String>)
Push a single issue (no received value).
Sourcepub fn push_with_value(
&mut self,
code: IssueCode,
message: impl Into<String>,
received: &Value,
)
pub fn push_with_value( &mut self, code: IssueCode, message: impl Into<String>, received: &Value, )
Push a single issue with the received value.
Sourcepub fn push_code(&mut self, code: IssueCode)
pub fn push_code(&mut self, code: IssueCode)
Push a single issue with its default English message.
Sourcepub fn push_code_with_value(&mut self, code: IssueCode, received: &Value)
pub fn push_code_with_value(&mut self, code: IssueCode, received: &Value)
Push a single issue with its default English message and the received value.
Source§impl VldError
impl VldError
Sourcepub fn llm_feedback(&self) -> String
pub fn llm_feedback(&self) -> String
The issues as feedback for a model, one line per issue:
path: expected <rule>, got <value>, at most 10 lines then
“and N more”. See llm_feedback_with.
use vld::prelude::*;
let err = vld::object()
.field("name", vld::string().min(2))
.field("age", vld::number().int())
.parse(r#"{"name": "A", "age": "x"}"#)
.unwrap_err();
assert_eq!(
err.llm_feedback(),
"name: expected string length >= 2, got \"A\"\nage: expected number, got \"x\"",
);Sourcepub fn llm_feedback_with(&self, options: &LlmFeedbackOptions) -> String
pub fn llm_feedback_with(&self, options: &LlmFeedbackOptions) -> String
llm_feedback with options: issue limit,
a retry instruction, allowed-key hints from the schema.
Sourcepub fn llm_feedback_json(&self) -> Value
pub fn llm_feedback_json(&self) -> Value
The issues as JSON for a tool result:
[{"path", "expected", "received", "hint"}] (received / hint may
be null).
Sourcepub fn llm_feedback_json_with(&self, options: &LlmFeedbackOptions) -> Value
pub fn llm_feedback_json_with(&self, options: &LlmFeedbackOptions) -> Value
llm_feedback_json with options (issue
limit, allowed-key hints).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for VldError
impl<'de> Deserialize<'de> for VldError
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<VldError, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<VldError, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Error for VldError
impl Error for VldError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<ValidationIssue> for VldError
impl From<ValidationIssue> for VldError
Source§fn from(issue: ValidationIssue) -> VldError
fn from(issue: ValidationIssue) -> VldError
Source§impl From<VldError> for VldHttpError
impl From<VldError> for VldHttpError
Source§impl From<VldError> for VldActixError
impl From<VldError> for VldActixError
Source§impl From<VldError> for VldJsonRejection
impl From<VldError> for VldJsonRejection
Source§impl From<VldError> for VldNtexError
impl From<VldError> for VldNtexError
Source§impl From<VldError> for VldNtexError
impl From<VldError> for VldNtexError
Source§impl From<VldError> for VldPoemError
impl From<VldError> for VldPoemError
Source§impl From<VldError> for VldToolError
impl From<VldError> for VldToolError
Source§impl From<VldError> for VldSalvoError
impl From<VldError> for VldSalvoError
Source§impl Serialize for VldError
impl Serialize for VldError
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl Forget for VldError
impl Freeze for VldError
impl Move for VldError
impl RefUnwindSafe for VldError
impl Send for VldError
impl Sync for VldError
impl Unpin for VldError
impl UnsafeUnpin for VldError
impl UnwindSafe for VldError
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Error> ErrorExt for Error
impl<Error> ErrorExt for Error
Source§fn into_box_error(self) -> Box<dyn Error + Send + Sync>
fn into_box_error(self) -> Box<dyn Error + Send + Sync>
BoxError without additional context.Source§fn into_opaque_error(self) -> OpaqueError
fn into_opaque_error(self) -> OpaqueError
OpaqueError without additional context. Read moreSource§fn context_debug<M>(self, value: M) -> Box<dyn Error + Send + Sync>
fn context_debug<M>(self, value: M) -> Box<dyn Error + Send + Sync>
fmt::Debug as fmt::Display.Source§fn context_field<M>(
self,
key: &'static str,
value: M,
) -> Box<dyn Error + Send + Sync>
fn context_field<M>( self, key: &'static str, value: M, ) -> Box<dyn Error + Send + Sync>
Source§fn context_str_field<M>(
self,
key: &'static str,
value: M,
) -> Box<dyn Error + Send + Sync>
fn context_str_field<M>( self, key: &'static str, value: M, ) -> Box<dyn Error + Send + Sync>
Self::context_field but using a string-like value,
this is useful in case you need to pass a string slice which is borrowed
and thus cannot be passed as part of ’static error.Source§fn context_hex_field<M>(
self,
key: &'static str,
value: M,
) -> Box<dyn Error + Send + Sync>
fn context_hex_field<M>( self, key: &'static str, value: M, ) -> Box<dyn Error + Send + Sync>
Source§fn context_debug_field<M>(
self,
key: &'static str,
value: M,
) -> Box<dyn Error + Send + Sync>
fn context_debug_field<M>( self, key: &'static str, value: M, ) -> Box<dyn Error + Send + Sync>
fmt::Debug as fmt::Display.Source§fn with_context<C, F>(self, cb: F) -> Box<dyn Error + Send + Sync>
fn with_context<C, F>(self, cb: F) -> Box<dyn Error + Send + Sync>
Source§fn with_context_debug<C, F>(self, cb: F) -> Box<dyn Error + Send + Sync>
fn with_context_debug<C, F>(self, cb: F) -> Box<dyn Error + Send + Sync>
fmt::Debug as fmt::Display.Source§fn with_context_field<C, F>(
self,
key: &'static str,
cb: F,
) -> Box<dyn Error + Send + Sync>
fn with_context_field<C, F>( self, key: &'static str, cb: F, ) -> Box<dyn Error + Send + Sync>
Source§fn with_context_str_field<C, F>(
self,
key: &'static str,
cb: F,
) -> Box<dyn Error + Send + Sync>
fn with_context_str_field<C, F>( self, key: &'static str, cb: F, ) -> Box<dyn Error + Send + Sync>
Self::with_context_field but using a string-like value,
this is useful in case you need to pass a string slice which is borrowed
and thus cannot be passed as part of ’static error.Source§fn with_context_hex_field<C, F>(
self,
key: &'static str,
cb: F,
) -> Box<dyn Error + Send + Sync>
fn with_context_hex_field<C, F>( self, key: &'static str, cb: F, ) -> Box<dyn Error + Send + Sync>
Source§fn with_context_debug_field<C, F>(
self,
key: &'static str,
cb: F,
) -> Box<dyn Error + Send + Sync>
fn with_context_debug_field<C, F>( self, key: &'static str, cb: F, ) -> Box<dyn Error + Send + Sync>
fmt::Debug as fmt::Display.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoCollection<T> for T
impl<T> IntoCollection<T> for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<B> IntoFunctionResponse<B, Body> for Bwhere
B: Serialize,
impl<B> IntoFunctionResponse<B, Body> for Bwhere
B: Serialize,
Source§fn into_response(self) -> FunctionResponse<B, Body>
fn into_response(self) -> FunctionResponse<B, Body>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> IntoToolOutput for Twhere
T: Serialize + 'static,
impl<T> IntoToolOutput for Twhere
T: Serialize + 'static,
Source§fn into_tool_output(self) -> Result<ToolOutput, ToolExecutionError>
fn into_tool_output(self) -> Result<ToolOutput, ToolExecutionError>
Source§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T, U> RamaTryFrom<T> for Uwhere
U: TryFrom<T>,
impl<T, U> RamaTryFrom<T> for Uwhere
U: TryFrom<T>,
Source§impl<T, U, CrateMarker> RamaTryInto<U, CrateMarker> for Twhere
U: RamaTryFrom<T, CrateMarker>,
impl<T, U, CrateMarker> RamaTryInto<U, CrateMarker> for Twhere
U: RamaTryFrom<T, CrateMarker>,
type Error = <U as RamaTryFrom<T, CrateMarker>>::Error
fn rama_try_into(self) -> Result<U, <U as RamaTryFrom<T, CrateMarker>>::Error>
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.