Debian Codegraph @

envoy/config/core/v3/event_service_config.pb.validate.go

raw
1 //go:build !disable_pgv
2 // Code generated by protoc-gen-validate. DO NOT EDIT.
3 // source: envoy/config/core/v3/event_service_config.proto
4
5 package corev3
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
23 // ensure the imports are used
24 var (
25 _ = bytes.MinRead
26 _ = errors.New("")
27 _ = fmt.Print
28 _ = utf8.UTFMax
29 _ = (*regexp.Regexp)(nil)
30 _ = (*strings.Reader)(nil)
31 _ = net.IPv4len
32 _ = time.Duration(0)
33 _ = (*url.URL)(nil)
34 _ = (*mail.Address)(nil)
35 _ = anypb.Any{}
36 _ = sort.Sort
37 )
38
39 // Validate checks the field values on EventServiceConfig with the rules
40 // defined in the proto definition for this message. If any rules are
41 // violated, the first error encountered is returned, or nil if there are no violations.
42 func (m *EventServiceConfig) Validate() error {
43 return m.validate(false)
44 }
45
46 // ValidateAll checks the field values on EventServiceConfig with the rules
47 // defined in the proto definition for this message. If any rules are
48 // violated, the result is a list of violation errors wrapped in
49 // EventServiceConfigMultiError, or nil if none found.
50 func (m *EventServiceConfig) ValidateAll() error {
51 return m.validate(true)
52 }
53
54 func (m *EventServiceConfig) validate(all bool) error {
55 if m == nil {
56 return nil
57 }
58
59 var errors []error
60
61 oneofConfigSourceSpecifierPresent := false
62 switch v := m.ConfigSourceSpecifier.(type) {
63 case *EventServiceConfig_GrpcService:
64 if v == nil {
65 err := EventServiceConfigValidationError{
66 field: "ConfigSourceSpecifier",
67 reason: "oneof value cannot be a typed-nil",
68 }
69 if !all {
70 return err
71 }
72 errors = append(errors, err)
73 }
74 oneofConfigSourceSpecifierPresent = true
75
76 if all {
77 switch v := interface{}(m.GetGrpcService()).(type) {
78 case interface{ ValidateAll() error }:
79 if err := v.ValidateAll(); err != nil {
80 errors = append(errors, EventServiceConfigValidationError{
81 field: "GrpcService",
82 reason: "embedded message failed validation",
83 cause: err,
84 })
85 }
86 case interface{ Validate() error }:
87 if err := v.Validate(); err != nil {
88 errors = append(errors, EventServiceConfigValidationError{
89 field: "GrpcService",
90 reason: "embedded message failed validation",
91 cause: err,
92 })
93 }
94 }
95 } else if v, ok := interface{}(m.GetGrpcService()).(interface{ Validate() error }); ok {
96 if err := v.Validate(); err != nil {
97 return EventServiceConfigValidationError{
98 field: "GrpcService",
99 reason: "embedded message failed validation",
100 cause: err,
101 }
102 }
103 }
104
105 default:
106 _ = v // ensures v is used
107 }
108 if !oneofConfigSourceSpecifierPresent {
109 err := EventServiceConfigValidationError{
110 field: "ConfigSourceSpecifier",
111 reason: "value is required",
112 }
113 if !all {
114 return err
115 }
116 errors = append(errors, err)
117 }
118
119 if len(errors) > 0 {
120 return EventServiceConfigMultiError(errors)
121 }
122
123 return nil
124 }
125
126 // EventServiceConfigMultiError is an error wrapping multiple validation errors
127 // returned by EventServiceConfig.ValidateAll() if the designated constraints
128 // aren't met.
129 type EventServiceConfigMultiError []error
130
131 // Error returns a concatenation of all the error messages it wraps.
132 func (m EventServiceConfigMultiError) Error() string {
133 var msgs []string
134 for _, err := range m {
135 msgs = append(msgs, err.Error())
136 }
137 return strings.Join(msgs, "; ")
138 }
139
140 // AllErrors returns a list of validation violation errors.
141 func (m EventServiceConfigMultiError) AllErrors() []error { return m }
142
143 // EventServiceConfigValidationError is the validation error returned by
144 // EventServiceConfig.Validate if the designated constraints aren't met.
145 type EventServiceConfigValidationError struct {
146 field string
147 reason string
148 cause error
149 key bool
150 }
151
152 // Field function returns field value.
153 func (e EventServiceConfigValidationError) Field() string { return e.field }
154
155 // Reason function returns reason value.
156 func (e EventServiceConfigValidationError) Reason() string { return e.reason }
157
158 // Cause function returns cause value.
159 func (e EventServiceConfigValidationError) Cause() error { return e.cause }
160
161 // Key function returns key value.
162 func (e EventServiceConfigValidationError) Key() bool { return e.key }
163
164 // ErrorName returns error name.
165 func (e EventServiceConfigValidationError) ErrorName() string {
166 return "EventServiceConfigValidationError"
167 }
168
169 // Error satisfies the builtin error interface
170 func (e EventServiceConfigValidationError) Error() string {
171 cause := ""
172 if e.cause != nil {
173 cause = fmt.Sprintf(" | caused by: %v", e.cause)
174 }
175
176 key := ""
177 if e.key {
178 key = "key for "
179 }
180
181 return fmt.Sprintf(
182 "invalid %sEventServiceConfig.%s: %s%s",
183 key,
184 e.field,
185 e.reason,
186 cause)
187 }
188
189 var _ error = EventServiceConfigValidationError{}
190
191 var _ interface {
192 Field() string
193 Reason() string
194 Key() bool
195 Cause() error
196 ErrorName() string
197 } = EventServiceConfigValidationError{}