代码拉取完成,页面将自动刷新
// 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{}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。