pub struct Validate { /* private fields */ }Expand description
Multi-field procedural validation builder for transaction scripts.
Accumulates field errors in deterministic key order and returns
SlabError::ValidationErrors (HTTP 422) from Validate::finish.
Implementations§
Source§impl Validate
impl Validate
Sourcepub fn required(
&mut self,
field: impl Into<String>,
value: &str,
) -> &mut Validate
pub fn required( &mut self, field: impl Into<String>, value: &str, ) -> &mut Validate
Requires value to be non-empty after trimming whitespace.
Records "is required" under field when empty.
Sourcepub fn min_len(
&mut self,
field: impl Into<String>,
value: &str,
min: usize,
) -> &mut Validate
pub fn min_len( &mut self, field: impl Into<String>, value: &str, min: usize, ) -> &mut Validate
Requires the trimmed value to have at least min Unicode scalar characters.
Sourcepub fn max_len(
&mut self,
field: impl Into<String>,
value: &str,
max: usize,
) -> &mut Validate
pub fn max_len( &mut self, field: impl Into<String>, value: &str, max: usize, ) -> &mut Validate
Requires the trimmed value to have at most max Unicode scalar characters.
Sourcepub fn email(&mut self, field: impl Into<String>, value: &str) -> &mut Validate
pub fn email(&mut self, field: impl Into<String>, value: &str) -> &mut Validate
Requires the trimmed value to look like an email address.
Checks that the trimmed string is non-empty, contains no whitespace, and has a
non-empty local part before @ and a domain containing . after @.
Sourcepub fn url(&mut self, field: impl Into<String>, value: &str) -> &mut Validate
pub fn url(&mut self, field: impl Into<String>, value: &str) -> &mut Validate
Requires the trimmed value to start with http:// or https:// followed by a host.
Sourcepub fn one_of(
&mut self,
field: impl Into<String>,
value: &str,
allowed: &[&str],
) -> &mut Validate
pub fn one_of( &mut self, field: impl Into<String>, value: &str, allowed: &[&str], ) -> &mut Validate
Requires value to match one of the entries in allowed.
Sourcepub fn check(
&mut self,
field: impl Into<String>,
condition: bool,
message: impl Into<String>,
) -> &mut Validate
pub fn check( &mut self, field: impl Into<String>, condition: bool, message: impl Into<String>, ) -> &mut Validate
Records message under field when condition is false.
Sourcepub fn push(
&mut self,
field: impl Into<String>,
message: impl Into<String>,
) -> &mut Validate
pub fn push( &mut self, field: impl Into<String>, message: impl Into<String>, ) -> &mut Validate
Unconditionally appends message to the error list for field.
Trait Implementations§
Auto Trait Implementations§
impl Forget for Validate
impl Freeze for Validate
impl Move for Validate
impl RefUnwindSafe for Validate
impl Send for Validate
impl Sync for Validate
impl Unpin for Validate
impl UnsafeUnpin for Validatewhere
*const LeafNode<String, Vec<String>> is !null: UnsafeUnpin,
PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin,
PhantomData<Box<(String, Vec<String>)>>: UnsafeUnpin,
impl UnwindSafe for Validate
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<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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> ⓘ
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<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> ServiceExt for T
impl<T> ServiceExt for T
Source§fn compression(self) -> Compression<Self>where
Self: Sized,
fn compression(self) -> Compression<Self>where
Self: Sized,
Source§fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
Source§fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
Source§fn follow_redirects(self) -> FollowRedirect<Self>where
Self: Sized,
fn follow_redirects(self) -> FollowRedirect<Self>where
Self: Sized,
Source§fn override_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
fn override_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
Source§fn append_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
fn append_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
Source§fn insert_request_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
fn insert_request_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
Source§fn override_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
fn override_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
Source§fn append_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
fn append_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
Source§fn insert_response_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
fn insert_response_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
Source§fn set_request_id<M>(
self,
header_name: HeaderName,
make_request_id: M,
) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
fn set_request_id<M>(
self,
header_name: HeaderName,
make_request_id: M,
) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
Source§fn set_x_request_id<M>(self, make_request_id: M) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
fn set_x_request_id<M>(self, make_request_id: M) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
x-request-id as the header name. Read moreSource§fn propagate_request_id(
self,
header_name: HeaderName,
) -> PropagateRequestId<Self>where
Self: Sized,
fn propagate_request_id(
self,
header_name: HeaderName,
) -> PropagateRequestId<Self>where
Self: Sized,
Source§fn propagate_x_request_id(self) -> PropagateRequestId<Self>where
Self: Sized,
fn propagate_x_request_id(self) -> PropagateRequestId<Self>where
Self: Sized,
x-request-id as the header name. Read moreSource§fn request_body_limit(self, limit: usize) -> RequestBodyLimit<Self>where
Self: Sized,
fn request_body_limit(self, limit: usize) -> RequestBodyLimit<Self>where
Self: Sized,
413 Payload Too Large responses. Read more