Skip to main content

AsyncValidator

Trait AsyncValidator 

Source
pub trait AsyncValidator: Send + Sync {
    // Required methods
    fn validate_async<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        value: &'life1 str,
        field: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = AsyncValidatorResult> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn provider(&self) -> AsyncValidatorProvider;
    fn timeout(&self) -> Duration;
}
Expand description

Trait for async validators.

Implementers should handle timeout and error cases gracefully.

Required Methods§

Source

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

Validate a value asynchronously.

§Arguments
  • value - The value to validate
  • field - The field name (for error reporting)
§Returns

Ok(()) if valid, Err(FraiseQLError) if invalid

Source

fn provider(&self) -> AsyncValidatorProvider

Get the provider this validator uses

Source

fn timeout(&self) -> Duration

Get the timeout for this validator

Implementors§