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:
parent
a0f6626367
commit
10a184ad10
1 changed files with 7 additions and 0 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue