forked from didirus/AstralRinth
Fix version name can be empty string (#537)
This commit is contained in:
@@ -140,7 +140,10 @@ fn default_requested_status() -> ProjectStatus {
|
||||
|
||||
#[derive(Serialize, Deserialize, Validate, Clone)]
|
||||
struct ProjectCreateData {
|
||||
#[validate(length(min = 3, max = 64))]
|
||||
#[validate(
|
||||
length(min = 3, max = 64),
|
||||
custom(function = "crate::util::validate::validate_name")
|
||||
)]
|
||||
#[serde(alias = "mod_name")]
|
||||
/// The title or name of the project.
|
||||
pub title: String,
|
||||
|
||||
@@ -289,7 +289,10 @@ pub async fn dependency_list(
|
||||
/// A project returned from the API
|
||||
#[derive(Serialize, Deserialize, Validate)]
|
||||
pub struct EditProject {
|
||||
#[validate(length(min = 3, max = 64))]
|
||||
#[validate(
|
||||
length(min = 3, max = 64),
|
||||
custom(function = "crate::util::validate::validate_name")
|
||||
)]
|
||||
pub title: Option<String>,
|
||||
#[validate(length(min = 3, max = 256))]
|
||||
pub description: Option<String>,
|
||||
@@ -441,7 +444,7 @@ pub async fn project_edit(
|
||||
SET title = $1
|
||||
WHERE (id = $2)
|
||||
",
|
||||
title,
|
||||
title.trim(),
|
||||
id as database::models::ids::ProjectId,
|
||||
)
|
||||
.execute(&mut *transaction)
|
||||
|
||||
@@ -41,7 +41,10 @@ pub struct InitialVersionData {
|
||||
regex = "crate::util::validate::RE_URL_SAFE"
|
||||
)]
|
||||
pub version_number: String,
|
||||
#[validate(length(min = 1, max = 64))]
|
||||
#[validate(
|
||||
length(min = 1, max = 64),
|
||||
custom(function = "crate::util::validate::validate_name")
|
||||
)]
|
||||
#[serde(alias = "name")]
|
||||
pub version_title: String,
|
||||
#[validate(length(max = 65536))]
|
||||
|
||||
@@ -216,7 +216,10 @@ pub async fn version_get(
|
||||
|
||||
#[derive(Serialize, Deserialize, Validate)]
|
||||
pub struct EditVersion {
|
||||
#[validate(length(min = 1, max = 64))]
|
||||
#[validate(
|
||||
length(min = 1, max = 64),
|
||||
custom(function = "crate::util::validate::validate_name")
|
||||
)]
|
||||
pub name: Option<String>,
|
||||
#[validate(
|
||||
length(min = 1, max = 32),
|
||||
@@ -309,7 +312,7 @@ pub async fn version_edit(
|
||||
SET name = $1
|
||||
WHERE (id = $2)
|
||||
",
|
||||
name,
|
||||
name.trim(),
|
||||
id as database::models::ids::VersionId,
|
||||
)
|
||||
.execute(&mut *transaction)
|
||||
|
||||
Reference in New Issue
Block a user