func validatePassword(password string) error { if len(password) < 6 { return datalayer.NewValidationError("Password too short") } if len(password) > 120 { return datalayer.NewValidationError("Password too long") } return nil }
func validateUsername(username string) error { if username == "leela" { return datalayer.NewValidationError("Username reserved") } if len(username) < 5 { return datalayer.NewValidationError("Username too short") } if len(username) > 24 { return datalayer.NewValidationError("Username too long") } matched, err := regexp.MatchString("^[a-zA-Z][a-zA-Z0-9_]+$", username) if !matched || err != nil { return datalayer.NewValidationError("Invalid username") } return nil }
func validateEmail(email string) error { if !emailPattern.MatchString(email) { return datalayer.NewValidationError("Invalid email address") } return nil }