You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
565 B
Go
29 lines
565 B
Go
2 years ago
|
package util
|
||
2 years ago
|
|
||
2 years ago
|
import (
|
||
|
"fmt"
|
||
|
)
|
||
2 years ago
|
|
||
2 years ago
|
func ValidateUsername(username string) error {
|
||
2 years ago
|
if !IsWhitespaceFree(username) {
|
||
|
return fmt.Errorf(`username cannot contain spaces`)
|
||
|
}
|
||
|
if len(username) < 4 {
|
||
|
return fmt.Errorf(`username too short`)
|
||
|
}
|
||
|
if len(username) > 1000 {
|
||
|
return fmt.Errorf(`username too long`)
|
||
|
}
|
||
|
return nil
|
||
|
}
|
||
|
|
||
2 years ago
|
func ValidatePasswords(password, password2 string) error {
|
||
2 years ago
|
if password != password2 {
|
||
|
return fmt.Errorf(`the two password fields don't match`)
|
||
|
}
|
||
|
if len(password) == 0 {
|
||
|
return fmt.Errorf(`password cannot be empty`)
|
||
|
}
|
||
|
return nil
|
||
|
}
|