Merge branch 'feat/1.0.3/fixbug' into test

This commit is contained in:
aichy126 2023-01-09 15:45:50 +08:00
commit 81b0f9f6dd
1 changed files with 2 additions and 1 deletions

View File

@ -300,12 +300,13 @@ type AvatarInfo struct {
func (u *UpdateInfoRequest) Check() (errFields []*validator.FormErrorField, err error) {
if len(u.Username) > 0 {
errFields := make([]*validator.FormErrorField, 0)
re := regexp.MustCompile(`^[a-z0-9._-]{4,30}$`)
match := re.MatchString(u.Username)
if !match {
errField := &validator.FormErrorField{
ErrorField: "username",
ErrorMsg: err.Error(),
ErrorMsg: reason.UsernameInvalid,
}
errFields = append(errFields, errField)
return errFields, errors.BadRequest(reason.UsernameInvalid)