Struct promkit::validate::ValidatorManager
source · pub struct ValidatorManager<T: ?Sized> { /* private fields */ }Expand description
A generic structure for validating inputs of any type.
This structure allows for the definition of custom validation logic and error message generation for inputs of a specified type. It encapsulates a validator function and an error message generator function, both of which operate on references to the input.
Implementations§
source§impl<T: ?Sized> ValidatorManager<T>
impl<T: ?Sized> ValidatorManager<T>
sourcepub fn new(
validator: Validator<T>,
error_message_generator: ErrorMessageGenerator<T>
) -> Self
pub fn new( validator: Validator<T>, error_message_generator: ErrorMessageGenerator<T> ) -> Self
Constructs a new Validator instance
with the specified validator and error message generator functions.
§Arguments
validator- A function that takes a reference to an input of typeTand returns a boolean indicating whether the input passes the validation.error_message_generator- A function that takes a reference to an input of typeTand returns aStringthat describes the validation error.
§Returns
Returns a new instance of Validator<T>.
sourcepub fn generate_error_message(&self, input: &T) -> String
pub fn generate_error_message(&self, input: &T) -> String
Auto Trait Implementations§
impl<T> Freeze for ValidatorManager<T>where
T: ?Sized,
impl<T> RefUnwindSafe for ValidatorManager<T>where
T: ?Sized,
impl<T> Send for ValidatorManager<T>where
T: ?Sized,
impl<T> Sync for ValidatorManager<T>where
T: ?Sized,
impl<T> Unpin for ValidatorManager<T>where
T: ?Sized,
impl<T> UnwindSafe for ValidatorManager<T>where
T: ?Sized,
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