Skip to main content

InputValidator

Trait InputValidator 

Source
pub trait InputValidator<T> {
    type Err;

    // Required method
    fn validate(&mut self, input: &T) -> Result<(), Self::Err>;
}
Expand description

Trait for input validators.

A generic implementation for Fn(&str) -> Result<(), E> is provided to facilitate development.

Required Associated Types§

Required Methods§

Source

fn validate(&mut self, input: &T) -> Result<(), Self::Err>

Invoked with the value to validate.

If this produces Ok(()) then the value is used and parsed, if an error is returned validation fails with that error.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<T, F, E> InputValidator<T> for F
where F: FnMut(&T) -> Result<(), E>,

Source§

type Err = E