Skip to main content

Validator

Trait Validator 

Source
pub trait Validator:
    Send
    + Sync
    + 'static {
    // Required methods
    fn validate(&self, value: &str) -> Option<String>;
    fn name(&self) -> &'static str;
}
Expand description

A validation rule that can be applied to a string value.

Required Methods§

Source

fn validate(&self, value: &str) -> Option<String>

Returns None if valid, or an error message string if invalid.

Source

fn name(&self) -> &'static str

Human-readable name for this rule (used in error messages).

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§