Skip to content

Commit

Permalink
More reasonable length restrictions (#458)
Browse files Browse the repository at this point in the history
  • Loading branch information
Geometrically committed Sep 27, 2022
1 parent 75b7583 commit 3e52f80
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/routes/project_creation.rs
Expand Up @@ -130,7 +130,7 @@ fn default_project_type() -> String {

#[derive(Serialize, Deserialize, Validate, Clone)]
struct ProjectCreateData {
#[validate(length(min = 3, max = 256))]
#[validate(length(min = 3, max = 64))]
#[serde(alias = "mod_name")]
/// The title or name of the project.
pub title: String,
Expand All @@ -145,7 +145,7 @@ struct ProjectCreateData {
#[serde(alias = "mod_slug")]
/// The slug of a project, used for vanity URLs
pub slug: String,
#[validate(length(min = 3, max = 2048))]
#[validate(length(min = 3, max = 255))]
#[serde(alias = "mod_description")]
/// A short description of the project.
pub description: String,
Expand Down
4 changes: 2 additions & 2 deletions src/routes/projects.rs
Expand Up @@ -251,9 +251,9 @@ pub async fn dependency_list(
/// A project returned from the API
#[derive(Serialize, Deserialize, Validate)]
pub struct EditProject {
#[validate(length(min = 3, max = 256))]
#[validate(length(min = 3, max = 64))]
pub title: Option<String>,
#[validate(length(min = 3, max = 2048))]
#[validate(length(min = 3, max = 256))]
pub description: Option<String>,
#[validate(length(max = 65536))]
pub body: Option<String>,
Expand Down
6 changes: 3 additions & 3 deletions src/routes/users.rs
Expand Up @@ -130,21 +130,21 @@ lazy_static! {

#[derive(Serialize, Deserialize, Validate)]
pub struct EditUser {
#[validate(length(min = 1, max = 255), regex = "RE_URL_SAFE")]
#[validate(length(min = 1, max = 39), regex = "RE_URL_SAFE")]
pub username: Option<String>,
#[serde(
default,
skip_serializing_if = "Option::is_none",
with = "::serde_with::rust::double_option"
)]
#[validate(length(min = 1, max = 255), regex = "RE_URL_SAFE")]
#[validate(length(min = 1, max = 64), regex = "RE_URL_SAFE")]
pub name: Option<Option<String>>,
#[serde(
default,
skip_serializing_if = "Option::is_none",
with = "::serde_with::rust::double_option"
)]
#[validate(email)]
#[validate(email, length(max = 2048))]
pub email: Option<Option<String>>,
#[serde(
default,
Expand Down
4 changes: 2 additions & 2 deletions src/routes/version_creation.rs
Expand Up @@ -32,11 +32,11 @@ pub struct InitialVersionData {
#[validate(length(min = 1, max = 256))]
pub file_parts: Vec<String>,
#[validate(
length(min = 1, max = 64),
length(min = 1, max = 32),
regex = "crate::util::validate::RE_URL_SAFE"
)]
pub version_number: String,
#[validate(length(min = 1, max = 256))]
#[validate(length(min = 1, max = 64))]
#[serde(alias = "name")]
pub version_title: String,
#[validate(length(max = 65536))]
Expand Down
4 changes: 2 additions & 2 deletions src/routes/versions.rs
Expand Up @@ -167,10 +167,10 @@ pub async fn version_get(

#[derive(Serialize, Deserialize, Validate)]
pub struct EditVersion {
#[validate(length(min = 1, max = 256))]
#[validate(length(min = 1, max = 64))]
pub name: Option<String>,
#[validate(
length(min = 1, max = 64),
length(min = 1, max = 32),
regex = "crate::util::validate::RE_URL_SAFE"
)]
pub version_number: Option<String>,
Expand Down

0 comments on commit 3e52f80

Please sign in to comment.