modo-rs 0.11.0

Rust web framework for small monolithic apps
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/// Trait for types that can sanitize their own fields.
///
/// Implement this on request/input structs to normalize data
/// (trim whitespace, lowercase emails, etc.) before validation.
///
/// The [`JsonRequest`](crate::extractor::JsonRequest),
/// [`FormRequest`](crate::extractor::FormRequest),
/// [`Query`](crate::extractor::Query), and
/// [`MultipartRequest`](crate::extractor::MultipartRequest) extractors call
/// [`Sanitize::sanitize`] automatically after deserialization, so every bound
/// on those extractors requires `T: Sanitize`.
pub trait Sanitize {
    /// Normalize the fields of `self` in place.
    ///
    /// Typical implementations call the helper functions from
    /// [`crate::sanitize`] on each `String` field.
    fn sanitize(&mut self);
}