Debian Codegraph @

envoy/extensions/resource_monitors/downstream_connections/v3/downstream_connections.pb.validate.go

raw
1 //go:build !disable_pgv
2 // Code generated by protoc-gen-validate. DO NOT EDIT.
3 // source: envoy/extensions/resource_monitors/downstream_connections/v3/downstream_connections.proto
4
5 package downstream_connectionsv3
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 DownstreamConnectionsConfig with the
40 // rules 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 *DownstreamConnectionsConfig) Validate() error {
43 return m.validate(false)
44 }
45
46 // ValidateAll checks the field values on DownstreamConnectionsConfig with the
47 // rules 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 // DownstreamConnectionsConfigMultiError, or nil if none found.
50 func (m *DownstreamConnectionsConfig) ValidateAll() error {
51 return m.validate(true)
52 }
53
54 func (m *DownstreamConnectionsConfig) validate(all bool) error {
55 if m == nil {
56 return nil
57 }
58
59 var errors []error
60
61 if m.GetMaxActiveDownstreamConnections() <= 0 {
62 err := DownstreamConnectionsConfigValidationError{
63 field: "MaxActiveDownstreamConnections",
64 reason: "value must be greater than 0",
65 }
66 if !all {
67 return err
68 }
69 errors = append(errors, err)
70 }
71
72 if len(errors) > 0 {
73 return DownstreamConnectionsConfigMultiError(errors)
74 }
75
76 return nil
77 }
78
79 // DownstreamConnectionsConfigMultiError is an error wrapping multiple
80 // validation errors returned by DownstreamConnectionsConfig.ValidateAll() if
81 // the designated constraints aren't met.
82 type DownstreamConnectionsConfigMultiError []error
83
84 // Error returns a concatenation of all the error messages it wraps.
85 func (m DownstreamConnectionsConfigMultiError) Error() string {
86 var msgs []string
87 for _, err := range m {
88 msgs = append(msgs, err.Error())
89 }
90 return strings.Join(msgs, "; ")
91 }
92
93 // AllErrors returns a list of validation violation errors.
94 func (m DownstreamConnectionsConfigMultiError) AllErrors() []error { return m }
95
96 // DownstreamConnectionsConfigValidationError is the validation error returned
97 // by DownstreamConnectionsConfig.Validate if the designated constraints
98 // aren't met.
99 type DownstreamConnectionsConfigValidationError struct {
100 field string
101 reason string
102 cause error
103 key bool
104 }
105
106 // Field function returns field value.
107 func (e DownstreamConnectionsConfigValidationError) Field() string { return e.field }
108
109 // Reason function returns reason value.
110 func (e DownstreamConnectionsConfigValidationError) Reason() string { return e.reason }
111
112 // Cause function returns cause value.
113 func (e DownstreamConnectionsConfigValidationError) Cause() error { return e.cause }
114
115 // Key function returns key value.
116 func (e DownstreamConnectionsConfigValidationError) Key() bool { return e.key }
117
118 // ErrorName returns error name.
119 func (e DownstreamConnectionsConfigValidationError) ErrorName() string {
120 return "DownstreamConnectionsConfigValidationError"
121 }
122
123 // Error satisfies the builtin error interface
124 func (e DownstreamConnectionsConfigValidationError) Error() string {
125 cause := ""
126 if e.cause != nil {
127 cause = fmt.Sprintf(" | caused by: %v", e.cause)
128 }
129
130 key := ""
131 if e.key {
132 key = "key for "
133 }
134
135 return fmt.Sprintf(
136 "invalid %sDownstreamConnectionsConfig.%s: %s%s",
137 key,
138 e.field,
139 e.reason,
140 cause)
141 }
142
143 var _ error = DownstreamConnectionsConfigValidationError{}
144
145 var _ interface {
146 Field() string
147 Reason() string
148 Key() bool
149 Cause() error
150 ErrorName() string
151 } = DownstreamConnectionsConfigValidationError{}