Skip to content

Commit

Permalink
Make display name minimum 1 character
Browse files Browse the repository at this point in the history
  • Loading branch information
Fleeym committed Jun 7, 2024
1 parent b286827 commit 94cebe2
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/types/models/developer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,12 +357,17 @@ impl Developer {
display_name: &str,
pool: &mut PgConnection,
) -> Result<(), ApiError> {
let str = String::from(display_name);
let str = String::from(display_name.trim());
if !str.chars().all(char::is_alphanumeric) {
return Err(ApiError::BadRequest(
"Display name must contain only alphanumeric characters".to_string(),
));
}
if str.len() < 2 {
return Err(ApiError::BadRequest(
"Display name must have > 1 character".to_string(),
));
}

let result = match sqlx::query!(
"UPDATE developers SET display_name = $1 WHERE id = $2",
Expand Down

0 comments on commit 94cebe2

Please sign in to comment.