AsyncValidationRule

Trait AsyncValidationRule 

Source
pub trait AsyncValidationRule<T: ?Sized + Sync>:
    Debug
    + Send
    + Sync {
    // Required methods
    fn validate_async<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        value: &'life1 T,
        ctx: &'life2 ValidationContext,
    ) -> Pin<Box<dyn Future<Output = Result<(), RuleError>> + 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 default_message(&self) -> String { ... }
}
Expand description

Trait for async validation rules.

Use this for rules that require async operations like database or API checks.

Required Methods§

Source

fn validate_async<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, value: &'life1 T, ctx: &'life2 ValidationContext, ) -> Pin<Box<dyn Future<Output = Result<(), RuleError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Validate the value asynchronously.

Source

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

Get the rule name/code for error reporting.

Provided Methods§

Source

fn default_message(&self) -> String

Get the default error message for this rule.

Implementors§