change_password.go 775 字节
package command

import (
	"fmt"

	"github.com/beego/beego/v2/core/validation"
)

type ChangePasswordCommand struct {
	// 旧密码
	OldPwd string `json:"oldPwd,omitempty"`
	// 新密码
	NewPwd string `json:"newPwd,omitempty"`
	// 确认密码
	ConfirmPwd string `json:"confirmPwd,omitempty"`
	// 手机号
	Phone string `json:"phone,omitempty"`
}

func (changePasswordCommand *ChangePasswordCommand) Valid(validation *validation.Validation) {

}

func (changePasswordCommand *ChangePasswordCommand) ValidateCommand() error {
	valid := validation.Validation{}
	b, err := valid.Valid(changePasswordCommand)
	if err != nil {
		return err
	}
	if !b {
		for _, validErr := range valid.Errors {
			return fmt.Errorf("%s  %s", validErr.Key, validErr.Message)
		}
	}
	return nil
}