check_smscode.go
753 字节
package command
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
)
type CheckSmsCodeCommand struct {
Phone string `json:"phone" valid:"Required"`
SmsCode string `json:"smsCode" valid:"Required"`
// [1:登录][2:修改密码][3:找回密码][4:注册][5:修改手机号]
Action int `json:"action" valid:"Required"`
}
func (checkSmsCodeCommand *CheckSmsCodeCommand) Valid(validation *validation.Validation) {
}
func (checkSmsCodeCommand *CheckSmsCodeCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(checkSmsCodeCommand)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}