Debian Codegraph @

envoy/config/trace/v3/service.pb.validate.go

raw
1 //go:build !disable_pgv
2 // Code generated by protoc-gen-validate. DO NOT EDIT.
3 // source: envoy/config/trace/v3/service.proto
4
5 package tracev3
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 TraceServiceConfig 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 *TraceServiceConfig) Validate() error {
43 return m.validate(false)
44 }
45
46 // ValidateAll checks the field values on TraceServiceConfig 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 // TraceServiceConfigMultiError, or nil if none found.
50 func (m *TraceServiceConfig) ValidateAll() error {
51 return m.validate(true)
52 }
53
54 func (m *TraceServiceConfig) validate(all bool) error {
55 if m == nil {
56 return nil
57 }
58
59 var errors []error
60
61 if m.GetGrpcService() == nil {
62 err := TraceServiceConfigValidationError{
63 field: "GrpcService",
64 reason: "value is required",
65 }
66 if !all {
67 return err
68 }
69 errors = append(errors, err)
70 }
71
72 if all {
73 switch v := interface{}(m.GetGrpcService()).(type) {
74 case interface{ ValidateAll() error }:
75 if err := v.ValidateAll(); err != nil {
76 errors = append(errors, TraceServiceConfigValidationError{
77 field: "GrpcService",
78 reason: "embedded message failed validation",
79 cause: err,
80 })
81 }
82 case interface{ Validate() error }:
83 if err := v.Validate(); err != nil {
84 errors = append(errors, TraceServiceConfigValidationError{
85 field: "GrpcService",
86 reason: "embedded message failed validation",
87 cause: err,
88 })
89 }
90 }
91 } else if v, ok := interface{}(m.GetGrpcService()).(interface{ Validate() error }); ok {
92 if err := v.Validate(); err != nil {
93 return TraceServiceConfigValidationError{
94 field: "GrpcService",
95 reason: "embedded message failed validation",
96 cause: err,
97 }
98 }
99 }
100
101 if len(errors) > 0 {
102 return TraceServiceConfigMultiError(errors)
103 }
104
105 return nil
106 }
107
108 // TraceServiceConfigMultiError is an error wrapping multiple validation errors
109 // returned by TraceServiceConfig.ValidateAll() if the designated constraints
110 // aren't met.
111 type TraceServiceConfigMultiError []error
112
113 // Error returns a concatenation of all the error messages it wraps.
114 func (m TraceServiceConfigMultiError) Error() string {
115 var msgs []string
116 for _, err := range m {
117 msgs = append(msgs, err.Error())
118 }
119 return strings.Join(msgs, "; ")
120 }
121
122 // AllErrors returns a list of validation violation errors.
123 func (m TraceServiceConfigMultiError) AllErrors() []error { return m }
124
125 // TraceServiceConfigValidationError is the validation error returned by
126 // TraceServiceConfig.Validate if the designated constraints aren't met.
127 type TraceServiceConfigValidationError struct {
128 field string
129 reason string
130 cause error
131 key bool
132 }
133
134 // Field function returns field value.
135 func (e TraceServiceConfigValidationError) Field() string { return e.field }
136
137 // Reason function returns reason value.
138 func (e TraceServiceConfigValidationError) Reason() string { return e.reason }
139
140 // Cause function returns cause value.
141 func (e TraceServiceConfigValidationError) Cause() error { return e.cause }
142
143 // Key function returns key value.
144 func (e TraceServiceConfigValidationError) Key() bool { return e.key }
145
146 // ErrorName returns error name.
147 func (e TraceServiceConfigValidationError) ErrorName() string {
148 return "TraceServiceConfigValidationError"
149 }
150
151 // Error satisfies the builtin error interface
152 func (e TraceServiceConfigValidationError) Error() string {
153 cause := ""
154 if e.cause != nil {
155 cause = fmt.Sprintf(" | caused by: %v", e.cause)
156 }
157
158 key := ""
159 if e.key {
160 key = "key for "
161 }
162
163 return fmt.Sprintf(
164 "invalid %sTraceServiceConfig.%s: %s%s",
165 key,
166 e.field,
167 e.reason,
168 cause)
169 }
170
171 var _ error = TraceServiceConfigValidationError{}
172
173 var _ interface {
174 Field() string
175 Reason() string
176 Key() bool
177 Cause() error
178 ErrorName() string
179 } = TraceServiceConfigValidationError{}