Skip to main content

Validate

Trait Validate 

Source
pub trait Validate:
    Send
    + Sync
    + 'static {
    // Required method
    fn check(&self, value: &str) -> Result<(), String>;
}
Expand description

Anything that can decide whether an input string is acceptable.

Implement this for any external validation library to bridge it into the prompt’s .rule(...) chain.

Required Methods§

Source

fn check(&self, value: &str) -> Result<(), String>

Return Ok(()) to accept the value, Err(msg) to reject and show msg as the user-facing error.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl Validate for Validator

Source§

impl<F> Validate for F
where F: Fn(&str) -> Result<(), String> + Send + Sync + 'static,