1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-08-04 04:55:23 +02:00

Cap category @ 30

This commit is contained in:
sauls8t 2018-06-29 15:53:57 +01:00
parent a0f6626367
commit 10a184ad10

View file

@ -18,6 +18,7 @@ import (
"encoding/json"
"io/ioutil"
"net/http"
"strings"
"github.com/documize/community/core/env"
"github.com/documize/community/core/request"
@ -72,6 +73,12 @@ func (h *Handler) Add(w http.ResponseWriter, r *http.Request) {
return
}
// Category max length 30.
cat.Category = strings.TrimSpace(cat.Category)
if len(cat.Category) > 30 {
cat.Category = cat.Category[:30]
}
err = h.Store.Category.Add(ctx, cat)
if err != nil {
ctx.Transaction.Rollback()