#[derive(JsonBody)]Expand description
§Validated Json Input
Structs that derive JsonBody can be used as Endpoint Input.
The data is read from the body as Json and validated via Validator.
If arguments are passed to cusom Validators
#[validate(custom(function="validate_password", arg="&'v_a Config"))]
they are read from state
§Requirements
The struct has to implement serde::Deserialize and validator::Validate
§Example
#[derive(serde::Deserialize, validator::Validate, rocketjson::JsonBody)]
pub struct TestRequest {
#[validate(length(min = 1))]
username: String
}
#[post("/register", data="<data>")]
pub fn register(data: RegisterRequest) {
//data is validated from json body
}