There is too many usages of the #[serde(rename = "newName")], all of this can be replaced to a singles #[serde(rename_all = "camelCase")] before the struct definition.
For example, the RegisterCountryDTO:
#[derive(Validate, Debug, Default, Clone, Serialize, Deserialize)]
pub struct RegisterCountryDTO {
#[validate(length(
min = 1,
max = 100,
message = "Country name must have a maximum of 100 characters"
))]
pub name: String,
#[validate(length(min = 2, max = 2, message = "Alpha 2 code must be 2 characters long"))]
#[serde(rename = "alpha2")]
pub alpha_2: String,
#[validate(length(min = 3, max = 3, message = "Alpha 3 code must be 3 characters long"))]
#[serde(rename = "alpha3")]
pub alpha_3: String,
#[validate(length(min = 3, max = 3, message = "Numeric 3 code must be 3 characters long"))]
#[serde(rename = "numeric3")]
pub numeric_3: String,
}
Uses the #[serde(rename = "")] in three places, and can be replaced by:
#[derive(Validate, Debug, Default, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct RegisterCountryDTO {
#[validate(length(
min = 1,
max = 100,
message = "Country name must have a maximum of 100 characters"
))]
pub name: String,
#[validate(length(min = 2, max = 2, message = "Alpha 2 code must be 2 characters long"))]
pub alpha_2: String,
#[validate(length(min = 3, max = 3, message = "Alpha 3 code must be 3 characters long"))]
pub alpha_3: String,
#[validate(length(min = 3, max = 3, message = "Numeric 3 code must be 3 characters long"))]
pub numeric_3: String,
}
There is too many usages of the
#[serde(rename = "newName")]
, all of this can be replaced to a singles#[serde(rename_all = "camelCase")]
before thestruct
definition.For example, the
RegisterCountryDTO
:Uses the
#[serde(rename = "")]
in three places, and can be replaced by: