Skip to content

Commit

Permalink
feat: change tag length limit
Browse files Browse the repository at this point in the history
  • Loading branch information
ppolariss committed Jul 11, 2024
1 parent 7f36602 commit a45c760
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion apis/hole/schemas.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (q *ListOldModel) SetDefaults() {
}

type TagCreateModelSlice struct {
Tags []tag.CreateModel `json:"tags" validate:"omitempty,min=1,max=10,dive"` // All users
Tags []tag.CreateModel `json:"tags" validate:"omitempty,min=1,max=20,dive"` // All users
}

func (tagCreateModelSlice TagCreateModelSlice) ToName() []string {
Expand Down
3 changes: 3 additions & 0 deletions apis/tag/apis.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ func CreateTag(c *fiber.Ctx) error {
return err
}
if !user.IsAdmin {
if len(tag.Name) > 15 {
return common.BadRequest("tag 名称长度不能超过 15 个字符")
}
if strings.HasPrefix(body.Name, "#") {
return common.BadRequest("只有管理员才能创建 # 开头的 tag")
}
Expand Down

0 comments on commit a45c760

Please sign in to comment.