Trait FormRequest

Source
pub trait FormRequest: Send + Sync {
    type Data: for<'de> Deserialize<'de>;

    // Required methods
    fn rules(&self) -> HashMap<String, Vec<Box<dyn ValidationRule>>>;
    fn validate<'life0, 'life1, 'async_trait>(
        &'life0 self,
        data: &'life1 Self::Data,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided methods
    fn authorize<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn messages(&self) -> HashMap<String, String> { ... }
}
Expand description

Trait for form requests (validation and authorization)

Required Associated Types§

Source

type Data: for<'de> Deserialize<'de>

Request data type

Required Methods§

Source

fn rules(&self) -> HashMap<String, Vec<Box<dyn ValidationRule>>>

Validation rules

Source

fn validate<'life0, 'life1, 'async_trait>( &'life0 self, data: &'life1 Self::Data, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Validates the request data

Provided Methods§

Source

fn authorize<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Authorizes the request

Source

fn messages(&self) -> HashMap<String, String>

Custom error messages

Implementors§