Debian Codegraph @

envoy/extensions/health_checkers/thrift/v3/thrift.pb.validate.go

raw
1 //go:build !disable_pgv
2 // Code generated by protoc-gen-validate. DO NOT EDIT.
3 // source: envoy/extensions/health_checkers/thrift/v3/thrift.proto
4
5 package thriftv3
6
7 import (
8 "bytes"
9 "errors"
10 "fmt"
11 "net"
12 "net/mail"
13 "net/url"
14 "regexp"
15 "sort"
16 "strings"
17 "time"
18 "unicode/utf8"
19
20 "google.golang.org/protobuf/types/known/anypb"
21
22 v3 "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/thrift_proxy/v3"
23 )
24
25 // ensure the imports are used
26 var (
27 _ = bytes.MinRead
28 _ = errors.New("")
29 _ = fmt.Print
30 _ = utf8.UTFMax
31 _ = (*regexp.Regexp)(nil)
32 _ = (*strings.Reader)(nil)
33 _ = net.IPv4len
34 _ = time.Duration(0)
35 _ = (*url.URL)(nil)
36 _ = (*mail.Address)(nil)
37 _ = anypb.Any{}
38 _ = sort.Sort
39
40 _ = v3.TransportType(0)
41 )
42
43 // Validate checks the field values on Thrift with the rules defined in the
44 // proto definition for this message. If any rules are violated, the first
45 // error encountered is returned, or nil if there are no violations.
46 func (m *Thrift) Validate() error {
47 return m.validate(false)
48 }
49
50 // ValidateAll checks the field values on Thrift with the rules defined in the
51 // proto definition for this message. If any rules are violated, the result is
52 // a list of violation errors wrapped in ThriftMultiError, or nil if none found.
53 func (m *Thrift) ValidateAll() error {
54 return m.validate(true)
55 }
56
57 func (m *Thrift) validate(all bool) error {
58 if m == nil {
59 return nil
60 }
61
62 var errors []error
63
64 if utf8.RuneCountInString(m.GetMethodName()) < 1 {
65 err := ThriftValidationError{
66 field: "MethodName",
67 reason: "value length must be at least 1 runes",
68 }
69 if !all {
70 return err
71 }
72 errors = append(errors, err)
73 }
74
75 if _, ok := v3.TransportType_name[int32(m.GetTransport())]; !ok {
76 err := ThriftValidationError{
77 field: "Transport",
78 reason: "value must be one of the defined enum values",
79 }
80 if !all {
81 return err
82 }
83 errors = append(errors, err)
84 }
85
86 if _, ok := v3.ProtocolType_name[int32(m.GetProtocol())]; !ok {
87 err := ThriftValidationError{
88 field: "Protocol",
89 reason: "value must be one of the defined enum values",
90 }
91 if !all {
92 return err
93 }
94 errors = append(errors, err)
95 }
96
97 if len(errors) > 0 {
98 return ThriftMultiError(errors)
99 }
100
101 return nil
102 }
103
104 // ThriftMultiError is an error wrapping multiple validation errors returned by
105 // Thrift.ValidateAll() if the designated constraints aren't met.
106 type ThriftMultiError []error
107
108 // Error returns a concatenation of all the error messages it wraps.
109 func (m ThriftMultiError) Error() string {
110 var msgs []string
111 for _, err := range m {
112 msgs = append(msgs, err.Error())
113 }
114 return strings.Join(msgs, "; ")
115 }
116
117 // AllErrors returns a list of validation violation errors.
118 func (m ThriftMultiError) AllErrors() []error { return m }
119
120 // ThriftValidationError is the validation error returned by Thrift.Validate if
121 // the designated constraints aren't met.
122 type ThriftValidationError struct {
123 field string
124 reason string
125 cause error
126 key bool
127 }
128
129 // Field function returns field value.
130 func (e ThriftValidationError) Field() string { return e.field }
131
132 // Reason function returns reason value.
133 func (e ThriftValidationError) Reason() string { return e.reason }
134
135 // Cause function returns cause value.
136 func (e ThriftValidationError) Cause() error { return e.cause }
137
138 // Key function returns key value.
139 func (e ThriftValidationError) Key() bool { return e.key }
140
141 // ErrorName returns error name.
142 func (e ThriftValidationError) ErrorName() string { return "ThriftValidationError" }
143
144 // Error satisfies the builtin error interface
145 func (e ThriftValidationError) Error() string {
146 cause := ""
147 if e.cause != nil {
148 cause = fmt.Sprintf(" | caused by: %v", e.cause)
149 }
150
151 key := ""
152 if e.key {
153 key = "key for "
154 }
155
156 return fmt.Sprintf(
157 "invalid %sThrift.%s: %s%s",
158 key,
159 e.field,
160 e.reason,
161 cause)
162 }
163
164 var _ error = ThriftValidationError{}
165
166 var _ interface {
167 Field() string
168 Reason() string
169 Key() bool
170 Cause() error
171 ErrorName() string
172 } = ThriftValidationError{}