Debian Codegraph @

go/xds/core/v3/extension.pb.validate.go

raw symbols SCIP
1 // Code generated by protoc-gen-validate. DO NOT EDIT.
2 // source: xds/core/v3/extension.proto
3
4 package v3
5
6 import (
7 "bytes"
8 "errors"
9 "fmt"
10 "net"
11 "net/mail"
12 "net/url"
13 "regexp"
14 "sort"
15 "strings"
16 "time"
17 "unicode/utf8"
18
19 "google.golang.org/protobuf/types/known/anypb"
20 )
21
22 // ensure the imports are used
23 var (
24 _ = bytes.MinRead
25 _ = errors.New("")
26 _ = fmt.Print
27 _ = utf8.UTFMax
28 _ = (*regexp.Regexp)(nil)
29 _ = (*strings.Reader)(nil)
30 _ = net.IPv4len
31 _ = time.Duration(0)
32 _ = (*url.URL)(nil)
33 _ = (*mail.Address)(nil)
34 _ = anypb.Any{}
35 _ = sort.Sort
36 )
37
38 // Validate checks the field values on TypedExtensionConfig with the rules
39 // defined in the proto definition for this message. If any rules are
40 // violated, the first error encountered is returned, or nil if there are no violations.
41 func (m *TypedExtensionConfig) Validate() error {
42 return m.validate(false)
43 }
44
45 // ValidateAll checks the field values on TypedExtensionConfig with the rules
46 // defined in the proto definition for this message. If any rules are
47 // violated, the result is a list of violation errors wrapped in
48 // TypedExtensionConfigMultiError, or nil if none found.
49 func (m *TypedExtensionConfig) ValidateAll() error {
50 return m.validate(true)
51 }
52
53 func (m *TypedExtensionConfig) validate(all bool) error {
54 if m == nil {
55 return nil
56 }
57
58 var errors []error
59
60 if utf8.RuneCountInString(m.GetName()) < 1 {
61 err := TypedExtensionConfigValidationError{
62 field: "Name",
63 reason: "value length must be at least 1 runes",
64 }
65 if !all {
66 return err
67 }
68 errors = append(errors, err)
69 }
70
71 if m.GetTypedConfig() == nil {
72 err := TypedExtensionConfigValidationError{
73 field: "TypedConfig",
74 reason: "value is required",
75 }
76 if !all {
77 return err
78 }
79 errors = append(errors, err)
80 }
81
82 if a := m.GetTypedConfig(); a != nil {
83
84 }
85
86 if len(errors) > 0 {
87 return TypedExtensionConfigMultiError(errors)
88 }
89
90 return nil
91 }
92
93 // TypedExtensionConfigMultiError is an error wrapping multiple validation
94 // errors returned by TypedExtensionConfig.ValidateAll() if the designated
95 // constraints aren't met.
96 type TypedExtensionConfigMultiError []error
97
98 // Error returns a concatenation of all the error messages it wraps.
99 func (m TypedExtensionConfigMultiError) Error() string {
100 msgs := make([]string, 0, len(m))
101 for _, err := range m {
102 msgs = append(msgs, err.Error())
103 }
104 return strings.Join(msgs, "; ")
105 }
106
107 // AllErrors returns a list of validation violation errors.
108 func (m TypedExtensionConfigMultiError) AllErrors() []error { return m }
109
110 // TypedExtensionConfigValidationError is the validation error returned by
111 // TypedExtensionConfig.Validate if the designated constraints aren't met.
112 type TypedExtensionConfigValidationError struct {
113 field string
114 reason string
115 cause error
116 key bool
117 }
118
119 // Field function returns field value.
120 func (e TypedExtensionConfigValidationError) Field() string { return e.field }
121
122 // Reason function returns reason value.
123 func (e TypedExtensionConfigValidationError) Reason() string { return e.reason }
124
125 // Cause function returns cause value.
126 func (e TypedExtensionConfigValidationError) Cause() error { return e.cause }
127
128 // Key function returns key value.
129 func (e TypedExtensionConfigValidationError) Key() bool { return e.key }
130
131 // ErrorName returns error name.
132 func (e TypedExtensionConfigValidationError) ErrorName() string {
133 return "TypedExtensionConfigValidationError"
134 }
135
136 // Error satisfies the builtin error interface
137 func (e TypedExtensionConfigValidationError) Error() string {
138 cause := ""
139 if e.cause != nil {
140 cause = fmt.Sprintf(" | caused by: %v", e.cause)
141 }
142
143 key := ""
144 if e.key {
145 key = "key for "
146 }
147
148 return fmt.Sprintf(
149 "invalid %sTypedExtensionConfig.%s: %s%s",
150 key,
151 e.field,
152 e.reason,
153 cause)
154 }
155
156 var _ error = TypedExtensionConfigValidationError{}
157
158 var _ interface {
159 Field() string
160 Reason() string
161 Key() bool
162 Cause() error
163 ErrorName() string
164 } = TypedExtensionConfigValidationError{}