Skip to content

A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.

update username

aichy1267ed8a7d633c2
diff --git a/internal/schema/user_schema.go b/internal/schema/user_schema.go
index 0cdba3f1..d1712129 100644
--- a/internal/schema/user_schema.go
+++ b/internal/schema/user_schema.go
@@ -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)