Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions app/http/endpoints/api/forms/createform.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"net/http"
"strings"
"unicode/utf8"

"github.com/TicketsBot-cloud/dashboard/app"
"github.com/TicketsBot-cloud/dashboard/app/http/audit"
Expand Down Expand Up @@ -33,8 +34,8 @@ func CreateForm(c *gin.Context) {
return
}

if len(data.Title) > 45 {
c.JSON(400, utils.ErrorStr("Form title must be 45 characters or less (current: %d characters)", len(data.Title)))
if utf8.RuneCountInString(data.Title) > 45 {
c.JSON(400, utils.ErrorStr("Form title must be 45 characters or less (current: %d characters)", utf8.RuneCountInString(data.Title)))
return
}

Expand Down
5 changes: 3 additions & 2 deletions app/http/endpoints/api/forms/updateform.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"net/http"
"strconv"
"strings"
"unicode/utf8"

"github.com/TicketsBot-cloud/dashboard/app"
"github.com/TicketsBot-cloud/dashboard/app/http/audit"
Expand All @@ -29,8 +30,8 @@ func UpdateForm(c *gin.Context) {
return
}

if len(data.Title) > 45 {
c.JSON(400, utils.ErrorStr("Form title must be 45 characters or less (current: %d characters)", len(data.Title)))
if utf8.RuneCountInString(data.Title) > 45 {
c.JSON(400, utils.ErrorStr("Form title must be 45 characters or less (current: %d characters)", utf8.RuneCountInString(data.Title)))
return
}

Expand Down
8 changes: 4 additions & 4 deletions app/http/endpoints/api/panel/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func panelValidators() []validation.Validator[PanelValidationContext] {

func validateTitle(ctx PanelValidationContext) validation.ValidationFunc {
return func() error {
if len(ctx.Data.Title) > 80 {
if utf8.RuneCountInString(ctx.Data.Title) > 80 {
return validation.NewInvalidInputError("Panel title must be less than 80 characters")
}

Expand All @@ -93,7 +93,7 @@ func validateTitle(ctx PanelValidationContext) validation.ValidationFunc {

func validateContent(ctx PanelValidationContext) validation.ValidationFunc {
return func() error {
if len(ctx.Data.Content) > 4096 {
if utf8.RuneCountInString(ctx.Data.Content) > 4096 {
return validation.NewInvalidInputError("Panel content must be less than 4096 characters")
}

Expand Down Expand Up @@ -202,7 +202,7 @@ func validateButtonStyle(ctx PanelValidationContext) validation.ValidationFunc {

func validateButtonLabel(ctx PanelValidationContext) validation.ValidationFunc {
return func() error {
if len(ctx.Data.ButtonLabel) > 80 {
if utf8.RuneCountInString(ctx.Data.ButtonLabel) > 80 {
return validation.NewInvalidInputError("Button label must be less than 80 characters")
}

Expand Down Expand Up @@ -312,7 +312,7 @@ func validateNamingScheme(ctx PanelValidationContext) validation.ValidationFunc
return nil
}

if len(*ctx.Data.NamingScheme) > 100 {
if utf8.RuneCountInString(*ctx.Data.NamingScheme) > 100 {
return validation.NewInvalidInputError("Naming scheme must be less than 100 characters")
}

Expand Down