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§
Sourcefn 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 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.
Provided Methods§
Sourcefn default_message(&self) -> String
fn default_message(&self) -> String
Get the default error message for this rule.