Debian Codegraph @

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

raw symbols SCIP
1 // Code generated by protoc-gen-validate. DO NOT EDIT.
2 // source: xds/core/v3/resource_name.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 ResourceName with the rules defined in
39 // the proto definition for this message. If any rules are violated, the first
40 // error encountered is returned, or nil if there are no violations.
41 func (m *ResourceName) Validate() error {
42 return m.validate(false)
43 }
44
45 // ValidateAll checks the field values on ResourceName with the rules defined
46 // in the proto definition for this message. If any rules are violated, the
47 // result is a list of violation errors wrapped in ResourceNameMultiError, or
48 // nil if none found.
49 func (m *ResourceName) ValidateAll() error {
50 return m.validate(true)
51 }
52
53 func (m *ResourceName) validate(all bool) error {
54 if m == nil {
55 return nil
56 }
57
58 var errors []error
59
60 // no validation rules for Id
61
62 // no validation rules for Authority
63
64 if utf8.RuneCountInString(m.GetResourceType()) < 1 {
65 err := ResourceNameValidationError{
66 field: "ResourceType",
67 reason: "value length must be at least 1 runes",
68 }
69 if !all {
70 return err
71 }
72 errors = append(errors, err)
73 }
74
75 if all {
76 switch v := interface{}(m.GetContext()).(type) {
77 case interface{ ValidateAll() error }:
78 if err := v.ValidateAll(); err != nil {
79 errors = append(errors, ResourceNameValidationError{
80 field: "Context",
81 reason: "embedded message failed validation",
82 cause: err,
83 })
84 }
85 case interface{ Validate() error }:
86 if err := v.Validate(); err != nil {
87 errors = append(errors, ResourceNameValidationError{
88 field: "Context",
89 reason: "embedded message failed validation",
90 cause: err,
91 })
92 }
93 }
94 } else if v, ok := interface{}(m.GetContext()).(interface{ Validate() error }); ok {
95 if err := v.Validate(); err != nil {
96 return ResourceNameValidationError{
97 field: "Context",
98 reason: "embedded message failed validation",
99 cause: err,
100 }
101 }
102 }
103
104 if len(errors) > 0 {
105 return ResourceNameMultiError(errors)
106 }
107
108 return nil
109 }
110
111 // ResourceNameMultiError is an error wrapping multiple validation errors
112 // returned by ResourceName.ValidateAll() if the designated constraints aren't met.
113 type ResourceNameMultiError []error
114
115 // Error returns a concatenation of all the error messages it wraps.
116 func (m ResourceNameMultiError) Error() string {
117 msgs := make([]string, 0, len(m))
118 for _, err := range m {
119 msgs = append(msgs, err.Error())
120 }
121 return strings.Join(msgs, "; ")
122 }
123
124 // AllErrors returns a list of validation violation errors.
125 func (m ResourceNameMultiError) AllErrors() []error { return m }
126
127 // ResourceNameValidationError is the validation error returned by
128 // ResourceName.Validate if the designated constraints aren't met.
129 type ResourceNameValidationError struct {
130 field string
131 reason string
132 cause error
133 key bool
134 }
135
136 // Field function returns field value.
137 func (e ResourceNameValidationError) Field() string { return e.field }
138
139 // Reason function returns reason value.
140 func (e ResourceNameValidationError) Reason() string { return e.reason }
141
142 // Cause function returns cause value.
143 func (e ResourceNameValidationError) Cause() error { return e.cause }
144
145 // Key function returns key value.
146 func (e ResourceNameValidationError) Key() bool { return e.key }
147
148 // ErrorName returns error name.
149 func (e ResourceNameValidationError) ErrorName() string { return "ResourceNameValidationError" }
150
151 // Error satisfies the builtin error interface
152 func (e ResourceNameValidationError) 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 %sResourceName.%s: %s%s",
165 key,
166 e.field,
167 e.reason,
168 cause)
169 }
170
171 var _ error = ResourceNameValidationError{}
172
173 var _ interface {
174 Field() string
175 Reason() string
176 Key() bool
177 Cause() error
178 ErrorName() string
179 } = ResourceNameValidationError{}