Debian Codegraph @

envoy/config/grpc_credential/v2alpha/file_based_metadata.pb.validate.go

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