Use better name error; Tweak name requirements
- "Invalid name" was replaced with a description of a valid name. Fixes #100 - Tweaked the valid name regex to require at least one number or letter.
This commit is contained in:
parent
78ecee1395
commit
a85c618e4a
@ -60,7 +60,7 @@ func (cr *ChatRoom) Join(conn *chatConnection, data common.JoinData) (*Client, e
|
||||
}
|
||||
|
||||
if !common.IsValidName(data.Name) {
|
||||
sendHiddenMessage(common.CdNotify, "Invalid name")
|
||||
sendHiddenMessage(common.CdNotify, common.InvalidNameError)
|
||||
return nil, UserFormatError{Name: data.Name}
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,9 @@ import (
|
||||
"regexp"
|
||||
)
|
||||
|
||||
var usernameRegex *regexp.Regexp = regexp.MustCompile(`^[0-9a-zA-Z_-]+$`)
|
||||
var usernameRegex *regexp.Regexp = regexp.MustCompile(`^[0-9a-zA-Z_-]*[a-zA-Z0-9]+[0-9a-zA-Z_-]*$`)
|
||||
|
||||
const InvalidNameError string = `Invalid name.<br />Name must be between 3 and 36 characters in length; contain only numbers, letters, underscores or dashes; and contain at least one number or letter.<br />Names cannot contain spaces.`
|
||||
|
||||
// IsValidName checks that name is within the correct ranges, follows the regex defined
|
||||
// and is not a valid color name
|
||||
|
Loading…
Reference in New Issue
Block a user