Debian Codegraph @

envoy/config/cluster/aggregate/v2alpha/cluster.pb.validate.go

raw
1 //go:build !disable_pgv
2 // Code generated by protoc-gen-validate. DO NOT EDIT.
3 // source: envoy/config/cluster/aggregate/v2alpha/cluster.proto
4
5 package v2alpha
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 ClusterConfig with the rules defined in
40 // the proto definition for this message. If any rules are violated, the first
41 // error encountered is returned, or nil if there are no violations.
42 func (m *ClusterConfig) Validate() error {
43 return m.validate(false)
44 }
45
46 // ValidateAll checks the field values on ClusterConfig with the rules defined
47 // in the proto definition for this message. If any rules are violated, the
48 // result is a list of violation errors wrapped in ClusterConfigMultiError, or
49 // nil if none found.
50 func (m *ClusterConfig) ValidateAll() error {
51 return m.validate(true)
52 }
53
54 func (m *ClusterConfig) validate(all bool) error {
55 if m == nil {
56 return nil
57 }
58
59 var errors []error
60
61 if len(m.GetClusters()) < 1 {
62 err := ClusterConfigValidationError{
63 field: "Clusters",
64 reason: "value must contain at least 1 item(s)",
65 }
66 if !all {
67 return err
68 }
69 errors = append(errors, err)
70 }
71
72 if len(errors) > 0 {
73 return ClusterConfigMultiError(errors)
74 }
75
76 return nil
77 }
78
79 // ClusterConfigMultiError is an error wrapping multiple validation errors
80 // returned by ClusterConfig.ValidateAll() if the designated constraints
81 // aren't met.
82 type ClusterConfigMultiError []error
83
84 // Error returns a concatenation of all the error messages it wraps.
85 func (m ClusterConfigMultiError) 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 ClusterConfigMultiError) AllErrors() []error { return m }
95
96 // ClusterConfigValidationError is the validation error returned by
97 // ClusterConfig.Validate if the designated constraints aren't met.
98 type ClusterConfigValidationError struct {
99 field string
100 reason string
101 cause error
102 key bool
103 }
104
105 // Field function returns field value.
106 func (e ClusterConfigValidationError) Field() string { return e.field }
107
108 // Reason function returns reason value.
109 func (e ClusterConfigValidationError) Reason() string { return e.reason }
110
111 // Cause function returns cause value.
112 func (e ClusterConfigValidationError) Cause() error { return e.cause }
113
114 // Key function returns key value.
115 func (e ClusterConfigValidationError) Key() bool { return e.key }
116
117 // ErrorName returns error name.
118 func (e ClusterConfigValidationError) ErrorName() string { return "ClusterConfigValidationError" }
119
120 // Error satisfies the builtin error interface
121 func (e ClusterConfigValidationError) Error() string {
122 cause := ""
123 if e.cause != nil {
124 cause = fmt.Sprintf(" | caused by: %v", e.cause)
125 }
126
127 key := ""
128 if e.key {
129 key = "key for "
130 }
131
132 return fmt.Sprintf(
133 "invalid %sClusterConfig.%s: %s%s",
134 key,
135 e.field,
136 e.reason,
137 cause)
138 }
139
140 var _ error = ClusterConfigValidationError{}
141
142 var _ interface {
143 Field() string
144 Reason() string
145 Key() bool
146 Cause() error
147 ErrorName() string
148 } = ClusterConfigValidationError{}