command_change_password_request.go 750 字节
package command

import (
	"fmt"
	"github.com/astaxie/beego/validation"
)

type ChangePasswordRequest struct {
	Phone string `json:"phone" valid:"Required"`
	//OldPwd string `json:"oldPassword" valid:"Required"`
	//NewPwd string `json:"newPassword" valid:"Required"`
	Password string `json:"pwd"`
}

func (ChangePasswordRequest *ChangePasswordRequest) ValidateCommand() error {
	valid := validation.Validation{}
	b, err := valid.Valid(ChangePasswordRequest)
	if err != nil {
		return err
	}
	//if ChangePasswordRequest.OldPwd == ChangePasswordRequest.NewPwd {
	//	return errors.New("新旧密码不能相同")
	//}
	if !b {
		for _, validErr := range valid.Errors {
			return fmt.Errorf("%s  %s", validErr.Key, validErr.Message)
		}
	}
	return nil
}