package args import "errors" type LoginReq struct { Account string `json:"account"` Password string `json:"password"` } func (arg LoginReq) Validate() (err error) { if len(arg.Account) == 0 { err = errors.New("account is empty") return } if len(arg.Account) > 36 { err = errors.New("account length must be at most 36") return } if len(arg.Password) < 6 || len(arg.Password) > 128 { err = errors.New("password length must be at least 6 and at most 128") return } return }