Ai
1 Star 0 Fork 0

JohnZhan/user_server_api

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
user.pb.validate.go 29.74 KB
一键复制 编辑 原始数据 按行查看 历史
Your Name 提交于 2023-03-09 23:04 +08:00 . v3.3.0
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155
// Code generated by protoc-gen-validate. DO NOT EDIT.
// source: user.proto
package proto
import (
"bytes"
"errors"
"fmt"
"net"
"net/mail"
"net/url"
"regexp"
"sort"
"strings"
"time"
"unicode/utf8"
"google.golang.org/protobuf/types/known/anypb"
)
// ensure the imports are used
var (
_ = bytes.MinRead
_ = errors.New("")
_ = fmt.Print
_ = utf8.UTFMax
_ = (*regexp.Regexp)(nil)
_ = (*strings.Reader)(nil)
_ = net.IPv4len
_ = time.Duration(0)
_ = (*url.URL)(nil)
_ = (*mail.Address)(nil)
_ = anypb.Any{}
_ = sort.Sort
)
// Validate checks the field values on PageInfo with the rules defined in the
// proto definition for this message. If any rules are violated, the first
// error encountered is returned, or nil if there are no violations.
func (m *PageInfo) Validate() error {
return m.validate(false)
}
// ValidateAll checks the field values on PageInfo with the rules defined in
// the proto definition for this message. If any rules are violated, the
// result is a list of violation errors wrapped in PageInfoMultiError, or nil
// if none found.
func (m *PageInfo) ValidateAll() error {
return m.validate(true)
}
func (m *PageInfo) validate(all bool) error {
if m == nil {
return nil
}
var errors []error
if m.GetPn() < 0 {
err := PageInfoValidationError{
field: "Pn",
reason: "value must be greater than or equal to 0",
}
if !all {
return err
}
errors = append(errors, err)
}
if m.GetPSize() <= 0 {
err := PageInfoValidationError{
field: "PSize",
reason: "value must be greater than 0",
}
if !all {
return err
}
errors = append(errors, err)
}
if len(errors) > 0 {
return PageInfoMultiError(errors)
}
return nil
}
// PageInfoMultiError is an error wrapping multiple validation errors returned
// by PageInfo.ValidateAll() if the designated constraints aren't met.
type PageInfoMultiError []error
// Error returns a concatenation of all the error messages it wraps.
func (m PageInfoMultiError) Error() string {
var msgs []string
for _, err := range m {
msgs = append(msgs, err.Error())
}
return strings.Join(msgs, "; ")
}
// AllErrors returns a list of validation violation errors.
func (m PageInfoMultiError) AllErrors() []error { return m }
// PageInfoValidationError is the validation error returned by
// PageInfo.Validate if the designated constraints aren't met.
type PageInfoValidationError struct {
field string
reason string
cause error
key bool
}
// Field function returns field value.
func (e PageInfoValidationError) Field() string { return e.field }
// Reason function returns reason value.
func (e PageInfoValidationError) Reason() string { return e.reason }
// Cause function returns cause value.
func (e PageInfoValidationError) Cause() error { return e.cause }
// Key function returns key value.
func (e PageInfoValidationError) Key() bool { return e.key }
// ErrorName returns error name.
func (e PageInfoValidationError) ErrorName() string { return "PageInfoValidationError" }
// Error satisfies the builtin error interface
func (e PageInfoValidationError) Error() string {
cause := ""
if e.cause != nil {
cause = fmt.Sprintf(" | caused by: %v", e.cause)
}
key := ""
if e.key {
key = "key for "
}
return fmt.Sprintf(
"invalid %sPageInfo.%s: %s%s",
key,
e.field,
e.reason,
cause)
}
var _ error = PageInfoValidationError{}
var _ interface {
Field() string
Reason() string
Key() bool
Cause() error
ErrorName() string
} = PageInfoValidationError{}
// Validate checks the field values on UserInfoResponse with the rules defined
// in the proto definition for this message. If any rules are violated, the
// first error encountered is returned, or nil if there are no violations.
func (m *UserInfoResponse) Validate() error {
return m.validate(false)
}
// ValidateAll checks the field values on UserInfoResponse with the rules
// defined in the proto definition for this message. If any rules are
// violated, the result is a list of violation errors wrapped in
// UserInfoResponseMultiError, or nil if none found.
func (m *UserInfoResponse) ValidateAll() error {
return m.validate(true)
}
func (m *UserInfoResponse) validate(all bool) error {
if m == nil {
return nil
}
var errors []error
// no validation rules for Id
// no validation rules for Mobile
// no validation rules for NickName
if all {
switch v := interface{}(m.GetBirthday()).(type) {
case interface{ ValidateAll() error }:
if err := v.ValidateAll(); err != nil {
errors = append(errors, UserInfoResponseValidationError{
field: "Birthday",
reason: "embedded message failed validation",
cause: err,
})
}
case interface{ Validate() error }:
if err := v.Validate(); err != nil {
errors = append(errors, UserInfoResponseValidationError{
field: "Birthday",
reason: "embedded message failed validation",
cause: err,
})
}
}
} else if v, ok := interface{}(m.GetBirthday()).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return UserInfoResponseValidationError{
field: "Birthday",
reason: "embedded message failed validation",
cause: err,
}
}
}
// no validation rules for Gender
// no validation rules for RoleId
if len(errors) > 0 {
return UserInfoResponseMultiError(errors)
}
return nil
}
// UserInfoResponseMultiError is an error wrapping multiple validation errors
// returned by UserInfoResponse.ValidateAll() if the designated constraints
// aren't met.
type UserInfoResponseMultiError []error
// Error returns a concatenation of all the error messages it wraps.
func (m UserInfoResponseMultiError) Error() string {
var msgs []string
for _, err := range m {
msgs = append(msgs, err.Error())
}
return strings.Join(msgs, "; ")
}
// AllErrors returns a list of validation violation errors.
func (m UserInfoResponseMultiError) AllErrors() []error { return m }
// UserInfoResponseValidationError is the validation error returned by
// UserInfoResponse.Validate if the designated constraints aren't met.
type UserInfoResponseValidationError struct {
field string
reason string
cause error
key bool
}
// Field function returns field value.
func (e UserInfoResponseValidationError) Field() string { return e.field }
// Reason function returns reason value.
func (e UserInfoResponseValidationError) Reason() string { return e.reason }
// Cause function returns cause value.
func (e UserInfoResponseValidationError) Cause() error { return e.cause }
// Key function returns key value.
func (e UserInfoResponseValidationError) Key() bool { return e.key }
// ErrorName returns error name.
func (e UserInfoResponseValidationError) ErrorName() string { return "UserInfoResponseValidationError" }
// Error satisfies the builtin error interface
func (e UserInfoResponseValidationError) Error() string {
cause := ""
if e.cause != nil {
cause = fmt.Sprintf(" | caused by: %v", e.cause)
}
key := ""
if e.key {
key = "key for "
}
return fmt.Sprintf(
"invalid %sUserInfoResponse.%s: %s%s",
key,
e.field,
e.reason,
cause)
}
var _ error = UserInfoResponseValidationError{}
var _ interface {
Field() string
Reason() string
Key() bool
Cause() error
ErrorName() string
} = UserInfoResponseValidationError{}
// Validate checks the field values on MobileRequest with the rules defined in
// the proto definition for this message. If any rules are violated, the first
// error encountered is returned, or nil if there are no violations.
func (m *MobileRequest) Validate() error {
return m.validate(false)
}
// ValidateAll checks the field values on MobileRequest with the rules defined
// in the proto definition for this message. If any rules are violated, the
// result is a list of violation errors wrapped in MobileRequestMultiError, or
// nil if none found.
func (m *MobileRequest) ValidateAll() error {
return m.validate(true)
}
func (m *MobileRequest) validate(all bool) error {
if m == nil {
return nil
}
var errors []error
if !_MobileRequest_Mobile_Pattern.MatchString(m.GetMobile()) {
err := MobileRequestValidationError{
field: "Mobile",
reason: "value does not match regex pattern \"^1([38][0-9]|14[579]|5[^4]|16[6]|7[1-35-8]|9[189])[0-9]{8}$\"",
}
if !all {
return err
}
errors = append(errors, err)
}
if len(errors) > 0 {
return MobileRequestMultiError(errors)
}
return nil
}
// MobileRequestMultiError is an error wrapping multiple validation errors
// returned by MobileRequest.ValidateAll() if the designated constraints
// aren't met.
type MobileRequestMultiError []error
// Error returns a concatenation of all the error messages it wraps.
func (m MobileRequestMultiError) Error() string {
var msgs []string
for _, err := range m {
msgs = append(msgs, err.Error())
}
return strings.Join(msgs, "; ")
}
// AllErrors returns a list of validation violation errors.
func (m MobileRequestMultiError) AllErrors() []error { return m }
// MobileRequestValidationError is the validation error returned by
// MobileRequest.Validate if the designated constraints aren't met.
type MobileRequestValidationError struct {
field string
reason string
cause error
key bool
}
// Field function returns field value.
func (e MobileRequestValidationError) Field() string { return e.field }
// Reason function returns reason value.
func (e MobileRequestValidationError) Reason() string { return e.reason }
// Cause function returns cause value.
func (e MobileRequestValidationError) Cause() error { return e.cause }
// Key function returns key value.
func (e MobileRequestValidationError) Key() bool { return e.key }
// ErrorName returns error name.
func (e MobileRequestValidationError) ErrorName() string { return "MobileRequestValidationError" }
// Error satisfies the builtin error interface
func (e MobileRequestValidationError) Error() string {
cause := ""
if e.cause != nil {
cause = fmt.Sprintf(" | caused by: %v", e.cause)
}
key := ""
if e.key {
key = "key for "
}
return fmt.Sprintf(
"invalid %sMobileRequest.%s: %s%s",
key,
e.field,
e.reason,
cause)
}
var _ error = MobileRequestValidationError{}
var _ interface {
Field() string
Reason() string
Key() bool
Cause() error
ErrorName() string
} = MobileRequestValidationError{}
var _MobileRequest_Mobile_Pattern = regexp.MustCompile("^1([38][0-9]|14[579]|5[^4]|16[6]|7[1-35-8]|9[189])[0-9]{8}$")
// Validate checks the field values on IdRequest with the rules defined in the
// proto definition for this message. If any rules are violated, the first
// error encountered is returned, or nil if there are no violations.
func (m *IdRequest) Validate() error {
return m.validate(false)
}
// ValidateAll checks the field values on IdRequest with the rules defined in
// the proto definition for this message. If any rules are violated, the
// result is a list of violation errors wrapped in IdRequestMultiError, or nil
// if none found.
func (m *IdRequest) ValidateAll() error {
return m.validate(true)
}
func (m *IdRequest) validate(all bool) error {
if m == nil {
return nil
}
var errors []error
if m.GetId() < 0 {
err := IdRequestValidationError{
field: "Id",
reason: "value must be greater than or equal to 0",
}
if !all {
return err
}
errors = append(errors, err)
}
if len(errors) > 0 {
return IdRequestMultiError(errors)
}
return nil
}
// IdRequestMultiError is an error wrapping multiple validation errors returned
// by IdRequest.ValidateAll() if the designated constraints aren't met.
type IdRequestMultiError []error
// Error returns a concatenation of all the error messages it wraps.
func (m IdRequestMultiError) Error() string {
var msgs []string
for _, err := range m {
msgs = append(msgs, err.Error())
}
return strings.Join(msgs, "; ")
}
// AllErrors returns a list of validation violation errors.
func (m IdRequestMultiError) AllErrors() []error { return m }
// IdRequestValidationError is the validation error returned by
// IdRequest.Validate if the designated constraints aren't met.
type IdRequestValidationError struct {
field string
reason string
cause error
key bool
}
// Field function returns field value.
func (e IdRequestValidationError) Field() string { return e.field }
// Reason function returns reason value.
func (e IdRequestValidationError) Reason() string { return e.reason }
// Cause function returns cause value.
func (e IdRequestValidationError) Cause() error { return e.cause }
// Key function returns key value.
func (e IdRequestValidationError) Key() bool { return e.key }
// ErrorName returns error name.
func (e IdRequestValidationError) ErrorName() string { return "IdRequestValidationError" }
// Error satisfies the builtin error interface
func (e IdRequestValidationError) Error() string {
cause := ""
if e.cause != nil {
cause = fmt.Sprintf(" | caused by: %v", e.cause)
}
key := ""
if e.key {
key = "key for "
}
return fmt.Sprintf(
"invalid %sIdRequest.%s: %s%s",
key,
e.field,
e.reason,
cause)
}
var _ error = IdRequestValidationError{}
var _ interface {
Field() string
Reason() string
Key() bool
Cause() error
ErrorName() string
} = IdRequestValidationError{}
// Validate checks the field values on UserListResponse with the rules defined
// in the proto definition for this message. If any rules are violated, the
// first error encountered is returned, or nil if there are no violations.
func (m *UserListResponse) Validate() error {
return m.validate(false)
}
// ValidateAll checks the field values on UserListResponse with the rules
// defined in the proto definition for this message. If any rules are
// violated, the result is a list of violation errors wrapped in
// UserListResponseMultiError, or nil if none found.
func (m *UserListResponse) ValidateAll() error {
return m.validate(true)
}
func (m *UserListResponse) validate(all bool) error {
if m == nil {
return nil
}
var errors []error
// no validation rules for Count
for idx, item := range m.GetData() {
_, _ = idx, item
if all {
switch v := interface{}(item).(type) {
case interface{ ValidateAll() error }:
if err := v.ValidateAll(); err != nil {
errors = append(errors, UserListResponseValidationError{
field: fmt.Sprintf("Data[%v]", idx),
reason: "embedded message failed validation",
cause: err,
})
}
case interface{ Validate() error }:
if err := v.Validate(); err != nil {
errors = append(errors, UserListResponseValidationError{
field: fmt.Sprintf("Data[%v]", idx),
reason: "embedded message failed validation",
cause: err,
})
}
}
} else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return UserListResponseValidationError{
field: fmt.Sprintf("Data[%v]", idx),
reason: "embedded message failed validation",
cause: err,
}
}
}
}
if len(errors) > 0 {
return UserListResponseMultiError(errors)
}
return nil
}
// UserListResponseMultiError is an error wrapping multiple validation errors
// returned by UserListResponse.ValidateAll() if the designated constraints
// aren't met.
type UserListResponseMultiError []error
// Error returns a concatenation of all the error messages it wraps.
func (m UserListResponseMultiError) Error() string {
var msgs []string
for _, err := range m {
msgs = append(msgs, err.Error())
}
return strings.Join(msgs, "; ")
}
// AllErrors returns a list of validation violation errors.
func (m UserListResponseMultiError) AllErrors() []error { return m }
// UserListResponseValidationError is the validation error returned by
// UserListResponse.Validate if the designated constraints aren't met.
type UserListResponseValidationError struct {
field string
reason string
cause error
key bool
}
// Field function returns field value.
func (e UserListResponseValidationError) Field() string { return e.field }
// Reason function returns reason value.
func (e UserListResponseValidationError) Reason() string { return e.reason }
// Cause function returns cause value.
func (e UserListResponseValidationError) Cause() error { return e.cause }
// Key function returns key value.
func (e UserListResponseValidationError) Key() bool { return e.key }
// ErrorName returns error name.
func (e UserListResponseValidationError) ErrorName() string { return "UserListResponseValidationError" }
// Error satisfies the builtin error interface
func (e UserListResponseValidationError) Error() string {
cause := ""
if e.cause != nil {
cause = fmt.Sprintf(" | caused by: %v", e.cause)
}
key := ""
if e.key {
key = "key for "
}
return fmt.Sprintf(
"invalid %sUserListResponse.%s: %s%s",
key,
e.field,
e.reason,
cause)
}
var _ error = UserListResponseValidationError{}
var _ interface {
Field() string
Reason() string
Key() bool
Cause() error
ErrorName() string
} = UserListResponseValidationError{}
// Validate checks the field values on CreateUserRequest with the rules defined
// in the proto definition for this message. If any rules are violated, the
// first error encountered is returned, or nil if there are no violations.
func (m *CreateUserRequest) Validate() error {
return m.validate(false)
}
// ValidateAll checks the field values on CreateUserRequest with the rules
// defined in the proto definition for this message. If any rules are
// violated, the result is a list of violation errors wrapped in
// CreateUserRequestMultiError, or nil if none found.
func (m *CreateUserRequest) ValidateAll() error {
return m.validate(true)
}
func (m *CreateUserRequest) validate(all bool) error {
if m == nil {
return nil
}
var errors []error
if !_CreateUserRequest_Mobile_Pattern.MatchString(m.GetMobile()) {
err := CreateUserRequestValidationError{
field: "Mobile",
reason: "value does not match regex pattern \"^1([38][0-9]|14[579]|5[^4]|16[6]|7[1-35-8]|9[189])[0-9]{8}$\"",
}
if !all {
return err
}
errors = append(errors, err)
}
if l := utf8.RuneCountInString(m.GetPasswd()); l < 6 || l > 20 {
err := CreateUserRequestValidationError{
field: "Passwd",
reason: "value length must be between 6 and 20 runes, inclusive",
}
if !all {
return err
}
errors = append(errors, err)
}
if l := utf8.RuneCountInString(m.GetNickName()); l < 2 || l > 6 {
err := CreateUserRequestValidationError{
field: "NickName",
reason: "value length must be between 2 and 6 runes, inclusive",
}
if !all {
return err
}
errors = append(errors, err)
}
if len(errors) > 0 {
return CreateUserRequestMultiError(errors)
}
return nil
}
// CreateUserRequestMultiError is an error wrapping multiple validation errors
// returned by CreateUserRequest.ValidateAll() if the designated constraints
// aren't met.
type CreateUserRequestMultiError []error
// Error returns a concatenation of all the error messages it wraps.
func (m CreateUserRequestMultiError) Error() string {
var msgs []string
for _, err := range m {
msgs = append(msgs, err.Error())
}
return strings.Join(msgs, "; ")
}
// AllErrors returns a list of validation violation errors.
func (m CreateUserRequestMultiError) AllErrors() []error { return m }
// CreateUserRequestValidationError is the validation error returned by
// CreateUserRequest.Validate if the designated constraints aren't met.
type CreateUserRequestValidationError struct {
field string
reason string
cause error
key bool
}
// Field function returns field value.
func (e CreateUserRequestValidationError) Field() string { return e.field }
// Reason function returns reason value.
func (e CreateUserRequestValidationError) Reason() string { return e.reason }
// Cause function returns cause value.
func (e CreateUserRequestValidationError) Cause() error { return e.cause }
// Key function returns key value.
func (e CreateUserRequestValidationError) Key() bool { return e.key }
// ErrorName returns error name.
func (e CreateUserRequestValidationError) ErrorName() string {
return "CreateUserRequestValidationError"
}
// Error satisfies the builtin error interface
func (e CreateUserRequestValidationError) Error() string {
cause := ""
if e.cause != nil {
cause = fmt.Sprintf(" | caused by: %v", e.cause)
}
key := ""
if e.key {
key = "key for "
}
return fmt.Sprintf(
"invalid %sCreateUserRequest.%s: %s%s",
key,
e.field,
e.reason,
cause)
}
var _ error = CreateUserRequestValidationError{}
var _ interface {
Field() string
Reason() string
Key() bool
Cause() error
ErrorName() string
} = CreateUserRequestValidationError{}
var _CreateUserRequest_Mobile_Pattern = regexp.MustCompile("^1([38][0-9]|14[579]|5[^4]|16[6]|7[1-35-8]|9[189])[0-9]{8}$")
// Validate checks the field values on UpdateUserRequest with the rules defined
// in the proto definition for this message. If any rules are violated, the
// first error encountered is returned, or nil if there are no violations.
func (m *UpdateUserRequest) Validate() error {
return m.validate(false)
}
// ValidateAll checks the field values on UpdateUserRequest with the rules
// defined in the proto definition for this message. If any rules are
// violated, the result is a list of violation errors wrapped in
// UpdateUserRequestMultiError, or nil if none found.
func (m *UpdateUserRequest) ValidateAll() error {
return m.validate(true)
}
func (m *UpdateUserRequest) validate(all bool) error {
if m == nil {
return nil
}
var errors []error
if m.GetId() < 0 {
err := UpdateUserRequestValidationError{
field: "Id",
reason: "value must be greater than or equal to 0",
}
if !all {
return err
}
errors = append(errors, err)
}
if l := utf8.RuneCountInString(m.GetNickName()); l < 2 || l > 6 {
err := UpdateUserRequestValidationError{
field: "NickName",
reason: "value length must be between 2 and 6 runes, inclusive",
}
if !all {
return err
}
errors = append(errors, err)
}
if m.GetBirthday() == nil {
err := UpdateUserRequestValidationError{
field: "Birthday",
reason: "value is required",
}
if !all {
return err
}
errors = append(errors, err)
}
// no validation rules for Gender
if len(errors) > 0 {
return UpdateUserRequestMultiError(errors)
}
return nil
}
// UpdateUserRequestMultiError is an error wrapping multiple validation errors
// returned by UpdateUserRequest.ValidateAll() if the designated constraints
// aren't met.
type UpdateUserRequestMultiError []error
// Error returns a concatenation of all the error messages it wraps.
func (m UpdateUserRequestMultiError) Error() string {
var msgs []string
for _, err := range m {
msgs = append(msgs, err.Error())
}
return strings.Join(msgs, "; ")
}
// AllErrors returns a list of validation violation errors.
func (m UpdateUserRequestMultiError) AllErrors() []error { return m }
// UpdateUserRequestValidationError is the validation error returned by
// UpdateUserRequest.Validate if the designated constraints aren't met.
type UpdateUserRequestValidationError struct {
field string
reason string
cause error
key bool
}
// Field function returns field value.
func (e UpdateUserRequestValidationError) Field() string { return e.field }
// Reason function returns reason value.
func (e UpdateUserRequestValidationError) Reason() string { return e.reason }
// Cause function returns cause value.
func (e UpdateUserRequestValidationError) Cause() error { return e.cause }
// Key function returns key value.
func (e UpdateUserRequestValidationError) Key() bool { return e.key }
// ErrorName returns error name.
func (e UpdateUserRequestValidationError) ErrorName() string {
return "UpdateUserRequestValidationError"
}
// Error satisfies the builtin error interface
func (e UpdateUserRequestValidationError) Error() string {
cause := ""
if e.cause != nil {
cause = fmt.Sprintf(" | caused by: %v", e.cause)
}
key := ""
if e.key {
key = "key for "
}
return fmt.Sprintf(
"invalid %sUpdateUserRequest.%s: %s%s",
key,
e.field,
e.reason,
cause)
}
var _ error = UpdateUserRequestValidationError{}
var _ interface {
Field() string
Reason() string
Key() bool
Cause() error
ErrorName() string
} = UpdateUserRequestValidationError{}
// Validate checks the field values on CheckResponse with the rules defined in
// the proto definition for this message. If any rules are violated, the first
// error encountered is returned, or nil if there are no violations.
func (m *CheckResponse) Validate() error {
return m.validate(false)
}
// ValidateAll checks the field values on CheckResponse with the rules defined
// in the proto definition for this message. If any rules are violated, the
// result is a list of violation errors wrapped in CheckResponseMultiError, or
// nil if none found.
func (m *CheckResponse) ValidateAll() error {
return m.validate(true)
}
func (m *CheckResponse) validate(all bool) error {
if m == nil {
return nil
}
var errors []error
// no validation rules for Success
if len(errors) > 0 {
return CheckResponseMultiError(errors)
}
return nil
}
// CheckResponseMultiError is an error wrapping multiple validation errors
// returned by CheckResponse.ValidateAll() if the designated constraints
// aren't met.
type CheckResponseMultiError []error
// Error returns a concatenation of all the error messages it wraps.
func (m CheckResponseMultiError) Error() string {
var msgs []string
for _, err := range m {
msgs = append(msgs, err.Error())
}
return strings.Join(msgs, "; ")
}
// AllErrors returns a list of validation violation errors.
func (m CheckResponseMultiError) AllErrors() []error { return m }
// CheckResponseValidationError is the validation error returned by
// CheckResponse.Validate if the designated constraints aren't met.
type CheckResponseValidationError struct {
field string
reason string
cause error
key bool
}
// Field function returns field value.
func (e CheckResponseValidationError) Field() string { return e.field }
// Reason function returns reason value.
func (e CheckResponseValidationError) Reason() string { return e.reason }
// Cause function returns cause value.
func (e CheckResponseValidationError) Cause() error { return e.cause }
// Key function returns key value.
func (e CheckResponseValidationError) Key() bool { return e.key }
// ErrorName returns error name.
func (e CheckResponseValidationError) ErrorName() string { return "CheckResponseValidationError" }
// Error satisfies the builtin error interface
func (e CheckResponseValidationError) Error() string {
cause := ""
if e.cause != nil {
cause = fmt.Sprintf(" | caused by: %v", e.cause)
}
key := ""
if e.key {
key = "key for "
}
return fmt.Sprintf(
"invalid %sCheckResponse.%s: %s%s",
key,
e.field,
e.reason,
cause)
}
var _ error = CheckResponseValidationError{}
var _ interface {
Field() string
Reason() string
Key() bool
Cause() error
ErrorName() string
} = CheckResponseValidationError{}
// Validate checks the field values on PasswordCheckRequest with the rules
// defined in the proto definition for this message. If any rules are
// violated, the first error encountered is returned, or nil if there are no violations.
func (m *PasswordCheckRequest) Validate() error {
return m.validate(false)
}
// ValidateAll checks the field values on PasswordCheckRequest with the rules
// defined in the proto definition for this message. If any rules are
// violated, the result is a list of violation errors wrapped in
// PasswordCheckRequestMultiError, or nil if none found.
func (m *PasswordCheckRequest) ValidateAll() error {
return m.validate(true)
}
func (m *PasswordCheckRequest) validate(all bool) error {
if m == nil {
return nil
}
var errors []error
if m.GetId() < 0 {
err := PasswordCheckRequestValidationError{
field: "Id",
reason: "value must be greater than or equal to 0",
}
if !all {
return err
}
errors = append(errors, err)
}
if l := utf8.RuneCountInString(m.GetPassword()); l < 6 || l > 20 {
err := PasswordCheckRequestValidationError{
field: "Password",
reason: "value length must be between 6 and 20 runes, inclusive",
}
if !all {
return err
}
errors = append(errors, err)
}
if len(errors) > 0 {
return PasswordCheckRequestMultiError(errors)
}
return nil
}
// PasswordCheckRequestMultiError is an error wrapping multiple validation
// errors returned by PasswordCheckRequest.ValidateAll() if the designated
// constraints aren't met.
type PasswordCheckRequestMultiError []error
// Error returns a concatenation of all the error messages it wraps.
func (m PasswordCheckRequestMultiError) Error() string {
var msgs []string
for _, err := range m {
msgs = append(msgs, err.Error())
}
return strings.Join(msgs, "; ")
}
// AllErrors returns a list of validation violation errors.
func (m PasswordCheckRequestMultiError) AllErrors() []error { return m }
// PasswordCheckRequestValidationError is the validation error returned by
// PasswordCheckRequest.Validate if the designated constraints aren't met.
type PasswordCheckRequestValidationError struct {
field string
reason string
cause error
key bool
}
// Field function returns field value.
func (e PasswordCheckRequestValidationError) Field() string { return e.field }
// Reason function returns reason value.
func (e PasswordCheckRequestValidationError) Reason() string { return e.reason }
// Cause function returns cause value.
func (e PasswordCheckRequestValidationError) Cause() error { return e.cause }
// Key function returns key value.
func (e PasswordCheckRequestValidationError) Key() bool { return e.key }
// ErrorName returns error name.
func (e PasswordCheckRequestValidationError) ErrorName() string {
return "PasswordCheckRequestValidationError"
}
// Error satisfies the builtin error interface
func (e PasswordCheckRequestValidationError) Error() string {
cause := ""
if e.cause != nil {
cause = fmt.Sprintf(" | caused by: %v", e.cause)
}
key := ""
if e.key {
key = "key for "
}
return fmt.Sprintf(
"invalid %sPasswordCheckRequest.%s: %s%s",
key,
e.field,
e.reason,
cause)
}
var _ error = PasswordCheckRequestValidationError{}
var _ interface {
Field() string
Reason() string
Key() bool
Cause() error
ErrorName() string
} = PasswordCheckRequestValidationError{}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/zhancaihua/user_server_api.git
git@gitee.com:zhancaihua/user_server_api.git
zhancaihua
user_server_api
user_server_api
v1.5.0

搜索帮助