pub struct ValidationBuilder<FD: FormToolData, T: ?Sized + 'static> { /* private fields */ }Expand description
A helper builder that allows you to specify a validation function declaritivly
Using this builder is not required as validation functions can just be closures, but for simple validation function this builder can be helpful
Validations are run in the order that they are called in the builder.
Implementations§
Source§impl<FD: FormToolData, T: ?Sized + 'static> ValidationBuilder<FD, T>
impl<FD: FormToolData, T: ?Sized + 'static> ValidationBuilder<FD, T>
Sourcepub fn for_field(field_fn: impl Fn(&FD) -> &T + Send + Sync + 'static) -> Self
pub fn for_field(field_fn: impl Fn(&FD) -> &T + Send + Sync + 'static) -> Self
Creates a new empty ValidationBuilder on the given field.
Sourcepub fn named(self, name: impl ToString) -> Self
pub fn named(self, name: impl ToString) -> Self
The name of the field that is being validated.
This is the name that will be used for error messages.
Sourcepub fn custom(self, f: impl ValidationFn<T>) -> Self
pub fn custom(self, f: impl ValidationFn<T>) -> Self
Adds a custom validation function.
The function should take the value as an argument and return
a Result<(), String>, just like any other validation function.
Sourcepub fn build(self) -> impl ValidationFn<FD>
pub fn build(self) -> impl ValidationFn<FD>
Builds the action validation function.
Source§impl<FD: FormToolData, T> ValidationBuilder<FD, Option<T>>
impl<FD: FormToolData, T> ValidationBuilder<FD, Option<T>>
Source§impl<FD: FormToolData> ValidationBuilder<FD, str>
impl<FD: FormToolData> ValidationBuilder<FD, str>
Source§impl<FD: FormToolData, T: PartialOrd<T> + Display + Send + Sync + 'static> ValidationBuilder<FD, T>
impl<FD: FormToolData, T: PartialOrd<T> + Display + Send + Sync + 'static> ValidationBuilder<FD, T>
Source§impl<FD: FormToolData, T: PartialEq<T> + Display + Send + Sync + 'static> ValidationBuilder<FD, T>
impl<FD: FormToolData, T: PartialEq<T> + Display + Send + Sync + 'static> ValidationBuilder<FD, T>
Auto Trait Implementations§
impl<FD, T> Freeze for ValidationBuilder<FD, T>where
T: ?Sized,
impl<FD, T> !RefUnwindSafe for ValidationBuilder<FD, T>
impl<FD, T> Send for ValidationBuilder<FD, T>where
T: ?Sized,
impl<FD, T> Sync for ValidationBuilder<FD, T>where
T: ?Sized,
impl<FD, T> Unpin for ValidationBuilder<FD, T>where
T: ?Sized,
impl<FD, T> !UnwindSafe for ValidationBuilder<FD, T>
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> 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 moreSource§impl<T> SerializableKey for T
impl<T> SerializableKey for T
Source§impl<T> StorageAccess<T> for T
impl<T> StorageAccess<T> for T
Source§fn as_borrowed(&self) -> &T
fn as_borrowed(&self) -> &T
Borrows the value.
Source§fn into_taken(self) -> T
fn into_taken(self) -> T
Takes the value.