Skip to main content

FormPartial

Trait FormPartial 

Source
pub trait FormPartial {
    type Form: Form<Partial = Self>;
    type Validation: FormValidation<Partial = Self>;
    type Error: Send + 'static;

    const INFO: &'static FormPartialInfo;

    // Required methods
    fn form(&self) -> Result<Self::Form, &'static str>
       where Self: Sized;
    fn validate<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Self::Validation, Self::Error>> + Send + 'async_trait>>
       where Self: Sized + 'async_trait,
             'life0: 'async_trait;

    // Provided method
    fn validator_info(&self) -> &'static FormPartialInfo { ... }
}
Expand description

The type of a partially populated and as-yet-unvalidated form. Structs for and implementations of this trait can be generated via derive macro.

Required Associated Constants§

Source

const INFO: &'static FormPartialInfo

Required Associated Types§

Source

type Form: Form<Partial = Self>

Source

type Validation: FormValidation<Partial = Self>

Source

type Error: Send + 'static

Required Methods§

Source

fn form(&self) -> Result<Self::Form, &'static str>
where Self: Sized,

Converts the partial into a form.

§Preconditions
  • The form should already have been validated.
§Errors

Only structural/type errors will be returned here, with only the name of the field to be returned.

No other validation is performed here.

Source

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

Runs all the validators on the form and calculates errors.

Should only be called once.

§Errors

Returns direct errors from validators if one was thrown.

Provided Methods§

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§