dot is valid for username (#2958)
* dot is valid for username in gitlab * add test case for user
This commit is contained in:
parent
d881724695
commit
6b27829426
2 changed files with 5 additions and 1 deletions
|
@ -94,7 +94,7 @@ func (u *User) Validate() error {
|
|||
switch {
|
||||
case !govalidator.IsByteLength(u.Login, 1, 50):
|
||||
return errUsernameLen
|
||||
case !govalidator.Matches(u.Login, "^[a-zA-Z0-9_-]+$"):
|
||||
case !govalidator.Matches(u.Login, "^[.a-zA-Z0-9_-]+$"):
|
||||
return errUsernameChar
|
||||
default:
|
||||
return nil
|
||||
|
|
|
@ -39,6 +39,10 @@ func TestValidateUser(t *testing.T) {
|
|||
user: &User{Login: "octocat"},
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
user: &User{Login: "octocat.with.dot"},
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
user: &User{Login: "OctO-Cat_01"},
|
||||
err: nil,
|
||||
|
|
Loading…
Reference in a new issue