Use character count instead of bytes in validate_display_name()
This commit is contained in:
parent
5d3e5dc693
commit
a06f1b4aba
1 changed files with 3 additions and 1 deletions
|
@ -19,10 +19,12 @@ pub fn validate_username(username: &str) -> Result<(), ValidationError> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
const DISPLAY_NAME_MAX_LENGTH: usize = 200;
|
||||
|
||||
pub fn validate_display_name(display_name: &str)
|
||||
-> Result<(), ValidationError>
|
||||
{
|
||||
if display_name.len() > 200 {
|
||||
if display_name.chars().count() > DISPLAY_NAME_MAX_LENGTH {
|
||||
return Err(ValidationError("display name is too long"));
|
||||
};
|
||||
Ok(())
|
||||
|
|
Loading…
Reference in a new issue