pub struct IssueBuilder<'a> { /* private fields */ }Expand description
Fluent builder for constructing a single ValidationIssue.
Obtained via VldError::issue(). Push it into a VldError with
.finish().
§Example
use vld::prelude::*;
let mut errors = VldError::new();
errors
.issue(IssueCode::Custom { code: "password_weak".into() })
.message("Password is too weak")
.path_field("password")
.received(&serde_json::json!("123"))
.finish();
assert_eq!(errors.issues.len(), 1);
assert_eq!(errors.issues[0].message, "Password is too weak");Implementations§
Source§impl<'a> IssueBuilder<'a>
impl<'a> IssueBuilder<'a>
Sourcepub fn message(self, msg: impl Into<String>) -> IssueBuilder<'a>
pub fn message(self, msg: impl Into<String>) -> IssueBuilder<'a>
Set the error message.
Sourcepub fn path_field(self, name: impl Into<String>) -> IssueBuilder<'a>
pub fn path_field(self, name: impl Into<String>) -> IssueBuilder<'a>
Add a field path segment.
Sourcepub fn path_index(self, idx: usize) -> IssueBuilder<'a>
pub fn path_index(self, idx: usize) -> IssueBuilder<'a>
Add an index path segment.
Sourcepub fn received(self, value: &Value) -> IssueBuilder<'a>
pub fn received(self, value: &Value) -> IssueBuilder<'a>
Attach the received value.
Auto Trait Implementations§
impl<'a> Freeze for IssueBuilder<'a>
impl<'a> RefUnwindSafe for IssueBuilder<'a>
impl<'a> Send for IssueBuilder<'a>
impl<'a> Sync for IssueBuilder<'a>
impl<'a> Unpin for IssueBuilder<'a>
impl<'a> UnsafeUnpin for IssueBuilder<'a>
impl<'a> !UnwindSafe for IssueBuilder<'a>
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
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> 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>
Converts
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>
Converts
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 more