MM-25544:Update error message for length violations (#14853)

* update error message for length violations

* fix unit test

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Scott Bishel
2020-06-23 10:47:48 -06:00
коммит произвёл GitHub
родитель 574b48835d
Коммит 53ef4d120b
3 изменённых файлов: 6 добавлений и 2 удалений

Просмотреть файл

@@ -5518,6 +5518,10 @@
"id": "model.group.name.invalid_chars.app_error", "id": "model.group.name.invalid_chars.app_error",
"translation": "invalid characters in the name property for group" "translation": "invalid characters in the name property for group"
}, },
{
"id": "model.group.name.invalid_length.app_error",
"translation": "Name must be 1 to 64 lowercase alphanumeric characters."
},
{ {
"id": "model.group.remote_id.app_error", "id": "model.group.remote_id.app_error",
"translation": "invalid remote id property for group." "translation": "invalid remote id property for group."

Просмотреть файл

@@ -186,7 +186,7 @@ func (group *Group) IsValidName() *AppError {
} }
} else { } else {
if l := len(*group.Name); l == 0 || l > GroupNameMaxLength { if l := len(*group.Name); l == 0 || l > GroupNameMaxLength {
return NewAppError("Group.IsValidName", "model.group.name.app_error", map[string]interface{}{"GroupNameMaxLength": GroupNameMaxLength}, "", http.StatusBadRequest) return NewAppError("Group.IsValidName", "model.group.name.invalid_length.app_error", map[string]interface{}{"GroupNameMaxLength": GroupNameMaxLength}, "", http.StatusBadRequest)
} }
if !validGroupnameChars.MatchString(*group.Name) { if !validGroupnameChars.MatchString(*group.Name) {

Просмотреть файл

@@ -148,7 +148,7 @@ func testGroupStoreCreate(t *testing.T, ss store.Store) {
require.Nil(t, g5.IsValidForCreate()) require.Nil(t, g5.IsValidForCreate())
g5.Name = model.NewString(*g5.Name + "x") g5.Name = model.NewString(*g5.Name + "x")
require.Equal(t, g5.IsValidForCreate().Id, "model.group.name.app_error") require.Equal(t, g5.IsValidForCreate().Id, "model.group.name.invalid_length.app_error")
g5.Name = model.NewString(model.NewId()) g5.Name = model.NewString(model.NewId())
require.Nil(t, g5.IsValidForCreate()) require.Nil(t, g5.IsValidForCreate())