Skip to content

Commit 10a184a

Browse files
committed
Cap category @ 30
1 parent a0f6626 commit 10a184a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

domain/category/endpoint.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"encoding/json"
1919
"io/ioutil"
2020
"net/http"
21+
"strings"
2122

2223
"github.com/documize/community/core/env"
2324
"github.com/documize/community/core/request"
@@ -72,6 +73,12 @@ func (h *Handler) Add(w http.ResponseWriter, r *http.Request) {
7273
return
7374
}
7475

76+
// Category max length 30.
77+
cat.Category = strings.TrimSpace(cat.Category)
78+
if len(cat.Category) > 30 {
79+
cat.Category = cat.Category[:30]
80+
}
81+
7582
err = h.Store.Category.Add(ctx, cat)
7683
if err != nil {
7784
ctx.Transaction.Rollback()

0 commit comments

Comments
 (0)