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

package util
import (
"fmt"
)
func ValidateUsername(username string) error {
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
}
func ValidatePasswords(password, password2 string) error {
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
}