...
|
...
|
@@ -2,6 +2,7 @@ package command |
|
|
|
|
|
import (
|
|
|
"github.com/beego/beego/v2/core/validation"
|
|
|
"unicode/utf8"
|
|
|
)
|
|
|
|
|
|
type CreateTemplateCommand struct {
|
...
|
...
|
@@ -21,12 +22,13 @@ func (in *CreateTemplateCommand) Valid(validation *validation.Validation) { |
|
|
return
|
|
|
}
|
|
|
|
|
|
if len(in.Name) > 40 {
|
|
|
// 这个才是真正计算字符串文字长度的 utf8.RuneCountInString(in.Name)
|
|
|
if utf8.RuneCountInString(in.Name) > 40 {
|
|
|
validation.SetError("name", "模板名称最大长度40个字符")
|
|
|
return
|
|
|
}
|
|
|
|
|
|
if len(in.Describe) > 100 {
|
|
|
if utf8.RuneCountInString(in.Describe) > 100 {
|
|
|
validation.SetError("describe", "备注最大长度100个字符")
|
|
|
return
|
|
|
}
|
...
|
...
|
|