Trait ValidationRule

Source
pub trait ValidationRule: Send + Sync {
    // Required methods
    fn validate<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        value: &'life1 Value,
        field: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = ValidationResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn rule_name(&self) -> &'static str;

    // Provided method
    fn parameters(&self) -> Option<Value> { ... }
}
Expand description

Core validation trait that all validators must implement

Required Methods§

Source

fn validate<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, value: &'life1 Value, field: &'life2 str, ) -> Pin<Box<dyn Future<Output = ValidationResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Validate a single value

Source

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

Get the validation rule name/type

Provided Methods§

Source

fn parameters(&self) -> Option<Value>

Get validation rule parameters/configuration as JSON

Implementors§