Ai
1 Star 0 Fork 0

爱哭的毛毛虫/tcc-protoc

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
base.pb.validate.go 12.80 KB
一键复制 编辑 原始数据 按行查看 历史
cat 提交于 2024-07-23 22:22 +08:00 . 商品购买api定义
// Code generated by protoc-gen-validate. DO NOT EDIT.
// source: base/base.proto
package base
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 Error 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 *Error) Validate() error {
return m.validate(false)
}
// ValidateAll checks the field values on Error 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 ErrorMultiError, or nil if none found.
func (m *Error) ValidateAll() error {
return m.validate(true)
}
func (m *Error) validate(all bool) error {
if m == nil {
return nil
}
var errors []error
// no validation rules for Code
// no validation rules for Message
if len(errors) > 0 {
return ErrorMultiError(errors)
}
return nil
}
// ErrorMultiError is an error wrapping multiple validation errors returned by
// Error.ValidateAll() if the designated constraints aren't met.
type ErrorMultiError []error
// Error returns a concatenation of all the error messages it wraps.
func (m ErrorMultiError) 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 ErrorMultiError) AllErrors() []error { return m }
// ErrorValidationError is the validation error returned by Error.Validate if
// the designated constraints aren't met.
type ErrorValidationError struct {
field string
reason string
cause error
key bool
}
// Field function returns field value.
func (e ErrorValidationError) Field() string { return e.field }
// Reason function returns reason value.
func (e ErrorValidationError) Reason() string { return e.reason }
// Cause function returns cause value.
func (e ErrorValidationError) Cause() error { return e.cause }
// Key function returns key value.
func (e ErrorValidationError) Key() bool { return e.key }
// ErrorName returns error name.
func (e ErrorValidationError) ErrorName() string { return "ErrorValidationError" }
// Error satisfies the builtin error interface
func (e ErrorValidationError) 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 %sError.%s: %s%s",
key,
e.field,
e.reason,
cause)
}
var _ error = ErrorValidationError{}
var _ interface {
Field() string
Reason() string
Key() bool
Cause() error
ErrorName() string
} = ErrorValidationError{}
// Validate checks the field values on OperateRequest 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 *OperateRequest) Validate() error {
return m.validate(false)
}
// ValidateAll checks the field values on OperateRequest 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 OperateRequestMultiError,
// or nil if none found.
func (m *OperateRequest) ValidateAll() error {
return m.validate(true)
}
func (m *OperateRequest) validate(all bool) error {
if m == nil {
return nil
}
var errors []error
// no validation rules for RequestID
if len(errors) > 0 {
return OperateRequestMultiError(errors)
}
return nil
}
// OperateRequestMultiError is an error wrapping multiple validation errors
// returned by OperateRequest.ValidateAll() if the designated constraints
// aren't met.
type OperateRequestMultiError []error
// Error returns a concatenation of all the error messages it wraps.
func (m OperateRequestMultiError) 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 OperateRequestMultiError) AllErrors() []error { return m }
// OperateRequestValidationError is the validation error returned by
// OperateRequest.Validate if the designated constraints aren't met.
type OperateRequestValidationError struct {
field string
reason string
cause error
key bool
}
// Field function returns field value.
func (e OperateRequestValidationError) Field() string { return e.field }
// Reason function returns reason value.
func (e OperateRequestValidationError) Reason() string { return e.reason }
// Cause function returns cause value.
func (e OperateRequestValidationError) Cause() error { return e.cause }
// Key function returns key value.
func (e OperateRequestValidationError) Key() bool { return e.key }
// ErrorName returns error name.
func (e OperateRequestValidationError) ErrorName() string { return "OperateRequestValidationError" }
// Error satisfies the builtin error interface
func (e OperateRequestValidationError) 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 %sOperateRequest.%s: %s%s",
key,
e.field,
e.reason,
cause)
}
var _ error = OperateRequestValidationError{}
var _ interface {
Field() string
Reason() string
Key() bool
Cause() error
ErrorName() string
} = OperateRequestValidationError{}
// Validate checks the field values on OperateReply 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 *OperateReply) Validate() error {
return m.validate(false)
}
// ValidateAll checks the field values on OperateReply 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 OperateReplyMultiError, or
// nil if none found.
func (m *OperateReply) ValidateAll() error {
return m.validate(true)
}
func (m *OperateReply) validate(all bool) error {
if m == nil {
return nil
}
var errors []error
if all {
switch v := interface{}(m.GetResponse()).(type) {
case interface{ ValidateAll() error }:
if err := v.ValidateAll(); err != nil {
errors = append(errors, OperateReplyValidationError{
field: "Response",
reason: "embedded message failed validation",
cause: err,
})
}
case interface{ Validate() error }:
if err := v.Validate(); err != nil {
errors = append(errors, OperateReplyValidationError{
field: "Response",
reason: "embedded message failed validation",
cause: err,
})
}
}
} else if v, ok := interface{}(m.GetResponse()).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return OperateReplyValidationError{
field: "Response",
reason: "embedded message failed validation",
cause: err,
}
}
}
if len(errors) > 0 {
return OperateReplyMultiError(errors)
}
return nil
}
// OperateReplyMultiError is an error wrapping multiple validation errors
// returned by OperateReply.ValidateAll() if the designated constraints aren't met.
type OperateReplyMultiError []error
// Error returns a concatenation of all the error messages it wraps.
func (m OperateReplyMultiError) 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 OperateReplyMultiError) AllErrors() []error { return m }
// OperateReplyValidationError is the validation error returned by
// OperateReply.Validate if the designated constraints aren't met.
type OperateReplyValidationError struct {
field string
reason string
cause error
key bool
}
// Field function returns field value.
func (e OperateReplyValidationError) Field() string { return e.field }
// Reason function returns reason value.
func (e OperateReplyValidationError) Reason() string { return e.reason }
// Cause function returns cause value.
func (e OperateReplyValidationError) Cause() error { return e.cause }
// Key function returns key value.
func (e OperateReplyValidationError) Key() bool { return e.key }
// ErrorName returns error name.
func (e OperateReplyValidationError) ErrorName() string { return "OperateReplyValidationError" }
// Error satisfies the builtin error interface
func (e OperateReplyValidationError) 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 %sOperateReply.%s: %s%s",
key,
e.field,
e.reason,
cause)
}
var _ error = OperateReplyValidationError{}
var _ interface {
Field() string
Reason() string
Key() bool
Cause() error
ErrorName() string
} = OperateReplyValidationError{}
// Validate checks the field values on OperateResponse 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 *OperateResponse) Validate() error {
return m.validate(false)
}
// ValidateAll checks the field values on OperateResponse 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
// OperateResponseMultiError, or nil if none found.
func (m *OperateResponse) ValidateAll() error {
return m.validate(true)
}
func (m *OperateResponse) validate(all bool) error {
if m == nil {
return nil
}
var errors []error
// no validation rules for RequestID
// no validation rules for Data
if m.Error != nil {
if all {
switch v := interface{}(m.GetError()).(type) {
case interface{ ValidateAll() error }:
if err := v.ValidateAll(); err != nil {
errors = append(errors, OperateResponseValidationError{
field: "Error",
reason: "embedded message failed validation",
cause: err,
})
}
case interface{ Validate() error }:
if err := v.Validate(); err != nil {
errors = append(errors, OperateResponseValidationError{
field: "Error",
reason: "embedded message failed validation",
cause: err,
})
}
}
} else if v, ok := interface{}(m.GetError()).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return OperateResponseValidationError{
field: "Error",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
if len(errors) > 0 {
return OperateResponseMultiError(errors)
}
return nil
}
// OperateResponseMultiError is an error wrapping multiple validation errors
// returned by OperateResponse.ValidateAll() if the designated constraints
// aren't met.
type OperateResponseMultiError []error
// Error returns a concatenation of all the error messages it wraps.
func (m OperateResponseMultiError) 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 OperateResponseMultiError) AllErrors() []error { return m }
// OperateResponseValidationError is the validation error returned by
// OperateResponse.Validate if the designated constraints aren't met.
type OperateResponseValidationError struct {
field string
reason string
cause error
key bool
}
// Field function returns field value.
func (e OperateResponseValidationError) Field() string { return e.field }
// Reason function returns reason value.
func (e OperateResponseValidationError) Reason() string { return e.reason }
// Cause function returns cause value.
func (e OperateResponseValidationError) Cause() error { return e.cause }
// Key function returns key value.
func (e OperateResponseValidationError) Key() bool { return e.key }
// ErrorName returns error name.
func (e OperateResponseValidationError) ErrorName() string { return "OperateResponseValidationError" }
// Error satisfies the builtin error interface
func (e OperateResponseValidationError) 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 %sOperateResponse.%s: %s%s",
key,
e.field,
e.reason,
cause)
}
var _ error = OperateResponseValidationError{}
var _ interface {
Field() string
Reason() string
Key() bool
Cause() error
ErrorName() string
} = OperateResponseValidationError{}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/xiaoluo_1024/tcc-protoc.git
git@gitee.com:xiaoluo_1024/tcc-protoc.git
xiaoluo_1024
tcc-protoc
tcc-protoc
v1.1.0

搜索帮助