create_column_setting.go
804 字节
package command
import (
"fmt"
"github.com/astaxie/beego/validation"
)
type CreateColumnSettingCommand struct {
// 栏目设置描述
Description string `json:"description" valid:"Required"`
// 栏目设置关联用户名称
UserName string `json:"userName" valid:"Required"`
}
func (createColumnSettingCommand *CreateColumnSettingCommand) Valid(validation *validation.Validation) {
validation.SetError("CustomValid", "未实现的自定义认证")
}
func (createColumnSettingCommand *CreateColumnSettingCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(createColumnSettingCommand)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}