preprocess_trim

Function preprocess_trim 

Source
pub fn preprocess_trim<'a, T>(value: T) -> Result<Cow<'a, str>, Error>
where T: Into<Cow<'a, str>>,
Expand description

Preprocesses the given string and removes all leading and trailing whitespaces. Returns a Cow<’a, str> to avoid unnecessary allocations.

§Example

use preprocess::prelude::*;

#[preprocess::sync]
#[derive(Debug, Deserialize, Serialize)]
pub struct LoginRequest {
    #[preprocess(trim)]
    pub email: String,
    #[preprocess(regex = "^(?=.*[A-Za-z])(?=.*\\d)[A-Za-z\\d]{8,}$")]
    pub password: String,
}