1
|
|
|
// Code generated by protoc-gen-validate. DO NOT EDIT. |
2
|
|
|
// source: base/v1/base.proto |
3
|
|
|
|
4
|
|
|
package basev1 |
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 Context with the rules defined in the |
39
|
|
|
// 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 *Context) Validate() error { |
42
|
|
|
return m.validate(false) |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
// ValidateAll checks the field values on Context with the rules defined in the |
46
|
|
|
// proto definition for this message. If any rules are violated, the result is |
47
|
|
|
// a list of violation errors wrapped in ContextMultiError, or nil if none found. |
48
|
|
|
func (m *Context) ValidateAll() error { |
49
|
|
|
return m.validate(true) |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
func (m *Context) validate(all bool) error { |
53
|
|
|
if m == nil { |
54
|
|
|
return nil |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
var errors []error |
58
|
|
|
|
59
|
|
|
for idx, item := range m.GetTuples() { |
60
|
|
|
_, _ = idx, item |
61
|
|
|
|
62
|
|
|
if all { |
63
|
|
|
switch v := interface{}(item).(type) { |
64
|
|
|
case interface{ ValidateAll() error }: |
65
|
|
|
if err := v.ValidateAll(); err != nil { |
66
|
|
|
errors = append(errors, ContextValidationError{ |
67
|
|
|
field: fmt.Sprintf("Tuples[%v]", idx), |
68
|
|
|
reason: "embedded message failed validation", |
69
|
|
|
cause: err, |
70
|
|
|
}) |
71
|
|
|
} |
72
|
|
|
case interface{ Validate() error }: |
73
|
|
|
if err := v.Validate(); err != nil { |
74
|
|
|
errors = append(errors, ContextValidationError{ |
75
|
|
|
field: fmt.Sprintf("Tuples[%v]", idx), |
76
|
|
|
reason: "embedded message failed validation", |
77
|
|
|
cause: err, |
78
|
|
|
}) |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
} else if v, ok := interface{}(item).(interface{ Validate() error }); ok { |
82
|
|
|
if err := v.Validate(); err != nil { |
83
|
|
|
return ContextValidationError{ |
84
|
|
|
field: fmt.Sprintf("Tuples[%v]", idx), |
85
|
|
|
reason: "embedded message failed validation", |
86
|
|
|
cause: err, |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
for idx, item := range m.GetAttributes() { |
94
|
|
|
_, _ = idx, item |
95
|
|
|
|
96
|
|
|
if all { |
97
|
|
|
switch v := interface{}(item).(type) { |
98
|
|
|
case interface{ ValidateAll() error }: |
99
|
|
|
if err := v.ValidateAll(); err != nil { |
100
|
|
|
errors = append(errors, ContextValidationError{ |
101
|
|
|
field: fmt.Sprintf("Attributes[%v]", idx), |
102
|
|
|
reason: "embedded message failed validation", |
103
|
|
|
cause: err, |
104
|
|
|
}) |
105
|
|
|
} |
106
|
|
|
case interface{ Validate() error }: |
107
|
|
|
if err := v.Validate(); err != nil { |
108
|
|
|
errors = append(errors, ContextValidationError{ |
109
|
|
|
field: fmt.Sprintf("Attributes[%v]", idx), |
110
|
|
|
reason: "embedded message failed validation", |
111
|
|
|
cause: err, |
112
|
|
|
}) |
113
|
|
|
} |
114
|
|
|
} |
115
|
|
|
} else if v, ok := interface{}(item).(interface{ Validate() error }); ok { |
116
|
|
|
if err := v.Validate(); err != nil { |
117
|
|
|
return ContextValidationError{ |
118
|
|
|
field: fmt.Sprintf("Attributes[%v]", idx), |
119
|
|
|
reason: "embedded message failed validation", |
120
|
|
|
cause: err, |
121
|
|
|
} |
122
|
|
|
} |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
if all { |
128
|
|
|
switch v := interface{}(m.GetData()).(type) { |
129
|
|
|
case interface{ ValidateAll() error }: |
130
|
|
|
if err := v.ValidateAll(); err != nil { |
131
|
|
|
errors = append(errors, ContextValidationError{ |
132
|
|
|
field: "Data", |
133
|
|
|
reason: "embedded message failed validation", |
134
|
|
|
cause: err, |
135
|
|
|
}) |
136
|
|
|
} |
137
|
|
|
case interface{ Validate() error }: |
138
|
|
|
if err := v.Validate(); err != nil { |
139
|
|
|
errors = append(errors, ContextValidationError{ |
140
|
|
|
field: "Data", |
141
|
|
|
reason: "embedded message failed validation", |
142
|
|
|
cause: err, |
143
|
|
|
}) |
144
|
|
|
} |
145
|
|
|
} |
146
|
|
|
} else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { |
147
|
|
|
if err := v.Validate(); err != nil { |
148
|
|
|
return ContextValidationError{ |
149
|
|
|
field: "Data", |
150
|
|
|
reason: "embedded message failed validation", |
151
|
|
|
cause: err, |
152
|
|
|
} |
153
|
|
|
} |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
if len(errors) > 0 { |
157
|
|
|
return ContextMultiError(errors) |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
return nil |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
// ContextMultiError is an error wrapping multiple validation errors returned |
164
|
|
|
// by Context.ValidateAll() if the designated constraints aren't met. |
165
|
|
|
type ContextMultiError []error |
166
|
|
|
|
167
|
|
|
// Error returns a concatenation of all the error messages it wraps. |
168
|
|
|
func (m ContextMultiError) Error() string { |
169
|
|
|
var msgs []string |
170
|
|
|
for _, err := range m { |
171
|
|
|
msgs = append(msgs, err.Error()) |
172
|
|
|
} |
173
|
|
|
return strings.Join(msgs, "; ") |
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
// AllErrors returns a list of validation violation errors. |
177
|
|
|
func (m ContextMultiError) AllErrors() []error { return m } |
178
|
|
|
|
179
|
|
|
// ContextValidationError is the validation error returned by Context.Validate |
180
|
|
|
// if the designated constraints aren't met. |
181
|
|
|
type ContextValidationError struct { |
182
|
|
|
field string |
183
|
|
|
reason string |
184
|
|
|
cause error |
185
|
|
|
key bool |
186
|
|
|
} |
187
|
|
|
|
188
|
|
|
// Field function returns field value. |
189
|
|
|
func (e ContextValidationError) Field() string { return e.field } |
190
|
|
|
|
191
|
|
|
// Reason function returns reason value. |
192
|
|
|
func (e ContextValidationError) Reason() string { return e.reason } |
193
|
|
|
|
194
|
|
|
// Cause function returns cause value. |
195
|
|
|
func (e ContextValidationError) Cause() error { return e.cause } |
196
|
|
|
|
197
|
|
|
// Key function returns key value. |
198
|
|
|
func (e ContextValidationError) Key() bool { return e.key } |
199
|
|
|
|
200
|
|
|
// ErrorName returns error name. |
201
|
|
|
func (e ContextValidationError) ErrorName() string { return "ContextValidationError" } |
202
|
|
|
|
203
|
|
|
// Error satisfies the builtin error interface |
204
|
|
|
func (e ContextValidationError) Error() string { |
205
|
|
|
cause := "" |
206
|
|
|
if e.cause != nil { |
207
|
|
|
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
208
|
|
|
} |
209
|
|
|
|
210
|
|
|
key := "" |
211
|
|
|
if e.key { |
212
|
|
|
key = "key for " |
213
|
|
|
} |
214
|
|
|
|
215
|
|
|
return fmt.Sprintf( |
216
|
|
|
"invalid %sContext.%s: %s%s", |
217
|
|
|
key, |
218
|
|
|
e.field, |
219
|
|
|
e.reason, |
220
|
|
|
cause) |
221
|
|
|
} |
222
|
|
|
|
223
|
|
|
var _ error = ContextValidationError{} |
224
|
|
|
|
225
|
|
|
var _ interface { |
226
|
|
|
Field() string |
227
|
|
|
Reason() string |
228
|
|
|
Key() bool |
229
|
|
|
Cause() error |
230
|
|
|
ErrorName() string |
231
|
|
|
} = ContextValidationError{} |
232
|
|
|
|
233
|
|
|
// Validate checks the field values on Child with the rules defined in the |
234
|
|
|
// proto definition for this message. If any rules are violated, the first |
235
|
|
|
// error encountered is returned, or nil if there are no violations. |
236
|
|
|
func (m *Child) Validate() error { |
237
|
|
|
return m.validate(false) |
238
|
|
|
} |
239
|
|
|
|
240
|
|
|
// ValidateAll checks the field values on Child with the rules defined in the |
241
|
|
|
// proto definition for this message. If any rules are violated, the result is |
242
|
|
|
// a list of violation errors wrapped in ChildMultiError, or nil if none found. |
243
|
|
|
func (m *Child) ValidateAll() error { |
244
|
|
|
return m.validate(true) |
245
|
|
|
} |
246
|
|
|
|
247
|
|
|
func (m *Child) validate(all bool) error { |
248
|
|
|
if m == nil { |
249
|
|
|
return nil |
250
|
|
|
} |
251
|
|
|
|
252
|
|
|
var errors []error |
253
|
|
|
|
254
|
|
|
oneofTypePresent := false |
255
|
|
|
switch v := m.Type.(type) { |
256
|
|
|
case *Child_Leaf: |
257
|
|
|
if v == nil { |
258
|
|
|
err := ChildValidationError{ |
259
|
|
|
field: "Type", |
260
|
|
|
reason: "oneof value cannot be a typed-nil", |
261
|
|
|
} |
262
|
|
|
if !all { |
263
|
|
|
return err |
264
|
|
|
} |
265
|
|
|
errors = append(errors, err) |
266
|
|
|
} |
267
|
|
|
oneofTypePresent = true |
268
|
|
|
|
269
|
|
|
if m.GetLeaf() == nil { |
270
|
|
|
err := ChildValidationError{ |
271
|
|
|
field: "Leaf", |
272
|
|
|
reason: "value is required", |
273
|
|
|
} |
274
|
|
|
if !all { |
275
|
|
|
return err |
276
|
|
|
} |
277
|
|
|
errors = append(errors, err) |
278
|
|
|
} |
279
|
|
|
|
280
|
|
|
if all { |
281
|
|
|
switch v := interface{}(m.GetLeaf()).(type) { |
282
|
|
|
case interface{ ValidateAll() error }: |
283
|
|
|
if err := v.ValidateAll(); err != nil { |
284
|
|
|
errors = append(errors, ChildValidationError{ |
285
|
|
|
field: "Leaf", |
286
|
|
|
reason: "embedded message failed validation", |
287
|
|
|
cause: err, |
288
|
|
|
}) |
289
|
|
|
} |
290
|
|
|
case interface{ Validate() error }: |
291
|
|
|
if err := v.Validate(); err != nil { |
292
|
|
|
errors = append(errors, ChildValidationError{ |
293
|
|
|
field: "Leaf", |
294
|
|
|
reason: "embedded message failed validation", |
295
|
|
|
cause: err, |
296
|
|
|
}) |
297
|
|
|
} |
298
|
|
|
} |
299
|
|
|
} else if v, ok := interface{}(m.GetLeaf()).(interface{ Validate() error }); ok { |
300
|
|
|
if err := v.Validate(); err != nil { |
301
|
|
|
return ChildValidationError{ |
302
|
|
|
field: "Leaf", |
303
|
|
|
reason: "embedded message failed validation", |
304
|
|
|
cause: err, |
305
|
|
|
} |
306
|
|
|
} |
307
|
|
|
} |
308
|
|
|
|
309
|
|
|
case *Child_Rewrite: |
310
|
|
|
if v == nil { |
311
|
|
|
err := ChildValidationError{ |
312
|
|
|
field: "Type", |
313
|
|
|
reason: "oneof value cannot be a typed-nil", |
314
|
|
|
} |
315
|
|
|
if !all { |
316
|
|
|
return err |
317
|
|
|
} |
318
|
|
|
errors = append(errors, err) |
319
|
|
|
} |
320
|
|
|
oneofTypePresent = true |
321
|
|
|
|
322
|
|
|
if m.GetRewrite() == nil { |
323
|
|
|
err := ChildValidationError{ |
324
|
|
|
field: "Rewrite", |
325
|
|
|
reason: "value is required", |
326
|
|
|
} |
327
|
|
|
if !all { |
328
|
|
|
return err |
329
|
|
|
} |
330
|
|
|
errors = append(errors, err) |
331
|
|
|
} |
332
|
|
|
|
333
|
|
|
if all { |
334
|
|
|
switch v := interface{}(m.GetRewrite()).(type) { |
335
|
|
|
case interface{ ValidateAll() error }: |
336
|
|
|
if err := v.ValidateAll(); err != nil { |
337
|
|
|
errors = append(errors, ChildValidationError{ |
338
|
|
|
field: "Rewrite", |
339
|
|
|
reason: "embedded message failed validation", |
340
|
|
|
cause: err, |
341
|
|
|
}) |
342
|
|
|
} |
343
|
|
|
case interface{ Validate() error }: |
344
|
|
|
if err := v.Validate(); err != nil { |
345
|
|
|
errors = append(errors, ChildValidationError{ |
346
|
|
|
field: "Rewrite", |
347
|
|
|
reason: "embedded message failed validation", |
348
|
|
|
cause: err, |
349
|
|
|
}) |
350
|
|
|
} |
351
|
|
|
} |
352
|
|
|
} else if v, ok := interface{}(m.GetRewrite()).(interface{ Validate() error }); ok { |
353
|
|
|
if err := v.Validate(); err != nil { |
354
|
|
|
return ChildValidationError{ |
355
|
|
|
field: "Rewrite", |
356
|
|
|
reason: "embedded message failed validation", |
357
|
|
|
cause: err, |
358
|
|
|
} |
359
|
|
|
} |
360
|
|
|
} |
361
|
|
|
|
362
|
|
|
default: |
363
|
|
|
_ = v // ensures v is used |
364
|
|
|
} |
365
|
|
|
if !oneofTypePresent { |
366
|
|
|
err := ChildValidationError{ |
367
|
|
|
field: "Type", |
368
|
|
|
reason: "value is required", |
369
|
|
|
} |
370
|
|
|
if !all { |
371
|
|
|
return err |
372
|
|
|
} |
373
|
|
|
errors = append(errors, err) |
374
|
|
|
} |
375
|
|
|
|
376
|
|
|
if len(errors) > 0 { |
377
|
|
|
return ChildMultiError(errors) |
378
|
|
|
} |
379
|
|
|
|
380
|
|
|
return nil |
381
|
|
|
} |
382
|
|
|
|
383
|
|
|
// ChildMultiError is an error wrapping multiple validation errors returned by |
384
|
|
|
// Child.ValidateAll() if the designated constraints aren't met. |
385
|
|
|
type ChildMultiError []error |
386
|
|
|
|
387
|
|
|
// Error returns a concatenation of all the error messages it wraps. |
388
|
|
|
func (m ChildMultiError) Error() string { |
389
|
|
|
var msgs []string |
390
|
|
|
for _, err := range m { |
391
|
|
|
msgs = append(msgs, err.Error()) |
392
|
|
|
} |
393
|
|
|
return strings.Join(msgs, "; ") |
394
|
|
|
} |
395
|
|
|
|
396
|
|
|
// AllErrors returns a list of validation violation errors. |
397
|
|
|
func (m ChildMultiError) AllErrors() []error { return m } |
398
|
|
|
|
399
|
|
|
// ChildValidationError is the validation error returned by Child.Validate if |
400
|
|
|
// the designated constraints aren't met. |
401
|
|
|
type ChildValidationError struct { |
402
|
|
|
field string |
403
|
|
|
reason string |
404
|
|
|
cause error |
405
|
|
|
key bool |
406
|
|
|
} |
407
|
|
|
|
408
|
|
|
// Field function returns field value. |
409
|
|
|
func (e ChildValidationError) Field() string { return e.field } |
410
|
|
|
|
411
|
|
|
// Reason function returns reason value. |
412
|
|
|
func (e ChildValidationError) Reason() string { return e.reason } |
413
|
|
|
|
414
|
|
|
// Cause function returns cause value. |
415
|
|
|
func (e ChildValidationError) Cause() error { return e.cause } |
416
|
|
|
|
417
|
|
|
// Key function returns key value. |
418
|
|
|
func (e ChildValidationError) Key() bool { return e.key } |
419
|
|
|
|
420
|
|
|
// ErrorName returns error name. |
421
|
|
|
func (e ChildValidationError) ErrorName() string { return "ChildValidationError" } |
422
|
|
|
|
423
|
|
|
// Error satisfies the builtin error interface |
424
|
|
|
func (e ChildValidationError) Error() string { |
425
|
|
|
cause := "" |
426
|
|
|
if e.cause != nil { |
427
|
|
|
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
428
|
|
|
} |
429
|
|
|
|
430
|
|
|
key := "" |
431
|
|
|
if e.key { |
432
|
|
|
key = "key for " |
433
|
|
|
} |
434
|
|
|
|
435
|
|
|
return fmt.Sprintf( |
436
|
|
|
"invalid %sChild.%s: %s%s", |
437
|
|
|
key, |
438
|
|
|
e.field, |
439
|
|
|
e.reason, |
440
|
|
|
cause) |
441
|
|
|
} |
442
|
|
|
|
443
|
|
|
var _ error = ChildValidationError{} |
444
|
|
|
|
445
|
|
|
var _ interface { |
446
|
|
|
Field() string |
447
|
|
|
Reason() string |
448
|
|
|
Key() bool |
449
|
|
|
Cause() error |
450
|
|
|
ErrorName() string |
451
|
|
|
} = ChildValidationError{} |
452
|
|
|
|
453
|
|
|
// Validate checks the field values on Leaf with the rules defined in the proto |
454
|
|
|
// definition for this message. If any rules are violated, the first error |
455
|
|
|
// encountered is returned, or nil if there are no violations. |
456
|
|
|
func (m *Leaf) Validate() error { |
457
|
|
|
return m.validate(false) |
458
|
|
|
} |
459
|
|
|
|
460
|
|
|
// ValidateAll checks the field values on Leaf with the rules defined in the |
461
|
|
|
// proto definition for this message. If any rules are violated, the result is |
462
|
|
|
// a list of violation errors wrapped in LeafMultiError, or nil if none found. |
463
|
|
|
func (m *Leaf) ValidateAll() error { |
464
|
|
|
return m.validate(true) |
465
|
|
|
} |
466
|
|
|
|
467
|
|
|
func (m *Leaf) validate(all bool) error { |
468
|
|
|
if m == nil { |
469
|
|
|
return nil |
470
|
|
|
} |
471
|
|
|
|
472
|
|
|
var errors []error |
473
|
|
|
|
474
|
|
|
oneofTypePresent := false |
475
|
|
|
switch v := m.Type.(type) { |
476
|
|
|
case *Leaf_ComputedUserSet: |
477
|
|
|
if v == nil { |
478
|
|
|
err := LeafValidationError{ |
479
|
|
|
field: "Type", |
480
|
|
|
reason: "oneof value cannot be a typed-nil", |
481
|
|
|
} |
482
|
|
|
if !all { |
483
|
|
|
return err |
484
|
|
|
} |
485
|
|
|
errors = append(errors, err) |
486
|
|
|
} |
487
|
|
|
oneofTypePresent = true |
488
|
|
|
|
489
|
|
|
if m.GetComputedUserSet() == nil { |
490
|
|
|
err := LeafValidationError{ |
491
|
|
|
field: "ComputedUserSet", |
492
|
|
|
reason: "value is required", |
493
|
|
|
} |
494
|
|
|
if !all { |
495
|
|
|
return err |
496
|
|
|
} |
497
|
|
|
errors = append(errors, err) |
498
|
|
|
} |
499
|
|
|
|
500
|
|
|
if all { |
501
|
|
|
switch v := interface{}(m.GetComputedUserSet()).(type) { |
502
|
|
|
case interface{ ValidateAll() error }: |
503
|
|
|
if err := v.ValidateAll(); err != nil { |
504
|
|
|
errors = append(errors, LeafValidationError{ |
505
|
|
|
field: "ComputedUserSet", |
506
|
|
|
reason: "embedded message failed validation", |
507
|
|
|
cause: err, |
508
|
|
|
}) |
509
|
|
|
} |
510
|
|
|
case interface{ Validate() error }: |
511
|
|
|
if err := v.Validate(); err != nil { |
512
|
|
|
errors = append(errors, LeafValidationError{ |
513
|
|
|
field: "ComputedUserSet", |
514
|
|
|
reason: "embedded message failed validation", |
515
|
|
|
cause: err, |
516
|
|
|
}) |
517
|
|
|
} |
518
|
|
|
} |
519
|
|
|
} else if v, ok := interface{}(m.GetComputedUserSet()).(interface{ Validate() error }); ok { |
520
|
|
|
if err := v.Validate(); err != nil { |
521
|
|
|
return LeafValidationError{ |
522
|
|
|
field: "ComputedUserSet", |
523
|
|
|
reason: "embedded message failed validation", |
524
|
|
|
cause: err, |
525
|
|
|
} |
526
|
|
|
} |
527
|
|
|
} |
528
|
|
|
|
529
|
|
|
case *Leaf_TupleToUserSet: |
530
|
|
|
if v == nil { |
531
|
|
|
err := LeafValidationError{ |
532
|
|
|
field: "Type", |
533
|
|
|
reason: "oneof value cannot be a typed-nil", |
534
|
|
|
} |
535
|
|
|
if !all { |
536
|
|
|
return err |
537
|
|
|
} |
538
|
|
|
errors = append(errors, err) |
539
|
|
|
} |
540
|
|
|
oneofTypePresent = true |
541
|
|
|
|
542
|
|
|
if m.GetTupleToUserSet() == nil { |
543
|
|
|
err := LeafValidationError{ |
544
|
|
|
field: "TupleToUserSet", |
545
|
|
|
reason: "value is required", |
546
|
|
|
} |
547
|
|
|
if !all { |
548
|
|
|
return err |
549
|
|
|
} |
550
|
|
|
errors = append(errors, err) |
551
|
|
|
} |
552
|
|
|
|
553
|
|
|
if all { |
554
|
|
|
switch v := interface{}(m.GetTupleToUserSet()).(type) { |
555
|
|
|
case interface{ ValidateAll() error }: |
556
|
|
|
if err := v.ValidateAll(); err != nil { |
557
|
|
|
errors = append(errors, LeafValidationError{ |
558
|
|
|
field: "TupleToUserSet", |
559
|
|
|
reason: "embedded message failed validation", |
560
|
|
|
cause: err, |
561
|
|
|
}) |
562
|
|
|
} |
563
|
|
|
case interface{ Validate() error }: |
564
|
|
|
if err := v.Validate(); err != nil { |
565
|
|
|
errors = append(errors, LeafValidationError{ |
566
|
|
|
field: "TupleToUserSet", |
567
|
|
|
reason: "embedded message failed validation", |
568
|
|
|
cause: err, |
569
|
|
|
}) |
570
|
|
|
} |
571
|
|
|
} |
572
|
|
|
} else if v, ok := interface{}(m.GetTupleToUserSet()).(interface{ Validate() error }); ok { |
573
|
|
|
if err := v.Validate(); err != nil { |
574
|
|
|
return LeafValidationError{ |
575
|
|
|
field: "TupleToUserSet", |
576
|
|
|
reason: "embedded message failed validation", |
577
|
|
|
cause: err, |
578
|
|
|
} |
579
|
|
|
} |
580
|
|
|
} |
581
|
|
|
|
582
|
|
|
case *Leaf_ComputedAttribute: |
583
|
|
|
if v == nil { |
584
|
|
|
err := LeafValidationError{ |
585
|
|
|
field: "Type", |
586
|
|
|
reason: "oneof value cannot be a typed-nil", |
587
|
|
|
} |
588
|
|
|
if !all { |
589
|
|
|
return err |
590
|
|
|
} |
591
|
|
|
errors = append(errors, err) |
592
|
|
|
} |
593
|
|
|
oneofTypePresent = true |
594
|
|
|
|
595
|
|
|
if m.GetComputedAttribute() == nil { |
596
|
|
|
err := LeafValidationError{ |
597
|
|
|
field: "ComputedAttribute", |
598
|
|
|
reason: "value is required", |
599
|
|
|
} |
600
|
|
|
if !all { |
601
|
|
|
return err |
602
|
|
|
} |
603
|
|
|
errors = append(errors, err) |
604
|
|
|
} |
605
|
|
|
|
606
|
|
|
if all { |
607
|
|
|
switch v := interface{}(m.GetComputedAttribute()).(type) { |
608
|
|
|
case interface{ ValidateAll() error }: |
609
|
|
|
if err := v.ValidateAll(); err != nil { |
610
|
|
|
errors = append(errors, LeafValidationError{ |
611
|
|
|
field: "ComputedAttribute", |
612
|
|
|
reason: "embedded message failed validation", |
613
|
|
|
cause: err, |
614
|
|
|
}) |
615
|
|
|
} |
616
|
|
|
case interface{ Validate() error }: |
617
|
|
|
if err := v.Validate(); err != nil { |
618
|
|
|
errors = append(errors, LeafValidationError{ |
619
|
|
|
field: "ComputedAttribute", |
620
|
|
|
reason: "embedded message failed validation", |
621
|
|
|
cause: err, |
622
|
|
|
}) |
623
|
|
|
} |
624
|
|
|
} |
625
|
|
|
} else if v, ok := interface{}(m.GetComputedAttribute()).(interface{ Validate() error }); ok { |
626
|
|
|
if err := v.Validate(); err != nil { |
627
|
|
|
return LeafValidationError{ |
628
|
|
|
field: "ComputedAttribute", |
629
|
|
|
reason: "embedded message failed validation", |
630
|
|
|
cause: err, |
631
|
|
|
} |
632
|
|
|
} |
633
|
|
|
} |
634
|
|
|
|
635
|
|
|
case *Leaf_Call: |
636
|
|
|
if v == nil { |
637
|
|
|
err := LeafValidationError{ |
638
|
|
|
field: "Type", |
639
|
|
|
reason: "oneof value cannot be a typed-nil", |
640
|
|
|
} |
641
|
|
|
if !all { |
642
|
|
|
return err |
643
|
|
|
} |
644
|
|
|
errors = append(errors, err) |
645
|
|
|
} |
646
|
|
|
oneofTypePresent = true |
647
|
|
|
|
648
|
|
|
if m.GetCall() == nil { |
649
|
|
|
err := LeafValidationError{ |
650
|
|
|
field: "Call", |
651
|
|
|
reason: "value is required", |
652
|
|
|
} |
653
|
|
|
if !all { |
654
|
|
|
return err |
655
|
|
|
} |
656
|
|
|
errors = append(errors, err) |
657
|
|
|
} |
658
|
|
|
|
659
|
|
|
if all { |
660
|
|
|
switch v := interface{}(m.GetCall()).(type) { |
661
|
|
|
case interface{ ValidateAll() error }: |
662
|
|
|
if err := v.ValidateAll(); err != nil { |
663
|
|
|
errors = append(errors, LeafValidationError{ |
664
|
|
|
field: "Call", |
665
|
|
|
reason: "embedded message failed validation", |
666
|
|
|
cause: err, |
667
|
|
|
}) |
668
|
|
|
} |
669
|
|
|
case interface{ Validate() error }: |
670
|
|
|
if err := v.Validate(); err != nil { |
671
|
|
|
errors = append(errors, LeafValidationError{ |
672
|
|
|
field: "Call", |
673
|
|
|
reason: "embedded message failed validation", |
674
|
|
|
cause: err, |
675
|
|
|
}) |
676
|
|
|
} |
677
|
|
|
} |
678
|
|
|
} else if v, ok := interface{}(m.GetCall()).(interface{ Validate() error }); ok { |
679
|
|
|
if err := v.Validate(); err != nil { |
680
|
|
|
return LeafValidationError{ |
681
|
|
|
field: "Call", |
682
|
|
|
reason: "embedded message failed validation", |
683
|
|
|
cause: err, |
684
|
|
|
} |
685
|
|
|
} |
686
|
|
|
} |
687
|
|
|
|
688
|
|
|
default: |
689
|
|
|
_ = v // ensures v is used |
690
|
|
|
} |
691
|
|
|
if !oneofTypePresent { |
692
|
|
|
err := LeafValidationError{ |
693
|
|
|
field: "Type", |
694
|
|
|
reason: "value is required", |
695
|
|
|
} |
696
|
|
|
if !all { |
697
|
|
|
return err |
698
|
|
|
} |
699
|
|
|
errors = append(errors, err) |
700
|
|
|
} |
701
|
|
|
|
702
|
|
|
if len(errors) > 0 { |
703
|
|
|
return LeafMultiError(errors) |
704
|
|
|
} |
705
|
|
|
|
706
|
|
|
return nil |
707
|
|
|
} |
708
|
|
|
|
709
|
|
|
// LeafMultiError is an error wrapping multiple validation errors returned by |
710
|
|
|
// Leaf.ValidateAll() if the designated constraints aren't met. |
711
|
|
|
type LeafMultiError []error |
712
|
|
|
|
713
|
|
|
// Error returns a concatenation of all the error messages it wraps. |
714
|
|
|
func (m LeafMultiError) Error() string { |
715
|
|
|
var msgs []string |
716
|
|
|
for _, err := range m { |
717
|
|
|
msgs = append(msgs, err.Error()) |
718
|
|
|
} |
719
|
|
|
return strings.Join(msgs, "; ") |
720
|
|
|
} |
721
|
|
|
|
722
|
|
|
// AllErrors returns a list of validation violation errors. |
723
|
|
|
func (m LeafMultiError) AllErrors() []error { return m } |
724
|
|
|
|
725
|
|
|
// LeafValidationError is the validation error returned by Leaf.Validate if the |
726
|
|
|
// designated constraints aren't met. |
727
|
|
|
type LeafValidationError struct { |
728
|
|
|
field string |
729
|
|
|
reason string |
730
|
|
|
cause error |
731
|
|
|
key bool |
732
|
|
|
} |
733
|
|
|
|
734
|
|
|
// Field function returns field value. |
735
|
|
|
func (e LeafValidationError) Field() string { return e.field } |
736
|
|
|
|
737
|
|
|
// Reason function returns reason value. |
738
|
|
|
func (e LeafValidationError) Reason() string { return e.reason } |
739
|
|
|
|
740
|
|
|
// Cause function returns cause value. |
741
|
|
|
func (e LeafValidationError) Cause() error { return e.cause } |
742
|
|
|
|
743
|
|
|
// Key function returns key value. |
744
|
|
|
func (e LeafValidationError) Key() bool { return e.key } |
745
|
|
|
|
746
|
|
|
// ErrorName returns error name. |
747
|
|
|
func (e LeafValidationError) ErrorName() string { return "LeafValidationError" } |
748
|
|
|
|
749
|
|
|
// Error satisfies the builtin error interface |
750
|
|
|
func (e LeafValidationError) Error() string { |
751
|
|
|
cause := "" |
752
|
|
|
if e.cause != nil { |
753
|
|
|
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
754
|
|
|
} |
755
|
|
|
|
756
|
|
|
key := "" |
757
|
|
|
if e.key { |
758
|
|
|
key = "key for " |
759
|
|
|
} |
760
|
|
|
|
761
|
|
|
return fmt.Sprintf( |
762
|
|
|
"invalid %sLeaf.%s: %s%s", |
763
|
|
|
key, |
764
|
|
|
e.field, |
765
|
|
|
e.reason, |
766
|
|
|
cause) |
767
|
|
|
} |
768
|
|
|
|
769
|
|
|
var _ error = LeafValidationError{} |
770
|
|
|
|
771
|
|
|
var _ interface { |
772
|
|
|
Field() string |
773
|
|
|
Reason() string |
774
|
|
|
Key() bool |
775
|
|
|
Cause() error |
776
|
|
|
ErrorName() string |
777
|
|
|
} = LeafValidationError{} |
778
|
|
|
|
779
|
|
|
// Validate checks the field values on Rewrite with the rules defined in the |
780
|
|
|
// proto definition for this message. If any rules are violated, the first |
781
|
|
|
// error encountered is returned, or nil if there are no violations. |
782
|
|
|
func (m *Rewrite) Validate() error { |
783
|
|
|
return m.validate(false) |
784
|
|
|
} |
785
|
|
|
|
786
|
|
|
// ValidateAll checks the field values on Rewrite with the rules defined in the |
787
|
|
|
// proto definition for this message. If any rules are violated, the result is |
788
|
|
|
// a list of violation errors wrapped in RewriteMultiError, or nil if none found. |
789
|
|
|
func (m *Rewrite) ValidateAll() error { |
790
|
|
|
return m.validate(true) |
791
|
|
|
} |
792
|
|
|
|
793
|
|
|
func (m *Rewrite) validate(all bool) error { |
794
|
|
|
if m == nil { |
795
|
|
|
return nil |
796
|
|
|
} |
797
|
|
|
|
798
|
|
|
var errors []error |
799
|
|
|
|
800
|
|
|
// no validation rules for RewriteOperation |
801
|
|
|
|
802
|
|
|
for idx, item := range m.GetChildren() { |
803
|
|
|
_, _ = idx, item |
804
|
|
|
|
805
|
|
|
if all { |
806
|
|
|
switch v := interface{}(item).(type) { |
807
|
|
|
case interface{ ValidateAll() error }: |
808
|
|
|
if err := v.ValidateAll(); err != nil { |
809
|
|
|
errors = append(errors, RewriteValidationError{ |
810
|
|
|
field: fmt.Sprintf("Children[%v]", idx), |
811
|
|
|
reason: "embedded message failed validation", |
812
|
|
|
cause: err, |
813
|
|
|
}) |
814
|
|
|
} |
815
|
|
|
case interface{ Validate() error }: |
816
|
|
|
if err := v.Validate(); err != nil { |
817
|
|
|
errors = append(errors, RewriteValidationError{ |
818
|
|
|
field: fmt.Sprintf("Children[%v]", idx), |
819
|
|
|
reason: "embedded message failed validation", |
820
|
|
|
cause: err, |
821
|
|
|
}) |
822
|
|
|
} |
823
|
|
|
} |
824
|
|
|
} else if v, ok := interface{}(item).(interface{ Validate() error }); ok { |
825
|
|
|
if err := v.Validate(); err != nil { |
826
|
|
|
return RewriteValidationError{ |
827
|
|
|
field: fmt.Sprintf("Children[%v]", idx), |
828
|
|
|
reason: "embedded message failed validation", |
829
|
|
|
cause: err, |
830
|
|
|
} |
831
|
|
|
} |
832
|
|
|
} |
833
|
|
|
|
834
|
|
|
} |
835
|
|
|
|
836
|
|
|
if len(errors) > 0 { |
837
|
|
|
return RewriteMultiError(errors) |
838
|
|
|
} |
839
|
|
|
|
840
|
|
|
return nil |
841
|
|
|
} |
842
|
|
|
|
843
|
|
|
// RewriteMultiError is an error wrapping multiple validation errors returned |
844
|
|
|
// by Rewrite.ValidateAll() if the designated constraints aren't met. |
845
|
|
|
type RewriteMultiError []error |
846
|
|
|
|
847
|
|
|
// Error returns a concatenation of all the error messages it wraps. |
848
|
|
|
func (m RewriteMultiError) Error() string { |
849
|
|
|
var msgs []string |
850
|
|
|
for _, err := range m { |
851
|
|
|
msgs = append(msgs, err.Error()) |
852
|
|
|
} |
853
|
|
|
return strings.Join(msgs, "; ") |
854
|
|
|
} |
855
|
|
|
|
856
|
|
|
// AllErrors returns a list of validation violation errors. |
857
|
|
|
func (m RewriteMultiError) AllErrors() []error { return m } |
858
|
|
|
|
859
|
|
|
// RewriteValidationError is the validation error returned by Rewrite.Validate |
860
|
|
|
// if the designated constraints aren't met. |
861
|
|
|
type RewriteValidationError struct { |
862
|
|
|
field string |
863
|
|
|
reason string |
864
|
|
|
cause error |
865
|
|
|
key bool |
866
|
|
|
} |
867
|
|
|
|
868
|
|
|
// Field function returns field value. |
869
|
|
|
func (e RewriteValidationError) Field() string { return e.field } |
870
|
|
|
|
871
|
|
|
// Reason function returns reason value. |
872
|
|
|
func (e RewriteValidationError) Reason() string { return e.reason } |
873
|
|
|
|
874
|
|
|
// Cause function returns cause value. |
875
|
|
|
func (e RewriteValidationError) Cause() error { return e.cause } |
876
|
|
|
|
877
|
|
|
// Key function returns key value. |
878
|
|
|
func (e RewriteValidationError) Key() bool { return e.key } |
879
|
|
|
|
880
|
|
|
// ErrorName returns error name. |
881
|
|
|
func (e RewriteValidationError) ErrorName() string { return "RewriteValidationError" } |
882
|
|
|
|
883
|
|
|
// Error satisfies the builtin error interface |
884
|
|
|
func (e RewriteValidationError) Error() string { |
885
|
|
|
cause := "" |
886
|
|
|
if e.cause != nil { |
887
|
|
|
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
888
|
|
|
} |
889
|
|
|
|
890
|
|
|
key := "" |
891
|
|
|
if e.key { |
892
|
|
|
key = "key for " |
893
|
|
|
} |
894
|
|
|
|
895
|
|
|
return fmt.Sprintf( |
896
|
|
|
"invalid %sRewrite.%s: %s%s", |
897
|
|
|
key, |
898
|
|
|
e.field, |
899
|
|
|
e.reason, |
900
|
|
|
cause) |
901
|
|
|
} |
902
|
|
|
|
903
|
|
|
var _ error = RewriteValidationError{} |
904
|
|
|
|
905
|
|
|
var _ interface { |
906
|
|
|
Field() string |
907
|
|
|
Reason() string |
908
|
|
|
Key() bool |
909
|
|
|
Cause() error |
910
|
|
|
ErrorName() string |
911
|
|
|
} = RewriteValidationError{} |
912
|
|
|
|
913
|
|
|
// Validate checks the field values on SchemaDefinition with the rules defined |
914
|
|
|
// in the proto definition for this message. If any rules are violated, the |
915
|
|
|
// first error encountered is returned, or nil if there are no violations. |
916
|
|
|
func (m *SchemaDefinition) Validate() error { |
917
|
|
|
return m.validate(false) |
918
|
|
|
} |
919
|
|
|
|
920
|
|
|
// ValidateAll checks the field values on SchemaDefinition with the rules |
921
|
|
|
// defined in the proto definition for this message. If any rules are |
922
|
|
|
// violated, the result is a list of violation errors wrapped in |
923
|
|
|
// SchemaDefinitionMultiError, or nil if none found. |
924
|
|
|
func (m *SchemaDefinition) ValidateAll() error { |
925
|
|
|
return m.validate(true) |
926
|
|
|
} |
927
|
|
|
|
928
|
|
|
func (m *SchemaDefinition) validate(all bool) error { |
929
|
|
|
if m == nil { |
930
|
|
|
return nil |
931
|
|
|
} |
932
|
|
|
|
933
|
|
|
var errors []error |
934
|
|
|
|
935
|
|
|
{ |
936
|
|
|
sorted_keys := make([]string, len(m.GetEntityDefinitions())) |
937
|
|
|
i := 0 |
938
|
|
|
for key := range m.GetEntityDefinitions() { |
939
|
|
|
sorted_keys[i] = key |
940
|
|
|
i++ |
941
|
|
|
} |
942
|
|
|
sort.Slice(sorted_keys, func(i, j int) bool { return sorted_keys[i] < sorted_keys[j] }) |
943
|
|
|
for _, key := range sorted_keys { |
944
|
|
|
val := m.GetEntityDefinitions()[key] |
945
|
|
|
_ = val |
946
|
|
|
|
947
|
|
|
// no validation rules for EntityDefinitions[key] |
948
|
|
|
|
949
|
|
|
if all { |
950
|
|
|
switch v := interface{}(val).(type) { |
951
|
|
|
case interface{ ValidateAll() error }: |
952
|
|
|
if err := v.ValidateAll(); err != nil { |
953
|
|
|
errors = append(errors, SchemaDefinitionValidationError{ |
954
|
|
|
field: fmt.Sprintf("EntityDefinitions[%v]", key), |
955
|
|
|
reason: "embedded message failed validation", |
956
|
|
|
cause: err, |
957
|
|
|
}) |
958
|
|
|
} |
959
|
|
|
case interface{ Validate() error }: |
960
|
|
|
if err := v.Validate(); err != nil { |
961
|
|
|
errors = append(errors, SchemaDefinitionValidationError{ |
962
|
|
|
field: fmt.Sprintf("EntityDefinitions[%v]", key), |
963
|
|
|
reason: "embedded message failed validation", |
964
|
|
|
cause: err, |
965
|
|
|
}) |
966
|
|
|
} |
967
|
|
|
} |
968
|
|
|
} else if v, ok := interface{}(val).(interface{ Validate() error }); ok { |
969
|
|
|
if err := v.Validate(); err != nil { |
970
|
|
|
return SchemaDefinitionValidationError{ |
971
|
|
|
field: fmt.Sprintf("EntityDefinitions[%v]", key), |
972
|
|
|
reason: "embedded message failed validation", |
973
|
|
|
cause: err, |
974
|
|
|
} |
975
|
|
|
} |
976
|
|
|
} |
977
|
|
|
|
978
|
|
|
} |
979
|
|
|
} |
980
|
|
|
|
981
|
|
|
{ |
982
|
|
|
sorted_keys := make([]string, len(m.GetRuleDefinitions())) |
983
|
|
|
i := 0 |
984
|
|
|
for key := range m.GetRuleDefinitions() { |
985
|
|
|
sorted_keys[i] = key |
986
|
|
|
i++ |
987
|
|
|
} |
988
|
|
|
sort.Slice(sorted_keys, func(i, j int) bool { return sorted_keys[i] < sorted_keys[j] }) |
989
|
|
|
for _, key := range sorted_keys { |
990
|
|
|
val := m.GetRuleDefinitions()[key] |
991
|
|
|
_ = val |
992
|
|
|
|
993
|
|
|
// no validation rules for RuleDefinitions[key] |
994
|
|
|
|
995
|
|
|
if all { |
996
|
|
|
switch v := interface{}(val).(type) { |
997
|
|
|
case interface{ ValidateAll() error }: |
998
|
|
|
if err := v.ValidateAll(); err != nil { |
999
|
|
|
errors = append(errors, SchemaDefinitionValidationError{ |
1000
|
|
|
field: fmt.Sprintf("RuleDefinitions[%v]", key), |
1001
|
|
|
reason: "embedded message failed validation", |
1002
|
|
|
cause: err, |
1003
|
|
|
}) |
1004
|
|
|
} |
1005
|
|
|
case interface{ Validate() error }: |
1006
|
|
|
if err := v.Validate(); err != nil { |
1007
|
|
|
errors = append(errors, SchemaDefinitionValidationError{ |
1008
|
|
|
field: fmt.Sprintf("RuleDefinitions[%v]", key), |
1009
|
|
|
reason: "embedded message failed validation", |
1010
|
|
|
cause: err, |
1011
|
|
|
}) |
1012
|
|
|
} |
1013
|
|
|
} |
1014
|
|
|
} else if v, ok := interface{}(val).(interface{ Validate() error }); ok { |
1015
|
|
|
if err := v.Validate(); err != nil { |
1016
|
|
|
return SchemaDefinitionValidationError{ |
1017
|
|
|
field: fmt.Sprintf("RuleDefinitions[%v]", key), |
1018
|
|
|
reason: "embedded message failed validation", |
1019
|
|
|
cause: err, |
1020
|
|
|
} |
1021
|
|
|
} |
1022
|
|
|
} |
1023
|
|
|
|
1024
|
|
|
} |
1025
|
|
|
} |
1026
|
|
|
|
1027
|
|
|
// no validation rules for References |
1028
|
|
|
|
1029
|
|
|
if len(errors) > 0 { |
1030
|
|
|
return SchemaDefinitionMultiError(errors) |
1031
|
|
|
} |
1032
|
|
|
|
1033
|
|
|
return nil |
1034
|
|
|
} |
1035
|
|
|
|
1036
|
|
|
// SchemaDefinitionMultiError is an error wrapping multiple validation errors |
1037
|
|
|
// returned by SchemaDefinition.ValidateAll() if the designated constraints |
1038
|
|
|
// aren't met. |
1039
|
|
|
type SchemaDefinitionMultiError []error |
1040
|
|
|
|
1041
|
|
|
// Error returns a concatenation of all the error messages it wraps. |
1042
|
|
|
func (m SchemaDefinitionMultiError) Error() string { |
1043
|
|
|
var msgs []string |
1044
|
|
|
for _, err := range m { |
1045
|
|
|
msgs = append(msgs, err.Error()) |
1046
|
|
|
} |
1047
|
|
|
return strings.Join(msgs, "; ") |
1048
|
|
|
} |
1049
|
|
|
|
1050
|
|
|
// AllErrors returns a list of validation violation errors. |
1051
|
|
|
func (m SchemaDefinitionMultiError) AllErrors() []error { return m } |
1052
|
|
|
|
1053
|
|
|
// SchemaDefinitionValidationError is the validation error returned by |
1054
|
|
|
// SchemaDefinition.Validate if the designated constraints aren't met. |
1055
|
|
|
type SchemaDefinitionValidationError struct { |
1056
|
|
|
field string |
1057
|
|
|
reason string |
1058
|
|
|
cause error |
1059
|
|
|
key bool |
1060
|
|
|
} |
1061
|
|
|
|
1062
|
|
|
// Field function returns field value. |
1063
|
|
|
func (e SchemaDefinitionValidationError) Field() string { return e.field } |
1064
|
|
|
|
1065
|
|
|
// Reason function returns reason value. |
1066
|
|
|
func (e SchemaDefinitionValidationError) Reason() string { return e.reason } |
1067
|
|
|
|
1068
|
|
|
// Cause function returns cause value. |
1069
|
|
|
func (e SchemaDefinitionValidationError) Cause() error { return e.cause } |
1070
|
|
|
|
1071
|
|
|
// Key function returns key value. |
1072
|
|
|
func (e SchemaDefinitionValidationError) Key() bool { return e.key } |
1073
|
|
|
|
1074
|
|
|
// ErrorName returns error name. |
1075
|
|
|
func (e SchemaDefinitionValidationError) ErrorName() string { return "SchemaDefinitionValidationError" } |
1076
|
|
|
|
1077
|
|
|
// Error satisfies the builtin error interface |
1078
|
|
|
func (e SchemaDefinitionValidationError) Error() string { |
1079
|
|
|
cause := "" |
1080
|
|
|
if e.cause != nil { |
1081
|
|
|
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
1082
|
|
|
} |
1083
|
|
|
|
1084
|
|
|
key := "" |
1085
|
|
|
if e.key { |
1086
|
|
|
key = "key for " |
1087
|
|
|
} |
1088
|
|
|
|
1089
|
|
|
return fmt.Sprintf( |
1090
|
|
|
"invalid %sSchemaDefinition.%s: %s%s", |
1091
|
|
|
key, |
1092
|
|
|
e.field, |
1093
|
|
|
e.reason, |
1094
|
|
|
cause) |
1095
|
|
|
} |
1096
|
|
|
|
1097
|
|
|
var _ error = SchemaDefinitionValidationError{} |
1098
|
|
|
|
1099
|
|
|
var _ interface { |
1100
|
|
|
Field() string |
1101
|
|
|
Reason() string |
1102
|
|
|
Key() bool |
1103
|
|
|
Cause() error |
1104
|
|
|
ErrorName() string |
1105
|
|
|
} = SchemaDefinitionValidationError{} |
1106
|
|
|
|
1107
|
|
|
// Validate checks the field values on EntityDefinition with the rules defined |
1108
|
|
|
// in the proto definition for this message. If any rules are violated, the |
1109
|
|
|
// first error encountered is returned, or nil if there are no violations. |
1110
|
|
|
func (m *EntityDefinition) Validate() error { |
1111
|
|
|
return m.validate(false) |
1112
|
|
|
} |
1113
|
|
|
|
1114
|
|
|
// ValidateAll checks the field values on EntityDefinition with the rules |
1115
|
|
|
// defined in the proto definition for this message. If any rules are |
1116
|
|
|
// violated, the result is a list of violation errors wrapped in |
1117
|
|
|
// EntityDefinitionMultiError, or nil if none found. |
1118
|
|
|
func (m *EntityDefinition) ValidateAll() error { |
1119
|
|
|
return m.validate(true) |
1120
|
|
|
} |
1121
|
|
|
|
1122
|
|
|
func (m *EntityDefinition) validate(all bool) error { |
1123
|
|
|
if m == nil { |
1124
|
|
|
return nil |
1125
|
|
|
} |
1126
|
|
|
|
1127
|
|
|
var errors []error |
1128
|
|
|
|
1129
|
|
|
if len(m.GetName()) > 64 { |
1130
|
|
|
err := EntityDefinitionValidationError{ |
1131
|
|
|
field: "Name", |
1132
|
|
|
reason: "value length must be at most 64 bytes", |
1133
|
|
|
} |
1134
|
|
|
if !all { |
1135
|
|
|
return err |
1136
|
|
|
} |
1137
|
|
|
errors = append(errors, err) |
1138
|
|
|
} |
1139
|
|
|
|
1140
|
|
|
if !_EntityDefinition_Name_Pattern.MatchString(m.GetName()) { |
1141
|
|
|
err := EntityDefinitionValidationError{ |
1142
|
|
|
field: "Name", |
1143
|
|
|
reason: "value does not match regex pattern \"^[a-zA-Z_]{1,64}$\"", |
1144
|
|
|
} |
1145
|
|
|
if !all { |
1146
|
|
|
return err |
1147
|
|
|
} |
1148
|
|
|
errors = append(errors, err) |
1149
|
|
|
} |
1150
|
|
|
|
1151
|
|
|
{ |
1152
|
|
|
sorted_keys := make([]string, len(m.GetRelations())) |
1153
|
|
|
i := 0 |
1154
|
|
|
for key := range m.GetRelations() { |
1155
|
|
|
sorted_keys[i] = key |
1156
|
|
|
i++ |
1157
|
|
|
} |
1158
|
|
|
sort.Slice(sorted_keys, func(i, j int) bool { return sorted_keys[i] < sorted_keys[j] }) |
1159
|
|
|
for _, key := range sorted_keys { |
1160
|
|
|
val := m.GetRelations()[key] |
1161
|
|
|
_ = val |
1162
|
|
|
|
1163
|
|
|
// no validation rules for Relations[key] |
1164
|
|
|
|
1165
|
|
|
if all { |
1166
|
|
|
switch v := interface{}(val).(type) { |
1167
|
|
|
case interface{ ValidateAll() error }: |
1168
|
|
|
if err := v.ValidateAll(); err != nil { |
1169
|
|
|
errors = append(errors, EntityDefinitionValidationError{ |
1170
|
|
|
field: fmt.Sprintf("Relations[%v]", key), |
1171
|
|
|
reason: "embedded message failed validation", |
1172
|
|
|
cause: err, |
1173
|
|
|
}) |
1174
|
|
|
} |
1175
|
|
|
case interface{ Validate() error }: |
1176
|
|
|
if err := v.Validate(); err != nil { |
1177
|
|
|
errors = append(errors, EntityDefinitionValidationError{ |
1178
|
|
|
field: fmt.Sprintf("Relations[%v]", key), |
1179
|
|
|
reason: "embedded message failed validation", |
1180
|
|
|
cause: err, |
1181
|
|
|
}) |
1182
|
|
|
} |
1183
|
|
|
} |
1184
|
|
|
} else if v, ok := interface{}(val).(interface{ Validate() error }); ok { |
1185
|
|
|
if err := v.Validate(); err != nil { |
1186
|
|
|
return EntityDefinitionValidationError{ |
1187
|
|
|
field: fmt.Sprintf("Relations[%v]", key), |
1188
|
|
|
reason: "embedded message failed validation", |
1189
|
|
|
cause: err, |
1190
|
|
|
} |
1191
|
|
|
} |
1192
|
|
|
} |
1193
|
|
|
|
1194
|
|
|
} |
1195
|
|
|
} |
1196
|
|
|
|
1197
|
|
|
{ |
1198
|
|
|
sorted_keys := make([]string, len(m.GetPermissions())) |
1199
|
|
|
i := 0 |
1200
|
|
|
for key := range m.GetPermissions() { |
1201
|
|
|
sorted_keys[i] = key |
1202
|
|
|
i++ |
1203
|
|
|
} |
1204
|
|
|
sort.Slice(sorted_keys, func(i, j int) bool { return sorted_keys[i] < sorted_keys[j] }) |
1205
|
|
|
for _, key := range sorted_keys { |
1206
|
|
|
val := m.GetPermissions()[key] |
1207
|
|
|
_ = val |
1208
|
|
|
|
1209
|
|
|
// no validation rules for Permissions[key] |
1210
|
|
|
|
1211
|
|
|
if all { |
1212
|
|
|
switch v := interface{}(val).(type) { |
1213
|
|
|
case interface{ ValidateAll() error }: |
1214
|
|
|
if err := v.ValidateAll(); err != nil { |
1215
|
|
|
errors = append(errors, EntityDefinitionValidationError{ |
1216
|
|
|
field: fmt.Sprintf("Permissions[%v]", key), |
1217
|
|
|
reason: "embedded message failed validation", |
1218
|
|
|
cause: err, |
1219
|
|
|
}) |
1220
|
|
|
} |
1221
|
|
|
case interface{ Validate() error }: |
1222
|
|
|
if err := v.Validate(); err != nil { |
1223
|
|
|
errors = append(errors, EntityDefinitionValidationError{ |
1224
|
|
|
field: fmt.Sprintf("Permissions[%v]", key), |
1225
|
|
|
reason: "embedded message failed validation", |
1226
|
|
|
cause: err, |
1227
|
|
|
}) |
1228
|
|
|
} |
1229
|
|
|
} |
1230
|
|
|
} else if v, ok := interface{}(val).(interface{ Validate() error }); ok { |
1231
|
|
|
if err := v.Validate(); err != nil { |
1232
|
|
|
return EntityDefinitionValidationError{ |
1233
|
|
|
field: fmt.Sprintf("Permissions[%v]", key), |
1234
|
|
|
reason: "embedded message failed validation", |
1235
|
|
|
cause: err, |
1236
|
|
|
} |
1237
|
|
|
} |
1238
|
|
|
} |
1239
|
|
|
|
1240
|
|
|
} |
1241
|
|
|
} |
1242
|
|
|
|
1243
|
|
|
{ |
1244
|
|
|
sorted_keys := make([]string, len(m.GetAttributes())) |
1245
|
|
|
i := 0 |
1246
|
|
|
for key := range m.GetAttributes() { |
1247
|
|
|
sorted_keys[i] = key |
1248
|
|
|
i++ |
1249
|
|
|
} |
1250
|
|
|
sort.Slice(sorted_keys, func(i, j int) bool { return sorted_keys[i] < sorted_keys[j] }) |
1251
|
|
|
for _, key := range sorted_keys { |
1252
|
|
|
val := m.GetAttributes()[key] |
1253
|
|
|
_ = val |
1254
|
|
|
|
1255
|
|
|
// no validation rules for Attributes[key] |
1256
|
|
|
|
1257
|
|
|
if all { |
1258
|
|
|
switch v := interface{}(val).(type) { |
1259
|
|
|
case interface{ ValidateAll() error }: |
1260
|
|
|
if err := v.ValidateAll(); err != nil { |
1261
|
|
|
errors = append(errors, EntityDefinitionValidationError{ |
1262
|
|
|
field: fmt.Sprintf("Attributes[%v]", key), |
1263
|
|
|
reason: "embedded message failed validation", |
1264
|
|
|
cause: err, |
1265
|
|
|
}) |
1266
|
|
|
} |
1267
|
|
|
case interface{ Validate() error }: |
1268
|
|
|
if err := v.Validate(); err != nil { |
1269
|
|
|
errors = append(errors, EntityDefinitionValidationError{ |
1270
|
|
|
field: fmt.Sprintf("Attributes[%v]", key), |
1271
|
|
|
reason: "embedded message failed validation", |
1272
|
|
|
cause: err, |
1273
|
|
|
}) |
1274
|
|
|
} |
1275
|
|
|
} |
1276
|
|
|
} else if v, ok := interface{}(val).(interface{ Validate() error }); ok { |
1277
|
|
|
if err := v.Validate(); err != nil { |
1278
|
|
|
return EntityDefinitionValidationError{ |
1279
|
|
|
field: fmt.Sprintf("Attributes[%v]", key), |
1280
|
|
|
reason: "embedded message failed validation", |
1281
|
|
|
cause: err, |
1282
|
|
|
} |
1283
|
|
|
} |
1284
|
|
|
} |
1285
|
|
|
|
1286
|
|
|
} |
1287
|
|
|
} |
1288
|
|
|
|
1289
|
|
|
// no validation rules for References |
1290
|
|
|
|
1291
|
|
|
if len(errors) > 0 { |
1292
|
|
|
return EntityDefinitionMultiError(errors) |
1293
|
|
|
} |
1294
|
|
|
|
1295
|
|
|
return nil |
1296
|
|
|
} |
1297
|
|
|
|
1298
|
|
|
// EntityDefinitionMultiError is an error wrapping multiple validation errors |
1299
|
|
|
// returned by EntityDefinition.ValidateAll() if the designated constraints |
1300
|
|
|
// aren't met. |
1301
|
|
|
type EntityDefinitionMultiError []error |
1302
|
|
|
|
1303
|
|
|
// Error returns a concatenation of all the error messages it wraps. |
1304
|
|
|
func (m EntityDefinitionMultiError) Error() string { |
1305
|
|
|
var msgs []string |
1306
|
|
|
for _, err := range m { |
1307
|
|
|
msgs = append(msgs, err.Error()) |
1308
|
|
|
} |
1309
|
|
|
return strings.Join(msgs, "; ") |
1310
|
|
|
} |
1311
|
|
|
|
1312
|
|
|
// AllErrors returns a list of validation violation errors. |
1313
|
|
|
func (m EntityDefinitionMultiError) AllErrors() []error { return m } |
1314
|
|
|
|
1315
|
|
|
// EntityDefinitionValidationError is the validation error returned by |
1316
|
|
|
// EntityDefinition.Validate if the designated constraints aren't met. |
1317
|
|
|
type EntityDefinitionValidationError struct { |
1318
|
|
|
field string |
1319
|
|
|
reason string |
1320
|
|
|
cause error |
1321
|
|
|
key bool |
1322
|
|
|
} |
1323
|
|
|
|
1324
|
|
|
// Field function returns field value. |
1325
|
|
|
func (e EntityDefinitionValidationError) Field() string { return e.field } |
1326
|
|
|
|
1327
|
|
|
// Reason function returns reason value. |
1328
|
|
|
func (e EntityDefinitionValidationError) Reason() string { return e.reason } |
1329
|
|
|
|
1330
|
|
|
// Cause function returns cause value. |
1331
|
|
|
func (e EntityDefinitionValidationError) Cause() error { return e.cause } |
1332
|
|
|
|
1333
|
|
|
// Key function returns key value. |
1334
|
|
|
func (e EntityDefinitionValidationError) Key() bool { return e.key } |
1335
|
|
|
|
1336
|
|
|
// ErrorName returns error name. |
1337
|
|
|
func (e EntityDefinitionValidationError) ErrorName() string { return "EntityDefinitionValidationError" } |
1338
|
|
|
|
1339
|
|
|
// Error satisfies the builtin error interface |
1340
|
|
|
func (e EntityDefinitionValidationError) Error() string { |
1341
|
|
|
cause := "" |
1342
|
|
|
if e.cause != nil { |
1343
|
|
|
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
1344
|
|
|
} |
1345
|
|
|
|
1346
|
|
|
key := "" |
1347
|
|
|
if e.key { |
1348
|
|
|
key = "key for " |
1349
|
|
|
} |
1350
|
|
|
|
1351
|
|
|
return fmt.Sprintf( |
1352
|
|
|
"invalid %sEntityDefinition.%s: %s%s", |
1353
|
|
|
key, |
1354
|
|
|
e.field, |
1355
|
|
|
e.reason, |
1356
|
|
|
cause) |
1357
|
|
|
} |
1358
|
|
|
|
1359
|
|
|
var _ error = EntityDefinitionValidationError{} |
1360
|
|
|
|
1361
|
|
|
var _ interface { |
1362
|
|
|
Field() string |
1363
|
|
|
Reason() string |
1364
|
|
|
Key() bool |
1365
|
|
|
Cause() error |
1366
|
|
|
ErrorName() string |
1367
|
|
|
} = EntityDefinitionValidationError{} |
1368
|
|
|
|
1369
|
|
|
var _EntityDefinition_Name_Pattern = regexp.MustCompile("^[a-zA-Z_]{1,64}$") |
1370
|
|
|
|
1371
|
|
|
// Validate checks the field values on RuleDefinition with the rules defined in |
1372
|
|
|
// the proto definition for this message. If any rules are violated, the first |
1373
|
|
|
// error encountered is returned, or nil if there are no violations. |
1374
|
|
|
func (m *RuleDefinition) Validate() error { |
1375
|
|
|
return m.validate(false) |
1376
|
|
|
} |
1377
|
|
|
|
1378
|
|
|
// ValidateAll checks the field values on RuleDefinition with the rules defined |
1379
|
|
|
// in the proto definition for this message. If any rules are violated, the |
1380
|
|
|
// result is a list of violation errors wrapped in RuleDefinitionMultiError, |
1381
|
|
|
// or nil if none found. |
1382
|
|
|
func (m *RuleDefinition) ValidateAll() error { |
1383
|
|
|
return m.validate(true) |
1384
|
|
|
} |
1385
|
|
|
|
1386
|
|
|
func (m *RuleDefinition) validate(all bool) error { |
1387
|
|
|
if m == nil { |
1388
|
|
|
return nil |
1389
|
|
|
} |
1390
|
|
|
|
1391
|
|
|
var errors []error |
1392
|
|
|
|
1393
|
|
|
if len(m.GetName()) > 64 { |
1394
|
|
|
err := RuleDefinitionValidationError{ |
1395
|
|
|
field: "Name", |
1396
|
|
|
reason: "value length must be at most 64 bytes", |
1397
|
|
|
} |
1398
|
|
|
if !all { |
1399
|
|
|
return err |
1400
|
|
|
} |
1401
|
|
|
errors = append(errors, err) |
1402
|
|
|
} |
1403
|
|
|
|
1404
|
|
|
if !_RuleDefinition_Name_Pattern.MatchString(m.GetName()) { |
1405
|
|
|
err := RuleDefinitionValidationError{ |
1406
|
|
|
field: "Name", |
1407
|
|
|
reason: "value does not match regex pattern \"^[a-zA-Z_]{1,64}$\"", |
1408
|
|
|
} |
1409
|
|
|
if !all { |
1410
|
|
|
return err |
1411
|
|
|
} |
1412
|
|
|
errors = append(errors, err) |
1413
|
|
|
} |
1414
|
|
|
|
1415
|
|
|
// no validation rules for Arguments |
1416
|
|
|
|
1417
|
|
|
if all { |
1418
|
|
|
switch v := interface{}(m.GetExpression()).(type) { |
1419
|
|
|
case interface{ ValidateAll() error }: |
1420
|
|
|
if err := v.ValidateAll(); err != nil { |
1421
|
|
|
errors = append(errors, RuleDefinitionValidationError{ |
1422
|
|
|
field: "Expression", |
1423
|
|
|
reason: "embedded message failed validation", |
1424
|
|
|
cause: err, |
1425
|
|
|
}) |
1426
|
|
|
} |
1427
|
|
|
case interface{ Validate() error }: |
1428
|
|
|
if err := v.Validate(); err != nil { |
1429
|
|
|
errors = append(errors, RuleDefinitionValidationError{ |
1430
|
|
|
field: "Expression", |
1431
|
|
|
reason: "embedded message failed validation", |
1432
|
|
|
cause: err, |
1433
|
|
|
}) |
1434
|
|
|
} |
1435
|
|
|
} |
1436
|
|
|
} else if v, ok := interface{}(m.GetExpression()).(interface{ Validate() error }); ok { |
1437
|
|
|
if err := v.Validate(); err != nil { |
1438
|
|
|
return RuleDefinitionValidationError{ |
1439
|
|
|
field: "Expression", |
1440
|
|
|
reason: "embedded message failed validation", |
1441
|
|
|
cause: err, |
1442
|
|
|
} |
1443
|
|
|
} |
1444
|
|
|
} |
1445
|
|
|
|
1446
|
|
|
if len(errors) > 0 { |
1447
|
|
|
return RuleDefinitionMultiError(errors) |
1448
|
|
|
} |
1449
|
|
|
|
1450
|
|
|
return nil |
1451
|
|
|
} |
1452
|
|
|
|
1453
|
|
|
// RuleDefinitionMultiError is an error wrapping multiple validation errors |
1454
|
|
|
// returned by RuleDefinition.ValidateAll() if the designated constraints |
1455
|
|
|
// aren't met. |
1456
|
|
|
type RuleDefinitionMultiError []error |
1457
|
|
|
|
1458
|
|
|
// Error returns a concatenation of all the error messages it wraps. |
1459
|
|
|
func (m RuleDefinitionMultiError) Error() string { |
1460
|
|
|
var msgs []string |
1461
|
|
|
for _, err := range m { |
1462
|
|
|
msgs = append(msgs, err.Error()) |
1463
|
|
|
} |
1464
|
|
|
return strings.Join(msgs, "; ") |
1465
|
|
|
} |
1466
|
|
|
|
1467
|
|
|
// AllErrors returns a list of validation violation errors. |
1468
|
|
|
func (m RuleDefinitionMultiError) AllErrors() []error { return m } |
1469
|
|
|
|
1470
|
|
|
// RuleDefinitionValidationError is the validation error returned by |
1471
|
|
|
// RuleDefinition.Validate if the designated constraints aren't met. |
1472
|
|
|
type RuleDefinitionValidationError struct { |
1473
|
|
|
field string |
1474
|
|
|
reason string |
1475
|
|
|
cause error |
1476
|
|
|
key bool |
1477
|
|
|
} |
1478
|
|
|
|
1479
|
|
|
// Field function returns field value. |
1480
|
|
|
func (e RuleDefinitionValidationError) Field() string { return e.field } |
1481
|
|
|
|
1482
|
|
|
// Reason function returns reason value. |
1483
|
|
|
func (e RuleDefinitionValidationError) Reason() string { return e.reason } |
1484
|
|
|
|
1485
|
|
|
// Cause function returns cause value. |
1486
|
|
|
func (e RuleDefinitionValidationError) Cause() error { return e.cause } |
1487
|
|
|
|
1488
|
|
|
// Key function returns key value. |
1489
|
|
|
func (e RuleDefinitionValidationError) Key() bool { return e.key } |
1490
|
|
|
|
1491
|
|
|
// ErrorName returns error name. |
1492
|
|
|
func (e RuleDefinitionValidationError) ErrorName() string { return "RuleDefinitionValidationError" } |
1493
|
|
|
|
1494
|
|
|
// Error satisfies the builtin error interface |
1495
|
|
|
func (e RuleDefinitionValidationError) Error() string { |
1496
|
|
|
cause := "" |
1497
|
|
|
if e.cause != nil { |
1498
|
|
|
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
1499
|
|
|
} |
1500
|
|
|
|
1501
|
|
|
key := "" |
1502
|
|
|
if e.key { |
1503
|
|
|
key = "key for " |
1504
|
|
|
} |
1505
|
|
|
|
1506
|
|
|
return fmt.Sprintf( |
1507
|
|
|
"invalid %sRuleDefinition.%s: %s%s", |
1508
|
|
|
key, |
1509
|
|
|
e.field, |
1510
|
|
|
e.reason, |
1511
|
|
|
cause) |
1512
|
|
|
} |
1513
|
|
|
|
1514
|
|
|
var _ error = RuleDefinitionValidationError{} |
1515
|
|
|
|
1516
|
|
|
var _ interface { |
1517
|
|
|
Field() string |
1518
|
|
|
Reason() string |
1519
|
|
|
Key() bool |
1520
|
|
|
Cause() error |
1521
|
|
|
ErrorName() string |
1522
|
|
|
} = RuleDefinitionValidationError{} |
1523
|
|
|
|
1524
|
|
|
var _RuleDefinition_Name_Pattern = regexp.MustCompile("^[a-zA-Z_]{1,64}$") |
1525
|
|
|
|
1526
|
|
|
// Validate checks the field values on AttributeDefinition with the rules |
1527
|
|
|
// defined in the proto definition for this message. If any rules are |
1528
|
|
|
// violated, the first error encountered is returned, or nil if there are no violations. |
1529
|
|
|
func (m *AttributeDefinition) Validate() error { |
1530
|
|
|
return m.validate(false) |
1531
|
|
|
} |
1532
|
|
|
|
1533
|
|
|
// ValidateAll checks the field values on AttributeDefinition with the rules |
1534
|
|
|
// defined in the proto definition for this message. If any rules are |
1535
|
|
|
// violated, the result is a list of violation errors wrapped in |
1536
|
|
|
// AttributeDefinitionMultiError, or nil if none found. |
1537
|
|
|
func (m *AttributeDefinition) ValidateAll() error { |
1538
|
|
|
return m.validate(true) |
1539
|
|
|
} |
1540
|
|
|
|
1541
|
|
|
func (m *AttributeDefinition) validate(all bool) error { |
1542
|
|
|
if m == nil { |
1543
|
|
|
return nil |
1544
|
|
|
} |
1545
|
|
|
|
1546
|
|
|
var errors []error |
1547
|
|
|
|
1548
|
|
|
if len(m.GetName()) > 64 { |
1549
|
|
|
err := AttributeDefinitionValidationError{ |
1550
|
|
|
field: "Name", |
1551
|
|
|
reason: "value length must be at most 64 bytes", |
1552
|
|
|
} |
1553
|
|
|
if !all { |
1554
|
|
|
return err |
1555
|
|
|
} |
1556
|
|
|
errors = append(errors, err) |
1557
|
|
|
} |
1558
|
|
|
|
1559
|
|
|
if !_AttributeDefinition_Name_Pattern.MatchString(m.GetName()) { |
1560
|
|
|
err := AttributeDefinitionValidationError{ |
1561
|
|
|
field: "Name", |
1562
|
|
|
reason: "value does not match regex pattern \"^[a-zA-Z_]{1,64}$\"", |
1563
|
|
|
} |
1564
|
|
|
if !all { |
1565
|
|
|
return err |
1566
|
|
|
} |
1567
|
|
|
errors = append(errors, err) |
1568
|
|
|
} |
1569
|
|
|
|
1570
|
|
|
// no validation rules for Type |
1571
|
|
|
|
1572
|
|
|
if len(errors) > 0 { |
1573
|
|
|
return AttributeDefinitionMultiError(errors) |
1574
|
|
|
} |
1575
|
|
|
|
1576
|
|
|
return nil |
1577
|
|
|
} |
1578
|
|
|
|
1579
|
|
|
// AttributeDefinitionMultiError is an error wrapping multiple validation |
1580
|
|
|
// errors returned by AttributeDefinition.ValidateAll() if the designated |
1581
|
|
|
// constraints aren't met. |
1582
|
|
|
type AttributeDefinitionMultiError []error |
1583
|
|
|
|
1584
|
|
|
// Error returns a concatenation of all the error messages it wraps. |
1585
|
|
|
func (m AttributeDefinitionMultiError) Error() string { |
1586
|
|
|
var msgs []string |
1587
|
|
|
for _, err := range m { |
1588
|
|
|
msgs = append(msgs, err.Error()) |
1589
|
|
|
} |
1590
|
|
|
return strings.Join(msgs, "; ") |
1591
|
|
|
} |
1592
|
|
|
|
1593
|
|
|
// AllErrors returns a list of validation violation errors. |
1594
|
|
|
func (m AttributeDefinitionMultiError) AllErrors() []error { return m } |
1595
|
|
|
|
1596
|
|
|
// AttributeDefinitionValidationError is the validation error returned by |
1597
|
|
|
// AttributeDefinition.Validate if the designated constraints aren't met. |
1598
|
|
|
type AttributeDefinitionValidationError struct { |
1599
|
|
|
field string |
1600
|
|
|
reason string |
1601
|
|
|
cause error |
1602
|
|
|
key bool |
1603
|
|
|
} |
1604
|
|
|
|
1605
|
|
|
// Field function returns field value. |
1606
|
|
|
func (e AttributeDefinitionValidationError) Field() string { return e.field } |
1607
|
|
|
|
1608
|
|
|
// Reason function returns reason value. |
1609
|
|
|
func (e AttributeDefinitionValidationError) Reason() string { return e.reason } |
1610
|
|
|
|
1611
|
|
|
// Cause function returns cause value. |
1612
|
|
|
func (e AttributeDefinitionValidationError) Cause() error { return e.cause } |
1613
|
|
|
|
1614
|
|
|
// Key function returns key value. |
1615
|
|
|
func (e AttributeDefinitionValidationError) Key() bool { return e.key } |
1616
|
|
|
|
1617
|
|
|
// ErrorName returns error name. |
1618
|
|
|
func (e AttributeDefinitionValidationError) ErrorName() string { |
1619
|
|
|
return "AttributeDefinitionValidationError" |
1620
|
|
|
} |
1621
|
|
|
|
1622
|
|
|
// Error satisfies the builtin error interface |
1623
|
|
|
func (e AttributeDefinitionValidationError) Error() string { |
1624
|
|
|
cause := "" |
1625
|
|
|
if e.cause != nil { |
1626
|
|
|
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
1627
|
|
|
} |
1628
|
|
|
|
1629
|
|
|
key := "" |
1630
|
|
|
if e.key { |
1631
|
|
|
key = "key for " |
1632
|
|
|
} |
1633
|
|
|
|
1634
|
|
|
return fmt.Sprintf( |
1635
|
|
|
"invalid %sAttributeDefinition.%s: %s%s", |
1636
|
|
|
key, |
1637
|
|
|
e.field, |
1638
|
|
|
e.reason, |
1639
|
|
|
cause) |
1640
|
|
|
} |
1641
|
|
|
|
1642
|
|
|
var _ error = AttributeDefinitionValidationError{} |
1643
|
|
|
|
1644
|
|
|
var _ interface { |
1645
|
|
|
Field() string |
1646
|
|
|
Reason() string |
1647
|
|
|
Key() bool |
1648
|
|
|
Cause() error |
1649
|
|
|
ErrorName() string |
1650
|
|
|
} = AttributeDefinitionValidationError{} |
1651
|
|
|
|
1652
|
|
|
var _AttributeDefinition_Name_Pattern = regexp.MustCompile("^[a-zA-Z_]{1,64}$") |
1653
|
|
|
|
1654
|
|
|
// Validate checks the field values on RelationDefinition with the rules |
1655
|
|
|
// defined in the proto definition for this message. If any rules are |
1656
|
|
|
// violated, the first error encountered is returned, or nil if there are no violations. |
1657
|
|
|
func (m *RelationDefinition) Validate() error { |
1658
|
|
|
return m.validate(false) |
1659
|
|
|
} |
1660
|
|
|
|
1661
|
|
|
// ValidateAll checks the field values on RelationDefinition with the rules |
1662
|
|
|
// defined in the proto definition for this message. If any rules are |
1663
|
|
|
// violated, the result is a list of violation errors wrapped in |
1664
|
|
|
// RelationDefinitionMultiError, or nil if none found. |
1665
|
|
|
func (m *RelationDefinition) ValidateAll() error { |
1666
|
|
|
return m.validate(true) |
1667
|
|
|
} |
1668
|
|
|
|
1669
|
|
|
func (m *RelationDefinition) validate(all bool) error { |
1670
|
|
|
if m == nil { |
1671
|
|
|
return nil |
1672
|
|
|
} |
1673
|
|
|
|
1674
|
|
|
var errors []error |
1675
|
|
|
|
1676
|
|
|
if len(m.GetName()) > 64 { |
1677
|
|
|
err := RelationDefinitionValidationError{ |
1678
|
|
|
field: "Name", |
1679
|
|
|
reason: "value length must be at most 64 bytes", |
1680
|
|
|
} |
1681
|
|
|
if !all { |
1682
|
|
|
return err |
1683
|
|
|
} |
1684
|
|
|
errors = append(errors, err) |
1685
|
|
|
} |
1686
|
|
|
|
1687
|
|
|
if !_RelationDefinition_Name_Pattern.MatchString(m.GetName()) { |
1688
|
|
|
err := RelationDefinitionValidationError{ |
1689
|
|
|
field: "Name", |
1690
|
|
|
reason: "value does not match regex pattern \"^[a-zA-Z_]{1,64}$\"", |
1691
|
|
|
} |
1692
|
|
|
if !all { |
1693
|
|
|
return err |
1694
|
|
|
} |
1695
|
|
|
errors = append(errors, err) |
1696
|
|
|
} |
1697
|
|
|
|
1698
|
|
|
for idx, item := range m.GetRelationReferences() { |
1699
|
|
|
_, _ = idx, item |
1700
|
|
|
|
1701
|
|
|
if all { |
1702
|
|
|
switch v := interface{}(item).(type) { |
1703
|
|
|
case interface{ ValidateAll() error }: |
1704
|
|
|
if err := v.ValidateAll(); err != nil { |
1705
|
|
|
errors = append(errors, RelationDefinitionValidationError{ |
1706
|
|
|
field: fmt.Sprintf("RelationReferences[%v]", idx), |
1707
|
|
|
reason: "embedded message failed validation", |
1708
|
|
|
cause: err, |
1709
|
|
|
}) |
1710
|
|
|
} |
1711
|
|
|
case interface{ Validate() error }: |
1712
|
|
|
if err := v.Validate(); err != nil { |
1713
|
|
|
errors = append(errors, RelationDefinitionValidationError{ |
1714
|
|
|
field: fmt.Sprintf("RelationReferences[%v]", idx), |
1715
|
|
|
reason: "embedded message failed validation", |
1716
|
|
|
cause: err, |
1717
|
|
|
}) |
1718
|
|
|
} |
1719
|
|
|
} |
1720
|
|
|
} else if v, ok := interface{}(item).(interface{ Validate() error }); ok { |
1721
|
|
|
if err := v.Validate(); err != nil { |
1722
|
|
|
return RelationDefinitionValidationError{ |
1723
|
|
|
field: fmt.Sprintf("RelationReferences[%v]", idx), |
1724
|
|
|
reason: "embedded message failed validation", |
1725
|
|
|
cause: err, |
1726
|
|
|
} |
1727
|
|
|
} |
1728
|
|
|
} |
1729
|
|
|
|
1730
|
|
|
} |
1731
|
|
|
|
1732
|
|
|
if len(errors) > 0 { |
1733
|
|
|
return RelationDefinitionMultiError(errors) |
1734
|
|
|
} |
1735
|
|
|
|
1736
|
|
|
return nil |
1737
|
|
|
} |
1738
|
|
|
|
1739
|
|
|
// RelationDefinitionMultiError is an error wrapping multiple validation errors |
1740
|
|
|
// returned by RelationDefinition.ValidateAll() if the designated constraints |
1741
|
|
|
// aren't met. |
1742
|
|
|
type RelationDefinitionMultiError []error |
1743
|
|
|
|
1744
|
|
|
// Error returns a concatenation of all the error messages it wraps. |
1745
|
|
|
func (m RelationDefinitionMultiError) Error() string { |
1746
|
|
|
var msgs []string |
1747
|
|
|
for _, err := range m { |
1748
|
|
|
msgs = append(msgs, err.Error()) |
1749
|
|
|
} |
1750
|
|
|
return strings.Join(msgs, "; ") |
1751
|
|
|
} |
1752
|
|
|
|
1753
|
|
|
// AllErrors returns a list of validation violation errors. |
1754
|
|
|
func (m RelationDefinitionMultiError) AllErrors() []error { return m } |
1755
|
|
|
|
1756
|
|
|
// RelationDefinitionValidationError is the validation error returned by |
1757
|
|
|
// RelationDefinition.Validate if the designated constraints aren't met. |
1758
|
|
|
type RelationDefinitionValidationError struct { |
1759
|
|
|
field string |
1760
|
|
|
reason string |
1761
|
|
|
cause error |
1762
|
|
|
key bool |
1763
|
|
|
} |
1764
|
|
|
|
1765
|
|
|
// Field function returns field value. |
1766
|
|
|
func (e RelationDefinitionValidationError) Field() string { return e.field } |
1767
|
|
|
|
1768
|
|
|
// Reason function returns reason value. |
1769
|
|
|
func (e RelationDefinitionValidationError) Reason() string { return e.reason } |
1770
|
|
|
|
1771
|
|
|
// Cause function returns cause value. |
1772
|
|
|
func (e RelationDefinitionValidationError) Cause() error { return e.cause } |
1773
|
|
|
|
1774
|
|
|
// Key function returns key value. |
1775
|
|
|
func (e RelationDefinitionValidationError) Key() bool { return e.key } |
1776
|
|
|
|
1777
|
|
|
// ErrorName returns error name. |
1778
|
|
|
func (e RelationDefinitionValidationError) ErrorName() string { |
1779
|
|
|
return "RelationDefinitionValidationError" |
1780
|
|
|
} |
1781
|
|
|
|
1782
|
|
|
// Error satisfies the builtin error interface |
1783
|
|
|
func (e RelationDefinitionValidationError) Error() string { |
1784
|
|
|
cause := "" |
1785
|
|
|
if e.cause != nil { |
1786
|
|
|
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
1787
|
|
|
} |
1788
|
|
|
|
1789
|
|
|
key := "" |
1790
|
|
|
if e.key { |
1791
|
|
|
key = "key for " |
1792
|
|
|
} |
1793
|
|
|
|
1794
|
|
|
return fmt.Sprintf( |
1795
|
|
|
"invalid %sRelationDefinition.%s: %s%s", |
1796
|
|
|
key, |
1797
|
|
|
e.field, |
1798
|
|
|
e.reason, |
1799
|
|
|
cause) |
1800
|
|
|
} |
1801
|
|
|
|
1802
|
|
|
var _ error = RelationDefinitionValidationError{} |
1803
|
|
|
|
1804
|
|
|
var _ interface { |
1805
|
|
|
Field() string |
1806
|
|
|
Reason() string |
1807
|
|
|
Key() bool |
1808
|
|
|
Cause() error |
1809
|
|
|
ErrorName() string |
1810
|
|
|
} = RelationDefinitionValidationError{} |
1811
|
|
|
|
1812
|
|
|
var _RelationDefinition_Name_Pattern = regexp.MustCompile("^[a-zA-Z_]{1,64}$") |
1813
|
|
|
|
1814
|
|
|
// Validate checks the field values on PermissionDefinition with the rules |
1815
|
|
|
// defined in the proto definition for this message. If any rules are |
1816
|
|
|
// violated, the first error encountered is returned, or nil if there are no violations. |
1817
|
|
|
func (m *PermissionDefinition) Validate() error { |
1818
|
|
|
return m.validate(false) |
1819
|
|
|
} |
1820
|
|
|
|
1821
|
|
|
// ValidateAll checks the field values on PermissionDefinition with the rules |
1822
|
|
|
// defined in the proto definition for this message. If any rules are |
1823
|
|
|
// violated, the result is a list of violation errors wrapped in |
1824
|
|
|
// PermissionDefinitionMultiError, or nil if none found. |
1825
|
|
|
func (m *PermissionDefinition) ValidateAll() error { |
1826
|
|
|
return m.validate(true) |
1827
|
|
|
} |
1828
|
|
|
|
1829
|
|
|
func (m *PermissionDefinition) validate(all bool) error { |
1830
|
|
|
if m == nil { |
1831
|
|
|
return nil |
1832
|
|
|
} |
1833
|
|
|
|
1834
|
|
|
var errors []error |
1835
|
|
|
|
1836
|
|
|
if len(m.GetName()) > 64 { |
1837
|
|
|
err := PermissionDefinitionValidationError{ |
1838
|
|
|
field: "Name", |
1839
|
|
|
reason: "value length must be at most 64 bytes", |
1840
|
|
|
} |
1841
|
|
|
if !all { |
1842
|
|
|
return err |
1843
|
|
|
} |
1844
|
|
|
errors = append(errors, err) |
1845
|
|
|
} |
1846
|
|
|
|
1847
|
|
|
if !_PermissionDefinition_Name_Pattern.MatchString(m.GetName()) { |
1848
|
|
|
err := PermissionDefinitionValidationError{ |
1849
|
|
|
field: "Name", |
1850
|
|
|
reason: "value does not match regex pattern \"^[a-zA-Z_]{1,64}$\"", |
1851
|
|
|
} |
1852
|
|
|
if !all { |
1853
|
|
|
return err |
1854
|
|
|
} |
1855
|
|
|
errors = append(errors, err) |
1856
|
|
|
} |
1857
|
|
|
|
1858
|
|
|
if all { |
1859
|
|
|
switch v := interface{}(m.GetChild()).(type) { |
1860
|
|
|
case interface{ ValidateAll() error }: |
1861
|
|
|
if err := v.ValidateAll(); err != nil { |
1862
|
|
|
errors = append(errors, PermissionDefinitionValidationError{ |
1863
|
|
|
field: "Child", |
1864
|
|
|
reason: "embedded message failed validation", |
1865
|
|
|
cause: err, |
1866
|
|
|
}) |
1867
|
|
|
} |
1868
|
|
|
case interface{ Validate() error }: |
1869
|
|
|
if err := v.Validate(); err != nil { |
1870
|
|
|
errors = append(errors, PermissionDefinitionValidationError{ |
1871
|
|
|
field: "Child", |
1872
|
|
|
reason: "embedded message failed validation", |
1873
|
|
|
cause: err, |
1874
|
|
|
}) |
1875
|
|
|
} |
1876
|
|
|
} |
1877
|
|
|
} else if v, ok := interface{}(m.GetChild()).(interface{ Validate() error }); ok { |
1878
|
|
|
if err := v.Validate(); err != nil { |
1879
|
|
|
return PermissionDefinitionValidationError{ |
1880
|
|
|
field: "Child", |
1881
|
|
|
reason: "embedded message failed validation", |
1882
|
|
|
cause: err, |
1883
|
|
|
} |
1884
|
|
|
} |
1885
|
|
|
} |
1886
|
|
|
|
1887
|
|
|
if len(errors) > 0 { |
1888
|
|
|
return PermissionDefinitionMultiError(errors) |
1889
|
|
|
} |
1890
|
|
|
|
1891
|
|
|
return nil |
1892
|
|
|
} |
1893
|
|
|
|
1894
|
|
|
// PermissionDefinitionMultiError is an error wrapping multiple validation |
1895
|
|
|
// errors returned by PermissionDefinition.ValidateAll() if the designated |
1896
|
|
|
// constraints aren't met. |
1897
|
|
|
type PermissionDefinitionMultiError []error |
1898
|
|
|
|
1899
|
|
|
// Error returns a concatenation of all the error messages it wraps. |
1900
|
|
|
func (m PermissionDefinitionMultiError) Error() string { |
1901
|
|
|
var msgs []string |
1902
|
|
|
for _, err := range m { |
1903
|
|
|
msgs = append(msgs, err.Error()) |
1904
|
|
|
} |
1905
|
|
|
return strings.Join(msgs, "; ") |
1906
|
|
|
} |
1907
|
|
|
|
1908
|
|
|
// AllErrors returns a list of validation violation errors. |
1909
|
|
|
func (m PermissionDefinitionMultiError) AllErrors() []error { return m } |
1910
|
|
|
|
1911
|
|
|
// PermissionDefinitionValidationError is the validation error returned by |
1912
|
|
|
// PermissionDefinition.Validate if the designated constraints aren't met. |
1913
|
|
|
type PermissionDefinitionValidationError struct { |
1914
|
|
|
field string |
1915
|
|
|
reason string |
1916
|
|
|
cause error |
1917
|
|
|
key bool |
1918
|
|
|
} |
1919
|
|
|
|
1920
|
|
|
// Field function returns field value. |
1921
|
|
|
func (e PermissionDefinitionValidationError) Field() string { return e.field } |
1922
|
|
|
|
1923
|
|
|
// Reason function returns reason value. |
1924
|
|
|
func (e PermissionDefinitionValidationError) Reason() string { return e.reason } |
1925
|
|
|
|
1926
|
|
|
// Cause function returns cause value. |
1927
|
|
|
func (e PermissionDefinitionValidationError) Cause() error { return e.cause } |
1928
|
|
|
|
1929
|
|
|
// Key function returns key value. |
1930
|
|
|
func (e PermissionDefinitionValidationError) Key() bool { return e.key } |
1931
|
|
|
|
1932
|
|
|
// ErrorName returns error name. |
1933
|
|
|
func (e PermissionDefinitionValidationError) ErrorName() string { |
1934
|
|
|
return "PermissionDefinitionValidationError" |
1935
|
|
|
} |
1936
|
|
|
|
1937
|
|
|
// Error satisfies the builtin error interface |
1938
|
|
|
func (e PermissionDefinitionValidationError) Error() string { |
1939
|
|
|
cause := "" |
1940
|
|
|
if e.cause != nil { |
1941
|
|
|
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
1942
|
|
|
} |
1943
|
|
|
|
1944
|
|
|
key := "" |
1945
|
|
|
if e.key { |
1946
|
|
|
key = "key for " |
1947
|
|
|
} |
1948
|
|
|
|
1949
|
|
|
return fmt.Sprintf( |
1950
|
|
|
"invalid %sPermissionDefinition.%s: %s%s", |
1951
|
|
|
key, |
1952
|
|
|
e.field, |
1953
|
|
|
e.reason, |
1954
|
|
|
cause) |
1955
|
|
|
} |
1956
|
|
|
|
1957
|
|
|
var _ error = PermissionDefinitionValidationError{} |
1958
|
|
|
|
1959
|
|
|
var _ interface { |
1960
|
|
|
Field() string |
1961
|
|
|
Reason() string |
1962
|
|
|
Key() bool |
1963
|
|
|
Cause() error |
1964
|
|
|
ErrorName() string |
1965
|
|
|
} = PermissionDefinitionValidationError{} |
1966
|
|
|
|
1967
|
|
|
var _PermissionDefinition_Name_Pattern = regexp.MustCompile("^[a-zA-Z_]{1,64}$") |
1968
|
|
|
|
1969
|
|
|
// Validate checks the field values on RelationReference with the rules defined |
1970
|
|
|
// in the proto definition for this message. If any rules are violated, the |
1971
|
|
|
// first error encountered is returned, or nil if there are no violations. |
1972
|
|
|
func (m *RelationReference) Validate() error { |
1973
|
|
|
return m.validate(false) |
1974
|
|
|
} |
1975
|
|
|
|
1976
|
|
|
// ValidateAll checks the field values on RelationReference with the rules |
1977
|
|
|
// defined in the proto definition for this message. If any rules are |
1978
|
|
|
// violated, the result is a list of violation errors wrapped in |
1979
|
|
|
// RelationReferenceMultiError, or nil if none found. |
1980
|
|
|
func (m *RelationReference) ValidateAll() error { |
1981
|
|
|
return m.validate(true) |
1982
|
|
|
} |
1983
|
|
|
|
1984
|
|
|
func (m *RelationReference) validate(all bool) error { |
1985
|
|
|
if m == nil { |
1986
|
|
|
return nil |
1987
|
|
|
} |
1988
|
|
|
|
1989
|
|
|
var errors []error |
1990
|
|
|
|
1991
|
|
|
if len(m.GetType()) > 64 { |
1992
|
|
|
err := RelationReferenceValidationError{ |
1993
|
|
|
field: "Type", |
1994
|
|
|
reason: "value length must be at most 64 bytes", |
1995
|
|
|
} |
1996
|
|
|
if !all { |
1997
|
|
|
return err |
1998
|
|
|
} |
1999
|
|
|
errors = append(errors, err) |
2000
|
|
|
} |
2001
|
|
|
|
2002
|
|
|
if !_RelationReference_Type_Pattern.MatchString(m.GetType()) { |
2003
|
|
|
err := RelationReferenceValidationError{ |
2004
|
|
|
field: "Type", |
2005
|
|
|
reason: "value does not match regex pattern \"^[a-zA-Z_]{1,64}$\"", |
2006
|
|
|
} |
2007
|
|
|
if !all { |
2008
|
|
|
return err |
2009
|
|
|
} |
2010
|
|
|
errors = append(errors, err) |
2011
|
|
|
} |
2012
|
|
|
|
2013
|
|
|
if m.GetRelation() != "" { |
2014
|
|
|
|
2015
|
|
|
if len(m.GetRelation()) > 64 { |
2016
|
|
|
err := RelationReferenceValidationError{ |
2017
|
|
|
field: "Relation", |
2018
|
|
|
reason: "value length must be at most 64 bytes", |
2019
|
|
|
} |
2020
|
|
|
if !all { |
2021
|
|
|
return err |
2022
|
|
|
} |
2023
|
|
|
errors = append(errors, err) |
2024
|
|
|
} |
2025
|
|
|
|
2026
|
|
|
if !_RelationReference_Relation_Pattern.MatchString(m.GetRelation()) { |
2027
|
|
|
err := RelationReferenceValidationError{ |
2028
|
|
|
field: "Relation", |
2029
|
|
|
reason: "value does not match regex pattern \"^[a-zA-Z_]{1,64}$\"", |
2030
|
|
|
} |
2031
|
|
|
if !all { |
2032
|
|
|
return err |
2033
|
|
|
} |
2034
|
|
|
errors = append(errors, err) |
2035
|
|
|
} |
2036
|
|
|
|
2037
|
|
|
} |
2038
|
|
|
|
2039
|
|
|
if len(errors) > 0 { |
2040
|
|
|
return RelationReferenceMultiError(errors) |
2041
|
|
|
} |
2042
|
|
|
|
2043
|
|
|
return nil |
2044
|
|
|
} |
2045
|
|
|
|
2046
|
|
|
// RelationReferenceMultiError is an error wrapping multiple validation errors |
2047
|
|
|
// returned by RelationReference.ValidateAll() if the designated constraints |
2048
|
|
|
// aren't met. |
2049
|
|
|
type RelationReferenceMultiError []error |
2050
|
|
|
|
2051
|
|
|
// Error returns a concatenation of all the error messages it wraps. |
2052
|
|
|
func (m RelationReferenceMultiError) Error() string { |
2053
|
|
|
var msgs []string |
2054
|
|
|
for _, err := range m { |
2055
|
|
|
msgs = append(msgs, err.Error()) |
2056
|
|
|
} |
2057
|
|
|
return strings.Join(msgs, "; ") |
2058
|
|
|
} |
2059
|
|
|
|
2060
|
|
|
// AllErrors returns a list of validation violation errors. |
2061
|
|
|
func (m RelationReferenceMultiError) AllErrors() []error { return m } |
2062
|
|
|
|
2063
|
|
|
// RelationReferenceValidationError is the validation error returned by |
2064
|
|
|
// RelationReference.Validate if the designated constraints aren't met. |
2065
|
|
|
type RelationReferenceValidationError struct { |
2066
|
|
|
field string |
2067
|
|
|
reason string |
2068
|
|
|
cause error |
2069
|
|
|
key bool |
2070
|
|
|
} |
2071
|
|
|
|
2072
|
|
|
// Field function returns field value. |
2073
|
|
|
func (e RelationReferenceValidationError) Field() string { return e.field } |
2074
|
|
|
|
2075
|
|
|
// Reason function returns reason value. |
2076
|
|
|
func (e RelationReferenceValidationError) Reason() string { return e.reason } |
2077
|
|
|
|
2078
|
|
|
// Cause function returns cause value. |
2079
|
|
|
func (e RelationReferenceValidationError) Cause() error { return e.cause } |
2080
|
|
|
|
2081
|
|
|
// Key function returns key value. |
2082
|
|
|
func (e RelationReferenceValidationError) Key() bool { return e.key } |
2083
|
|
|
|
2084
|
|
|
// ErrorName returns error name. |
2085
|
|
|
func (e RelationReferenceValidationError) ErrorName() string { |
2086
|
|
|
return "RelationReferenceValidationError" |
2087
|
|
|
} |
2088
|
|
|
|
2089
|
|
|
// Error satisfies the builtin error interface |
2090
|
|
|
func (e RelationReferenceValidationError) Error() string { |
2091
|
|
|
cause := "" |
2092
|
|
|
if e.cause != nil { |
2093
|
|
|
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
2094
|
|
|
} |
2095
|
|
|
|
2096
|
|
|
key := "" |
2097
|
|
|
if e.key { |
2098
|
|
|
key = "key for " |
2099
|
|
|
} |
2100
|
|
|
|
2101
|
|
|
return fmt.Sprintf( |
2102
|
|
|
"invalid %sRelationReference.%s: %s%s", |
2103
|
|
|
key, |
2104
|
|
|
e.field, |
2105
|
|
|
e.reason, |
2106
|
|
|
cause) |
2107
|
|
|
} |
2108
|
|
|
|
2109
|
|
|
var _ error = RelationReferenceValidationError{} |
2110
|
|
|
|
2111
|
|
|
var _ interface { |
2112
|
|
|
Field() string |
2113
|
|
|
Reason() string |
2114
|
|
|
Key() bool |
2115
|
|
|
Cause() error |
2116
|
|
|
ErrorName() string |
2117
|
|
|
} = RelationReferenceValidationError{} |
2118
|
|
|
|
2119
|
|
|
var _RelationReference_Type_Pattern = regexp.MustCompile("^[a-zA-Z_]{1,64}$") |
2120
|
|
|
|
2121
|
|
|
var _RelationReference_Relation_Pattern = regexp.MustCompile("^[a-zA-Z_]{1,64}$") |
2122
|
|
|
|
2123
|
|
|
// Validate checks the field values on Entrance with the rules defined in the |
2124
|
|
|
// proto definition for this message. If any rules are violated, the first |
2125
|
|
|
// error encountered is returned, or nil if there are no violations. |
2126
|
|
|
func (m *Entrance) Validate() error { |
2127
|
|
|
return m.validate(false) |
2128
|
|
|
} |
2129
|
|
|
|
2130
|
|
|
// ValidateAll checks the field values on Entrance with the rules defined in |
2131
|
|
|
// the proto definition for this message. If any rules are violated, the |
2132
|
|
|
// result is a list of violation errors wrapped in EntranceMultiError, or nil |
2133
|
|
|
// if none found. |
2134
|
|
|
func (m *Entrance) ValidateAll() error { |
2135
|
|
|
return m.validate(true) |
2136
|
|
|
} |
2137
|
|
|
|
2138
|
|
|
func (m *Entrance) validate(all bool) error { |
2139
|
|
|
if m == nil { |
2140
|
|
|
return nil |
2141
|
|
|
} |
2142
|
|
|
|
2143
|
|
|
var errors []error |
2144
|
|
|
|
2145
|
|
|
if len(m.GetType()) > 64 { |
2146
|
|
|
err := EntranceValidationError{ |
2147
|
|
|
field: "Type", |
2148
|
|
|
reason: "value length must be at most 64 bytes", |
2149
|
|
|
} |
2150
|
|
|
if !all { |
2151
|
|
|
return err |
2152
|
|
|
} |
2153
|
|
|
errors = append(errors, err) |
2154
|
|
|
} |
2155
|
|
|
|
2156
|
|
|
if !_Entrance_Type_Pattern.MatchString(m.GetType()) { |
2157
|
|
|
err := EntranceValidationError{ |
2158
|
|
|
field: "Type", |
2159
|
|
|
reason: "value does not match regex pattern \"^[a-zA-Z_]{1,64}$\"", |
2160
|
|
|
} |
2161
|
|
|
if !all { |
2162
|
|
|
return err |
2163
|
|
|
} |
2164
|
|
|
errors = append(errors, err) |
2165
|
|
|
} |
2166
|
|
|
|
2167
|
|
|
if len(m.GetValue()) > 64 { |
2168
|
|
|
err := EntranceValidationError{ |
2169
|
|
|
field: "Value", |
2170
|
|
|
reason: "value length must be at most 64 bytes", |
2171
|
|
|
} |
2172
|
|
|
if !all { |
2173
|
|
|
return err |
2174
|
|
|
} |
2175
|
|
|
errors = append(errors, err) |
2176
|
|
|
} |
2177
|
|
|
|
2178
|
|
|
if !_Entrance_Value_Pattern.MatchString(m.GetValue()) { |
2179
|
|
|
err := EntranceValidationError{ |
2180
|
|
|
field: "Value", |
2181
|
|
|
reason: "value does not match regex pattern \"^[a-zA-Z_]{1,64}$\"", |
2182
|
|
|
} |
2183
|
|
|
if !all { |
2184
|
|
|
return err |
2185
|
|
|
} |
2186
|
|
|
errors = append(errors, err) |
2187
|
|
|
} |
2188
|
|
|
|
2189
|
|
|
if len(errors) > 0 { |
2190
|
|
|
return EntranceMultiError(errors) |
2191
|
|
|
} |
2192
|
|
|
|
2193
|
|
|
return nil |
2194
|
|
|
} |
2195
|
|
|
|
2196
|
|
|
// EntranceMultiError is an error wrapping multiple validation errors returned |
2197
|
|
|
// by Entrance.ValidateAll() if the designated constraints aren't met. |
2198
|
|
|
type EntranceMultiError []error |
2199
|
|
|
|
2200
|
|
|
// Error returns a concatenation of all the error messages it wraps. |
2201
|
|
|
func (m EntranceMultiError) Error() string { |
2202
|
|
|
var msgs []string |
2203
|
|
|
for _, err := range m { |
2204
|
|
|
msgs = append(msgs, err.Error()) |
2205
|
|
|
} |
2206
|
|
|
return strings.Join(msgs, "; ") |
2207
|
|
|
} |
2208
|
|
|
|
2209
|
|
|
// AllErrors returns a list of validation violation errors. |
2210
|
|
|
func (m EntranceMultiError) AllErrors() []error { return m } |
2211
|
|
|
|
2212
|
|
|
// EntranceValidationError is the validation error returned by |
2213
|
|
|
// Entrance.Validate if the designated constraints aren't met. |
2214
|
|
|
type EntranceValidationError struct { |
2215
|
|
|
field string |
2216
|
|
|
reason string |
2217
|
|
|
cause error |
2218
|
|
|
key bool |
2219
|
|
|
} |
2220
|
|
|
|
2221
|
|
|
// Field function returns field value. |
2222
|
|
|
func (e EntranceValidationError) Field() string { return e.field } |
2223
|
|
|
|
2224
|
|
|
// Reason function returns reason value. |
2225
|
|
|
func (e EntranceValidationError) Reason() string { return e.reason } |
2226
|
|
|
|
2227
|
|
|
// Cause function returns cause value. |
2228
|
|
|
func (e EntranceValidationError) Cause() error { return e.cause } |
2229
|
|
|
|
2230
|
|
|
// Key function returns key value. |
2231
|
|
|
func (e EntranceValidationError) Key() bool { return e.key } |
2232
|
|
|
|
2233
|
|
|
// ErrorName returns error name. |
2234
|
|
|
func (e EntranceValidationError) ErrorName() string { return "EntranceValidationError" } |
2235
|
|
|
|
2236
|
|
|
// Error satisfies the builtin error interface |
2237
|
|
|
func (e EntranceValidationError) Error() string { |
2238
|
|
|
cause := "" |
2239
|
|
|
if e.cause != nil { |
2240
|
|
|
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
2241
|
|
|
} |
2242
|
|
|
|
2243
|
|
|
key := "" |
2244
|
|
|
if e.key { |
2245
|
|
|
key = "key for " |
2246
|
|
|
} |
2247
|
|
|
|
2248
|
|
|
return fmt.Sprintf( |
2249
|
|
|
"invalid %sEntrance.%s: %s%s", |
2250
|
|
|
key, |
2251
|
|
|
e.field, |
2252
|
|
|
e.reason, |
2253
|
|
|
cause) |
2254
|
|
|
} |
2255
|
|
|
|
2256
|
|
|
var _ error = EntranceValidationError{} |
2257
|
|
|
|
2258
|
|
|
var _ interface { |
2259
|
|
|
Field() string |
2260
|
|
|
Reason() string |
2261
|
|
|
Key() bool |
2262
|
|
|
Cause() error |
2263
|
|
|
ErrorName() string |
2264
|
|
|
} = EntranceValidationError{} |
2265
|
|
|
|
2266
|
|
|
var _Entrance_Type_Pattern = regexp.MustCompile("^[a-zA-Z_]{1,64}$") |
2267
|
|
|
|
2268
|
|
|
var _Entrance_Value_Pattern = regexp.MustCompile("^[a-zA-Z_]{1,64}$") |
2269
|
|
|
|
2270
|
|
|
// Validate checks the field values on Argument with the rules defined in the |
2271
|
|
|
// proto definition for this message. If any rules are violated, the first |
2272
|
|
|
// error encountered is returned, or nil if there are no violations. |
2273
|
|
|
func (m *Argument) Validate() error { |
2274
|
|
|
return m.validate(false) |
2275
|
|
|
} |
2276
|
|
|
|
2277
|
|
|
// ValidateAll checks the field values on Argument with the rules defined in |
2278
|
|
|
// the proto definition for this message. If any rules are violated, the |
2279
|
|
|
// result is a list of violation errors wrapped in ArgumentMultiError, or nil |
2280
|
|
|
// if none found. |
2281
|
|
|
func (m *Argument) ValidateAll() error { |
2282
|
|
|
return m.validate(true) |
2283
|
|
|
} |
2284
|
|
|
|
2285
|
|
|
func (m *Argument) validate(all bool) error { |
2286
|
|
|
if m == nil { |
2287
|
|
|
return nil |
2288
|
|
|
} |
2289
|
|
|
|
2290
|
|
|
var errors []error |
2291
|
|
|
|
2292
|
|
|
switch v := m.Type.(type) { |
2293
|
|
|
case *Argument_ComputedAttribute: |
2294
|
|
|
if v == nil { |
2295
|
|
|
err := ArgumentValidationError{ |
2296
|
|
|
field: "Type", |
2297
|
|
|
reason: "oneof value cannot be a typed-nil", |
2298
|
|
|
} |
2299
|
|
|
if !all { |
2300
|
|
|
return err |
2301
|
|
|
} |
2302
|
|
|
errors = append(errors, err) |
2303
|
|
|
} |
2304
|
|
|
|
2305
|
|
|
if all { |
2306
|
|
|
switch v := interface{}(m.GetComputedAttribute()).(type) { |
2307
|
|
|
case interface{ ValidateAll() error }: |
2308
|
|
|
if err := v.ValidateAll(); err != nil { |
2309
|
|
|
errors = append(errors, ArgumentValidationError{ |
2310
|
|
|
field: "ComputedAttribute", |
2311
|
|
|
reason: "embedded message failed validation", |
2312
|
|
|
cause: err, |
2313
|
|
|
}) |
2314
|
|
|
} |
2315
|
|
|
case interface{ Validate() error }: |
2316
|
|
|
if err := v.Validate(); err != nil { |
2317
|
|
|
errors = append(errors, ArgumentValidationError{ |
2318
|
|
|
field: "ComputedAttribute", |
2319
|
|
|
reason: "embedded message failed validation", |
2320
|
|
|
cause: err, |
2321
|
|
|
}) |
2322
|
|
|
} |
2323
|
|
|
} |
2324
|
|
|
} else if v, ok := interface{}(m.GetComputedAttribute()).(interface{ Validate() error }); ok { |
2325
|
|
|
if err := v.Validate(); err != nil { |
2326
|
|
|
return ArgumentValidationError{ |
2327
|
|
|
field: "ComputedAttribute", |
2328
|
|
|
reason: "embedded message failed validation", |
2329
|
|
|
cause: err, |
2330
|
|
|
} |
2331
|
|
|
} |
2332
|
|
|
} |
2333
|
|
|
|
2334
|
|
|
default: |
2335
|
|
|
_ = v // ensures v is used |
2336
|
|
|
} |
2337
|
|
|
|
2338
|
|
|
if len(errors) > 0 { |
2339
|
|
|
return ArgumentMultiError(errors) |
2340
|
|
|
} |
2341
|
|
|
|
2342
|
|
|
return nil |
2343
|
|
|
} |
2344
|
|
|
|
2345
|
|
|
// ArgumentMultiError is an error wrapping multiple validation errors returned |
2346
|
|
|
// by Argument.ValidateAll() if the designated constraints aren't met. |
2347
|
|
|
type ArgumentMultiError []error |
2348
|
|
|
|
2349
|
|
|
// Error returns a concatenation of all the error messages it wraps. |
2350
|
|
|
func (m ArgumentMultiError) Error() string { |
2351
|
|
|
var msgs []string |
2352
|
|
|
for _, err := range m { |
2353
|
|
|
msgs = append(msgs, err.Error()) |
2354
|
|
|
} |
2355
|
|
|
return strings.Join(msgs, "; ") |
2356
|
|
|
} |
2357
|
|
|
|
2358
|
|
|
// AllErrors returns a list of validation violation errors. |
2359
|
|
|
func (m ArgumentMultiError) AllErrors() []error { return m } |
2360
|
|
|
|
2361
|
|
|
// ArgumentValidationError is the validation error returned by |
2362
|
|
|
// Argument.Validate if the designated constraints aren't met. |
2363
|
|
|
type ArgumentValidationError struct { |
2364
|
|
|
field string |
2365
|
|
|
reason string |
2366
|
|
|
cause error |
2367
|
|
|
key bool |
2368
|
|
|
} |
2369
|
|
|
|
2370
|
|
|
// Field function returns field value. |
2371
|
|
|
func (e ArgumentValidationError) Field() string { return e.field } |
2372
|
|
|
|
2373
|
|
|
// Reason function returns reason value. |
2374
|
|
|
func (e ArgumentValidationError) Reason() string { return e.reason } |
2375
|
|
|
|
2376
|
|
|
// Cause function returns cause value. |
2377
|
|
|
func (e ArgumentValidationError) Cause() error { return e.cause } |
2378
|
|
|
|
2379
|
|
|
// Key function returns key value. |
2380
|
|
|
func (e ArgumentValidationError) Key() bool { return e.key } |
2381
|
|
|
|
2382
|
|
|
// ErrorName returns error name. |
2383
|
|
|
func (e ArgumentValidationError) ErrorName() string { return "ArgumentValidationError" } |
2384
|
|
|
|
2385
|
|
|
// Error satisfies the builtin error interface |
2386
|
|
|
func (e ArgumentValidationError) Error() string { |
2387
|
|
|
cause := "" |
2388
|
|
|
if e.cause != nil { |
2389
|
|
|
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
2390
|
|
|
} |
2391
|
|
|
|
2392
|
|
|
key := "" |
2393
|
|
|
if e.key { |
2394
|
|
|
key = "key for " |
2395
|
|
|
} |
2396
|
|
|
|
2397
|
|
|
return fmt.Sprintf( |
2398
|
|
|
"invalid %sArgument.%s: %s%s", |
2399
|
|
|
key, |
2400
|
|
|
e.field, |
2401
|
|
|
e.reason, |
2402
|
|
|
cause) |
2403
|
|
|
} |
2404
|
|
|
|
2405
|
|
|
var _ error = ArgumentValidationError{} |
2406
|
|
|
|
2407
|
|
|
var _ interface { |
2408
|
|
|
Field() string |
2409
|
|
|
Reason() string |
2410
|
|
|
Key() bool |
2411
|
|
|
Cause() error |
2412
|
|
|
ErrorName() string |
2413
|
|
|
} = ArgumentValidationError{} |
2414
|
|
|
|
2415
|
|
|
// Validate checks the field values on Call with the rules defined in the proto |
2416
|
|
|
// definition for this message. If any rules are violated, the first error |
2417
|
|
|
// encountered is returned, or nil if there are no violations. |
2418
|
|
|
func (m *Call) Validate() error { |
2419
|
|
|
return m.validate(false) |
2420
|
|
|
} |
2421
|
|
|
|
2422
|
|
|
// ValidateAll checks the field values on Call with the rules defined in the |
2423
|
|
|
// proto definition for this message. If any rules are violated, the result is |
2424
|
|
|
// a list of violation errors wrapped in CallMultiError, or nil if none found. |
2425
|
|
|
func (m *Call) ValidateAll() error { |
2426
|
|
|
return m.validate(true) |
2427
|
|
|
} |
2428
|
|
|
|
2429
|
|
|
func (m *Call) validate(all bool) error { |
2430
|
|
|
if m == nil { |
2431
|
|
|
return nil |
2432
|
|
|
} |
2433
|
|
|
|
2434
|
|
|
var errors []error |
2435
|
|
|
|
2436
|
|
|
// no validation rules for RuleName |
2437
|
|
|
|
2438
|
|
|
for idx, item := range m.GetArguments() { |
2439
|
|
|
_, _ = idx, item |
2440
|
|
|
|
2441
|
|
|
if all { |
2442
|
|
|
switch v := interface{}(item).(type) { |
2443
|
|
|
case interface{ ValidateAll() error }: |
2444
|
|
|
if err := v.ValidateAll(); err != nil { |
2445
|
|
|
errors = append(errors, CallValidationError{ |
2446
|
|
|
field: fmt.Sprintf("Arguments[%v]", idx), |
2447
|
|
|
reason: "embedded message failed validation", |
2448
|
|
|
cause: err, |
2449
|
|
|
}) |
2450
|
|
|
} |
2451
|
|
|
case interface{ Validate() error }: |
2452
|
|
|
if err := v.Validate(); err != nil { |
2453
|
|
|
errors = append(errors, CallValidationError{ |
2454
|
|
|
field: fmt.Sprintf("Arguments[%v]", idx), |
2455
|
|
|
reason: "embedded message failed validation", |
2456
|
|
|
cause: err, |
2457
|
|
|
}) |
2458
|
|
|
} |
2459
|
|
|
} |
2460
|
|
|
} else if v, ok := interface{}(item).(interface{ Validate() error }); ok { |
2461
|
|
|
if err := v.Validate(); err != nil { |
2462
|
|
|
return CallValidationError{ |
2463
|
|
|
field: fmt.Sprintf("Arguments[%v]", idx), |
2464
|
|
|
reason: "embedded message failed validation", |
2465
|
|
|
cause: err, |
2466
|
|
|
} |
2467
|
|
|
} |
2468
|
|
|
} |
2469
|
|
|
|
2470
|
|
|
} |
2471
|
|
|
|
2472
|
|
|
if len(errors) > 0 { |
2473
|
|
|
return CallMultiError(errors) |
2474
|
|
|
} |
2475
|
|
|
|
2476
|
|
|
return nil |
2477
|
|
|
} |
2478
|
|
|
|
2479
|
|
|
// CallMultiError is an error wrapping multiple validation errors returned by |
2480
|
|
|
// Call.ValidateAll() if the designated constraints aren't met. |
2481
|
|
|
type CallMultiError []error |
2482
|
|
|
|
2483
|
|
|
// Error returns a concatenation of all the error messages it wraps. |
2484
|
|
|
func (m CallMultiError) Error() string { |
2485
|
|
|
var msgs []string |
2486
|
|
|
for _, err := range m { |
2487
|
|
|
msgs = append(msgs, err.Error()) |
2488
|
|
|
} |
2489
|
|
|
return strings.Join(msgs, "; ") |
2490
|
|
|
} |
2491
|
|
|
|
2492
|
|
|
// AllErrors returns a list of validation violation errors. |
2493
|
|
|
func (m CallMultiError) AllErrors() []error { return m } |
2494
|
|
|
|
2495
|
|
|
// CallValidationError is the validation error returned by Call.Validate if the |
2496
|
|
|
// designated constraints aren't met. |
2497
|
|
|
type CallValidationError struct { |
2498
|
|
|
field string |
2499
|
|
|
reason string |
2500
|
|
|
cause error |
2501
|
|
|
key bool |
2502
|
|
|
} |
2503
|
|
|
|
2504
|
|
|
// Field function returns field value. |
2505
|
|
|
func (e CallValidationError) Field() string { return e.field } |
2506
|
|
|
|
2507
|
|
|
// Reason function returns reason value. |
2508
|
|
|
func (e CallValidationError) Reason() string { return e.reason } |
2509
|
|
|
|
2510
|
|
|
// Cause function returns cause value. |
2511
|
|
|
func (e CallValidationError) Cause() error { return e.cause } |
2512
|
|
|
|
2513
|
|
|
// Key function returns key value. |
2514
|
|
|
func (e CallValidationError) Key() bool { return e.key } |
2515
|
|
|
|
2516
|
|
|
// ErrorName returns error name. |
2517
|
|
|
func (e CallValidationError) ErrorName() string { return "CallValidationError" } |
2518
|
|
|
|
2519
|
|
|
// Error satisfies the builtin error interface |
2520
|
|
|
func (e CallValidationError) Error() string { |
2521
|
|
|
cause := "" |
2522
|
|
|
if e.cause != nil { |
2523
|
|
|
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
2524
|
|
|
} |
2525
|
|
|
|
2526
|
|
|
key := "" |
2527
|
|
|
if e.key { |
2528
|
|
|
key = "key for " |
2529
|
|
|
} |
2530
|
|
|
|
2531
|
|
|
return fmt.Sprintf( |
2532
|
|
|
"invalid %sCall.%s: %s%s", |
2533
|
|
|
key, |
2534
|
|
|
e.field, |
2535
|
|
|
e.reason, |
2536
|
|
|
cause) |
2537
|
|
|
} |
2538
|
|
|
|
2539
|
|
|
var _ error = CallValidationError{} |
2540
|
|
|
|
2541
|
|
|
var _ interface { |
2542
|
|
|
Field() string |
2543
|
|
|
Reason() string |
2544
|
|
|
Key() bool |
2545
|
|
|
Cause() error |
2546
|
|
|
ErrorName() string |
2547
|
|
|
} = CallValidationError{} |
2548
|
|
|
|
2549
|
|
|
// Validate checks the field values on ComputedAttribute with the rules defined |
2550
|
|
|
// in the proto definition for this message. If any rules are violated, the |
2551
|
|
|
// first error encountered is returned, or nil if there are no violations. |
2552
|
|
|
func (m *ComputedAttribute) Validate() error { |
2553
|
|
|
return m.validate(false) |
2554
|
|
|
} |
2555
|
|
|
|
2556
|
|
|
// ValidateAll checks the field values on ComputedAttribute with the rules |
2557
|
|
|
// defined in the proto definition for this message. If any rules are |
2558
|
|
|
// violated, the result is a list of violation errors wrapped in |
2559
|
|
|
// ComputedAttributeMultiError, or nil if none found. |
2560
|
|
|
func (m *ComputedAttribute) ValidateAll() error { |
2561
|
|
|
return m.validate(true) |
2562
|
|
|
} |
2563
|
|
|
|
2564
|
|
|
func (m *ComputedAttribute) validate(all bool) error { |
2565
|
|
|
if m == nil { |
2566
|
|
|
return nil |
2567
|
|
|
} |
2568
|
|
|
|
2569
|
|
|
var errors []error |
2570
|
|
|
|
2571
|
|
|
if len(m.GetName()) > 64 { |
2572
|
|
|
err := ComputedAttributeValidationError{ |
2573
|
|
|
field: "Name", |
2574
|
|
|
reason: "value length must be at most 64 bytes", |
2575
|
|
|
} |
2576
|
|
|
if !all { |
2577
|
|
|
return err |
2578
|
|
|
} |
2579
|
|
|
errors = append(errors, err) |
2580
|
|
|
} |
2581
|
|
|
|
2582
|
|
|
if !_ComputedAttribute_Name_Pattern.MatchString(m.GetName()) { |
2583
|
|
|
err := ComputedAttributeValidationError{ |
2584
|
|
|
field: "Name", |
2585
|
|
|
reason: "value does not match regex pattern \"^[a-zA-Z_]{1,64}$\"", |
2586
|
|
|
} |
2587
|
|
|
if !all { |
2588
|
|
|
return err |
2589
|
|
|
} |
2590
|
|
|
errors = append(errors, err) |
2591
|
|
|
} |
2592
|
|
|
|
2593
|
|
|
if len(errors) > 0 { |
2594
|
|
|
return ComputedAttributeMultiError(errors) |
2595
|
|
|
} |
2596
|
|
|
|
2597
|
|
|
return nil |
2598
|
|
|
} |
2599
|
|
|
|
2600
|
|
|
// ComputedAttributeMultiError is an error wrapping multiple validation errors |
2601
|
|
|
// returned by ComputedAttribute.ValidateAll() if the designated constraints |
2602
|
|
|
// aren't met. |
2603
|
|
|
type ComputedAttributeMultiError []error |
2604
|
|
|
|
2605
|
|
|
// Error returns a concatenation of all the error messages it wraps. |
2606
|
|
|
func (m ComputedAttributeMultiError) Error() string { |
2607
|
|
|
var msgs []string |
2608
|
|
|
for _, err := range m { |
2609
|
|
|
msgs = append(msgs, err.Error()) |
2610
|
|
|
} |
2611
|
|
|
return strings.Join(msgs, "; ") |
2612
|
|
|
} |
2613
|
|
|
|
2614
|
|
|
// AllErrors returns a list of validation violation errors. |
2615
|
|
|
func (m ComputedAttributeMultiError) AllErrors() []error { return m } |
2616
|
|
|
|
2617
|
|
|
// ComputedAttributeValidationError is the validation error returned by |
2618
|
|
|
// ComputedAttribute.Validate if the designated constraints aren't met. |
2619
|
|
|
type ComputedAttributeValidationError struct { |
2620
|
|
|
field string |
2621
|
|
|
reason string |
2622
|
|
|
cause error |
2623
|
|
|
key bool |
2624
|
|
|
} |
2625
|
|
|
|
2626
|
|
|
// Field function returns field value. |
2627
|
|
|
func (e ComputedAttributeValidationError) Field() string { return e.field } |
2628
|
|
|
|
2629
|
|
|
// Reason function returns reason value. |
2630
|
|
|
func (e ComputedAttributeValidationError) Reason() string { return e.reason } |
2631
|
|
|
|
2632
|
|
|
// Cause function returns cause value. |
2633
|
|
|
func (e ComputedAttributeValidationError) Cause() error { return e.cause } |
2634
|
|
|
|
2635
|
|
|
// Key function returns key value. |
2636
|
|
|
func (e ComputedAttributeValidationError) Key() bool { return e.key } |
2637
|
|
|
|
2638
|
|
|
// ErrorName returns error name. |
2639
|
|
|
func (e ComputedAttributeValidationError) ErrorName() string { |
2640
|
|
|
return "ComputedAttributeValidationError" |
2641
|
|
|
} |
2642
|
|
|
|
2643
|
|
|
// Error satisfies the builtin error interface |
2644
|
|
|
func (e ComputedAttributeValidationError) Error() string { |
2645
|
|
|
cause := "" |
2646
|
|
|
if e.cause != nil { |
2647
|
|
|
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
2648
|
|
|
} |
2649
|
|
|
|
2650
|
|
|
key := "" |
2651
|
|
|
if e.key { |
2652
|
|
|
key = "key for " |
2653
|
|
|
} |
2654
|
|
|
|
2655
|
|
|
return fmt.Sprintf( |
2656
|
|
|
"invalid %sComputedAttribute.%s: %s%s", |
2657
|
|
|
key, |
2658
|
|
|
e.field, |
2659
|
|
|
e.reason, |
2660
|
|
|
cause) |
2661
|
|
|
} |
2662
|
|
|
|
2663
|
|
|
var _ error = ComputedAttributeValidationError{} |
2664
|
|
|
|
2665
|
|
|
var _ interface { |
2666
|
|
|
Field() string |
2667
|
|
|
Reason() string |
2668
|
|
|
Key() bool |
2669
|
|
|
Cause() error |
2670
|
|
|
ErrorName() string |
2671
|
|
|
} = ComputedAttributeValidationError{} |
2672
|
|
|
|
2673
|
|
|
var _ComputedAttribute_Name_Pattern = regexp.MustCompile("^[a-zA-Z_]{1,64}$") |
2674
|
|
|
|
2675
|
|
|
// Validate checks the field values on ComputedUserSet with the rules defined |
2676
|
|
|
// in the proto definition for this message. If any rules are violated, the |
2677
|
|
|
// first error encountered is returned, or nil if there are no violations. |
2678
|
|
|
func (m *ComputedUserSet) Validate() error { |
2679
|
|
|
return m.validate(false) |
2680
|
|
|
} |
2681
|
|
|
|
2682
|
|
|
// ValidateAll checks the field values on ComputedUserSet with the rules |
2683
|
|
|
// defined in the proto definition for this message. If any rules are |
2684
|
|
|
// violated, the result is a list of violation errors wrapped in |
2685
|
|
|
// ComputedUserSetMultiError, or nil if none found. |
2686
|
|
|
func (m *ComputedUserSet) ValidateAll() error { |
2687
|
|
|
return m.validate(true) |
2688
|
|
|
} |
2689
|
|
|
|
2690
|
|
|
func (m *ComputedUserSet) validate(all bool) error { |
2691
|
|
|
if m == nil { |
2692
|
|
|
return nil |
2693
|
|
|
} |
2694
|
|
|
|
2695
|
|
|
var errors []error |
2696
|
|
|
|
2697
|
|
|
if len(m.GetRelation()) > 64 { |
2698
|
|
|
err := ComputedUserSetValidationError{ |
2699
|
|
|
field: "Relation", |
2700
|
|
|
reason: "value length must be at most 64 bytes", |
2701
|
|
|
} |
2702
|
|
|
if !all { |
2703
|
|
|
return err |
2704
|
|
|
} |
2705
|
|
|
errors = append(errors, err) |
2706
|
|
|
} |
2707
|
|
|
|
2708
|
|
|
if !_ComputedUserSet_Relation_Pattern.MatchString(m.GetRelation()) { |
2709
|
|
|
err := ComputedUserSetValidationError{ |
2710
|
|
|
field: "Relation", |
2711
|
|
|
reason: "value does not match regex pattern \"^[a-zA-Z_]{1,64}$\"", |
2712
|
|
|
} |
2713
|
|
|
if !all { |
2714
|
|
|
return err |
2715
|
|
|
} |
2716
|
|
|
errors = append(errors, err) |
2717
|
|
|
} |
2718
|
|
|
|
2719
|
|
|
if len(errors) > 0 { |
2720
|
|
|
return ComputedUserSetMultiError(errors) |
2721
|
|
|
} |
2722
|
|
|
|
2723
|
|
|
return nil |
2724
|
|
|
} |
2725
|
|
|
|
2726
|
|
|
// ComputedUserSetMultiError is an error wrapping multiple validation errors |
2727
|
|
|
// returned by ComputedUserSet.ValidateAll() if the designated constraints |
2728
|
|
|
// aren't met. |
2729
|
|
|
type ComputedUserSetMultiError []error |
2730
|
|
|
|
2731
|
|
|
// Error returns a concatenation of all the error messages it wraps. |
2732
|
|
|
func (m ComputedUserSetMultiError) Error() string { |
2733
|
|
|
var msgs []string |
2734
|
|
|
for _, err := range m { |
2735
|
|
|
msgs = append(msgs, err.Error()) |
2736
|
|
|
} |
2737
|
|
|
return strings.Join(msgs, "; ") |
2738
|
|
|
} |
2739
|
|
|
|
2740
|
|
|
// AllErrors returns a list of validation violation errors. |
2741
|
|
|
func (m ComputedUserSetMultiError) AllErrors() []error { return m } |
2742
|
|
|
|
2743
|
|
|
// ComputedUserSetValidationError is the validation error returned by |
2744
|
|
|
// ComputedUserSet.Validate if the designated constraints aren't met. |
2745
|
|
|
type ComputedUserSetValidationError struct { |
2746
|
|
|
field string |
2747
|
|
|
reason string |
2748
|
|
|
cause error |
2749
|
|
|
key bool |
2750
|
|
|
} |
2751
|
|
|
|
2752
|
|
|
// Field function returns field value. |
2753
|
|
|
func (e ComputedUserSetValidationError) Field() string { return e.field } |
2754
|
|
|
|
2755
|
|
|
// Reason function returns reason value. |
2756
|
|
|
func (e ComputedUserSetValidationError) Reason() string { return e.reason } |
2757
|
|
|
|
2758
|
|
|
// Cause function returns cause value. |
2759
|
|
|
func (e ComputedUserSetValidationError) Cause() error { return e.cause } |
2760
|
|
|
|
2761
|
|
|
// Key function returns key value. |
2762
|
|
|
func (e ComputedUserSetValidationError) Key() bool { return e.key } |
2763
|
|
|
|
2764
|
|
|
// ErrorName returns error name. |
2765
|
|
|
func (e ComputedUserSetValidationError) ErrorName() string { return "ComputedUserSetValidationError" } |
2766
|
|
|
|
2767
|
|
|
// Error satisfies the builtin error interface |
2768
|
|
|
func (e ComputedUserSetValidationError) Error() string { |
2769
|
|
|
cause := "" |
2770
|
|
|
if e.cause != nil { |
2771
|
|
|
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
2772
|
|
|
} |
2773
|
|
|
|
2774
|
|
|
key := "" |
2775
|
|
|
if e.key { |
2776
|
|
|
key = "key for " |
2777
|
|
|
} |
2778
|
|
|
|
2779
|
|
|
return fmt.Sprintf( |
2780
|
|
|
"invalid %sComputedUserSet.%s: %s%s", |
2781
|
|
|
key, |
2782
|
|
|
e.field, |
2783
|
|
|
e.reason, |
2784
|
|
|
cause) |
2785
|
|
|
} |
2786
|
|
|
|
2787
|
|
|
var _ error = ComputedUserSetValidationError{} |
2788
|
|
|
|
2789
|
|
|
var _ interface { |
2790
|
|
|
Field() string |
2791
|
|
|
Reason() string |
2792
|
|
|
Key() bool |
2793
|
|
|
Cause() error |
2794
|
|
|
ErrorName() string |
2795
|
|
|
} = ComputedUserSetValidationError{} |
2796
|
|
|
|
2797
|
|
|
var _ComputedUserSet_Relation_Pattern = regexp.MustCompile("^[a-zA-Z_]{1,64}$") |
2798
|
|
|
|
2799
|
|
|
// Validate checks the field values on TupleToUserSet with the rules defined in |
2800
|
|
|
// the proto definition for this message. If any rules are violated, the first |
2801
|
|
|
// error encountered is returned, or nil if there are no violations. |
2802
|
|
|
func (m *TupleToUserSet) Validate() error { |
2803
|
|
|
return m.validate(false) |
2804
|
|
|
} |
2805
|
|
|
|
2806
|
|
|
// ValidateAll checks the field values on TupleToUserSet with the rules defined |
2807
|
|
|
// in the proto definition for this message. If any rules are violated, the |
2808
|
|
|
// result is a list of violation errors wrapped in TupleToUserSetMultiError, |
2809
|
|
|
// or nil if none found. |
2810
|
|
|
func (m *TupleToUserSet) ValidateAll() error { |
2811
|
|
|
return m.validate(true) |
2812
|
|
|
} |
2813
|
|
|
|
2814
|
|
|
func (m *TupleToUserSet) validate(all bool) error { |
2815
|
|
|
if m == nil { |
2816
|
|
|
return nil |
2817
|
|
|
} |
2818
|
|
|
|
2819
|
|
|
var errors []error |
2820
|
|
|
|
2821
|
|
|
if all { |
2822
|
|
|
switch v := interface{}(m.GetTupleSet()).(type) { |
2823
|
|
|
case interface{ ValidateAll() error }: |
2824
|
|
|
if err := v.ValidateAll(); err != nil { |
2825
|
|
|
errors = append(errors, TupleToUserSetValidationError{ |
2826
|
|
|
field: "TupleSet", |
2827
|
|
|
reason: "embedded message failed validation", |
2828
|
|
|
cause: err, |
2829
|
|
|
}) |
2830
|
|
|
} |
2831
|
|
|
case interface{ Validate() error }: |
2832
|
|
|
if err := v.Validate(); err != nil { |
2833
|
|
|
errors = append(errors, TupleToUserSetValidationError{ |
2834
|
|
|
field: "TupleSet", |
2835
|
|
|
reason: "embedded message failed validation", |
2836
|
|
|
cause: err, |
2837
|
|
|
}) |
2838
|
|
|
} |
2839
|
|
|
} |
2840
|
|
|
} else if v, ok := interface{}(m.GetTupleSet()).(interface{ Validate() error }); ok { |
2841
|
|
|
if err := v.Validate(); err != nil { |
2842
|
|
|
return TupleToUserSetValidationError{ |
2843
|
|
|
field: "TupleSet", |
2844
|
|
|
reason: "embedded message failed validation", |
2845
|
|
|
cause: err, |
2846
|
|
|
} |
2847
|
|
|
} |
2848
|
|
|
} |
2849
|
|
|
|
2850
|
|
|
if all { |
2851
|
|
|
switch v := interface{}(m.GetComputed()).(type) { |
2852
|
|
|
case interface{ ValidateAll() error }: |
2853
|
|
|
if err := v.ValidateAll(); err != nil { |
2854
|
|
|
errors = append(errors, TupleToUserSetValidationError{ |
2855
|
|
|
field: "Computed", |
2856
|
|
|
reason: "embedded message failed validation", |
2857
|
|
|
cause: err, |
2858
|
|
|
}) |
2859
|
|
|
} |
2860
|
|
|
case interface{ Validate() error }: |
2861
|
|
|
if err := v.Validate(); err != nil { |
2862
|
|
|
errors = append(errors, TupleToUserSetValidationError{ |
2863
|
|
|
field: "Computed", |
2864
|
|
|
reason: "embedded message failed validation", |
2865
|
|
|
cause: err, |
2866
|
|
|
}) |
2867
|
|
|
} |
2868
|
|
|
} |
2869
|
|
|
} else if v, ok := interface{}(m.GetComputed()).(interface{ Validate() error }); ok { |
2870
|
|
|
if err := v.Validate(); err != nil { |
2871
|
|
|
return TupleToUserSetValidationError{ |
2872
|
|
|
field: "Computed", |
2873
|
|
|
reason: "embedded message failed validation", |
2874
|
|
|
cause: err, |
2875
|
|
|
} |
2876
|
|
|
} |
2877
|
|
|
} |
2878
|
|
|
|
2879
|
|
|
if len(errors) > 0 { |
2880
|
|
|
return TupleToUserSetMultiError(errors) |
2881
|
|
|
} |
2882
|
|
|
|
2883
|
|
|
return nil |
2884
|
|
|
} |
2885
|
|
|
|
2886
|
|
|
// TupleToUserSetMultiError is an error wrapping multiple validation errors |
2887
|
|
|
// returned by TupleToUserSet.ValidateAll() if the designated constraints |
2888
|
|
|
// aren't met. |
2889
|
|
|
type TupleToUserSetMultiError []error |
2890
|
|
|
|
2891
|
|
|
// Error returns a concatenation of all the error messages it wraps. |
2892
|
|
|
func (m TupleToUserSetMultiError) Error() string { |
2893
|
|
|
var msgs []string |
2894
|
|
|
for _, err := range m { |
2895
|
|
|
msgs = append(msgs, err.Error()) |
2896
|
|
|
} |
2897
|
|
|
return strings.Join(msgs, "; ") |
2898
|
|
|
} |
2899
|
|
|
|
2900
|
|
|
// AllErrors returns a list of validation violation errors. |
2901
|
|
|
func (m TupleToUserSetMultiError) AllErrors() []error { return m } |
2902
|
|
|
|
2903
|
|
|
// TupleToUserSetValidationError is the validation error returned by |
2904
|
|
|
// TupleToUserSet.Validate if the designated constraints aren't met. |
2905
|
|
|
type TupleToUserSetValidationError struct { |
2906
|
|
|
field string |
2907
|
|
|
reason string |
2908
|
|
|
cause error |
2909
|
|
|
key bool |
2910
|
|
|
} |
2911
|
|
|
|
2912
|
|
|
// Field function returns field value. |
2913
|
|
|
func (e TupleToUserSetValidationError) Field() string { return e.field } |
2914
|
|
|
|
2915
|
|
|
// Reason function returns reason value. |
2916
|
|
|
func (e TupleToUserSetValidationError) Reason() string { return e.reason } |
2917
|
|
|
|
2918
|
|
|
// Cause function returns cause value. |
2919
|
|
|
func (e TupleToUserSetValidationError) Cause() error { return e.cause } |
2920
|
|
|
|
2921
|
|
|
// Key function returns key value. |
2922
|
|
|
func (e TupleToUserSetValidationError) Key() bool { return e.key } |
2923
|
|
|
|
2924
|
|
|
// ErrorName returns error name. |
2925
|
|
|
func (e TupleToUserSetValidationError) ErrorName() string { return "TupleToUserSetValidationError" } |
2926
|
|
|
|
2927
|
|
|
// Error satisfies the builtin error interface |
2928
|
|
|
func (e TupleToUserSetValidationError) Error() string { |
2929
|
|
|
cause := "" |
2930
|
|
|
if e.cause != nil { |
2931
|
|
|
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
2932
|
|
|
} |
2933
|
|
|
|
2934
|
|
|
key := "" |
2935
|
|
|
if e.key { |
2936
|
|
|
key = "key for " |
2937
|
|
|
} |
2938
|
|
|
|
2939
|
|
|
return fmt.Sprintf( |
2940
|
|
|
"invalid %sTupleToUserSet.%s: %s%s", |
2941
|
|
|
key, |
2942
|
|
|
e.field, |
2943
|
|
|
e.reason, |
2944
|
|
|
cause) |
2945
|
|
|
} |
2946
|
|
|
|
2947
|
|
|
var _ error = TupleToUserSetValidationError{} |
2948
|
|
|
|
2949
|
|
|
var _ interface { |
2950
|
|
|
Field() string |
2951
|
|
|
Reason() string |
2952
|
|
|
Key() bool |
2953
|
|
|
Cause() error |
2954
|
|
|
ErrorName() string |
2955
|
|
|
} = TupleToUserSetValidationError{} |
2956
|
|
|
|
2957
|
|
|
// Validate checks the field values on TupleSet with the rules defined in the |
2958
|
|
|
// proto definition for this message. If any rules are violated, the first |
2959
|
|
|
// error encountered is returned, or nil if there are no violations. |
2960
|
|
|
func (m *TupleSet) Validate() error { |
2961
|
|
|
return m.validate(false) |
2962
|
|
|
} |
2963
|
|
|
|
2964
|
|
|
// ValidateAll checks the field values on TupleSet with the rules defined in |
2965
|
|
|
// the proto definition for this message. If any rules are violated, the |
2966
|
|
|
// result is a list of violation errors wrapped in TupleSetMultiError, or nil |
2967
|
|
|
// if none found. |
2968
|
|
|
func (m *TupleSet) ValidateAll() error { |
2969
|
|
|
return m.validate(true) |
2970
|
|
|
} |
2971
|
|
|
|
2972
|
|
|
func (m *TupleSet) validate(all bool) error { |
2973
|
|
|
if m == nil { |
2974
|
|
|
return nil |
2975
|
|
|
} |
2976
|
|
|
|
2977
|
|
|
var errors []error |
2978
|
|
|
|
2979
|
|
|
if len(m.GetRelation()) > 64 { |
2980
|
|
|
err := TupleSetValidationError{ |
2981
|
|
|
field: "Relation", |
2982
|
|
|
reason: "value length must be at most 64 bytes", |
2983
|
|
|
} |
2984
|
|
|
if !all { |
2985
|
|
|
return err |
2986
|
|
|
} |
2987
|
|
|
errors = append(errors, err) |
2988
|
|
|
} |
2989
|
|
|
|
2990
|
|
|
if !_TupleSet_Relation_Pattern.MatchString(m.GetRelation()) { |
2991
|
|
|
err := TupleSetValidationError{ |
2992
|
|
|
field: "Relation", |
2993
|
|
|
reason: "value does not match regex pattern \"^[a-zA-Z_]{1,64}$\"", |
2994
|
|
|
} |
2995
|
|
|
if !all { |
2996
|
|
|
return err |
2997
|
|
|
} |
2998
|
|
|
errors = append(errors, err) |
2999
|
|
|
} |
3000
|
|
|
|
3001
|
|
|
if len(errors) > 0 { |
3002
|
|
|
return TupleSetMultiError(errors) |
3003
|
|
|
} |
3004
|
|
|
|
3005
|
|
|
return nil |
3006
|
|
|
} |
3007
|
|
|
|
3008
|
|
|
// TupleSetMultiError is an error wrapping multiple validation errors returned |
3009
|
|
|
// by TupleSet.ValidateAll() if the designated constraints aren't met. |
3010
|
|
|
type TupleSetMultiError []error |
3011
|
|
|
|
3012
|
|
|
// Error returns a concatenation of all the error messages it wraps. |
3013
|
|
|
func (m TupleSetMultiError) Error() string { |
3014
|
|
|
var msgs []string |
3015
|
|
|
for _, err := range m { |
3016
|
|
|
msgs = append(msgs, err.Error()) |
3017
|
|
|
} |
3018
|
|
|
return strings.Join(msgs, "; ") |
3019
|
|
|
} |
3020
|
|
|
|
3021
|
|
|
// AllErrors returns a list of validation violation errors. |
3022
|
|
|
func (m TupleSetMultiError) AllErrors() []error { return m } |
3023
|
|
|
|
3024
|
|
|
// TupleSetValidationError is the validation error returned by |
3025
|
|
|
// TupleSet.Validate if the designated constraints aren't met. |
3026
|
|
|
type TupleSetValidationError struct { |
3027
|
|
|
field string |
3028
|
|
|
reason string |
3029
|
|
|
cause error |
3030
|
|
|
key bool |
3031
|
|
|
} |
3032
|
|
|
|
3033
|
|
|
// Field function returns field value. |
3034
|
|
|
func (e TupleSetValidationError) Field() string { return e.field } |
3035
|
|
|
|
3036
|
|
|
// Reason function returns reason value. |
3037
|
|
|
func (e TupleSetValidationError) Reason() string { return e.reason } |
3038
|
|
|
|
3039
|
|
|
// Cause function returns cause value. |
3040
|
|
|
func (e TupleSetValidationError) Cause() error { return e.cause } |
3041
|
|
|
|
3042
|
|
|
// Key function returns key value. |
3043
|
|
|
func (e TupleSetValidationError) Key() bool { return e.key } |
3044
|
|
|
|
3045
|
|
|
// ErrorName returns error name. |
3046
|
|
|
func (e TupleSetValidationError) ErrorName() string { return "TupleSetValidationError" } |
3047
|
|
|
|
3048
|
|
|
// Error satisfies the builtin error interface |
3049
|
|
|
func (e TupleSetValidationError) Error() string { |
3050
|
|
|
cause := "" |
3051
|
|
|
if e.cause != nil { |
3052
|
|
|
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
3053
|
|
|
} |
3054
|
|
|
|
3055
|
|
|
key := "" |
3056
|
|
|
if e.key { |
3057
|
|
|
key = "key for " |
3058
|
|
|
} |
3059
|
|
|
|
3060
|
|
|
return fmt.Sprintf( |
3061
|
|
|
"invalid %sTupleSet.%s: %s%s", |
3062
|
|
|
key, |
3063
|
|
|
e.field, |
3064
|
|
|
e.reason, |
3065
|
|
|
cause) |
3066
|
|
|
} |
3067
|
|
|
|
3068
|
|
|
var _ error = TupleSetValidationError{} |
3069
|
|
|
|
3070
|
|
|
var _ interface { |
3071
|
|
|
Field() string |
3072
|
|
|
Reason() string |
3073
|
|
|
Key() bool |
3074
|
|
|
Cause() error |
3075
|
|
|
ErrorName() string |
3076
|
|
|
} = TupleSetValidationError{} |
3077
|
|
|
|
3078
|
|
|
var _TupleSet_Relation_Pattern = regexp.MustCompile("^[a-zA-Z_]{1,64}$") |
3079
|
|
|
|
3080
|
|
|
// Validate checks the field values on Tuple with the rules defined in the |
3081
|
|
|
// proto definition for this message. If any rules are violated, the first |
3082
|
|
|
// error encountered is returned, or nil if there are no violations. |
3083
|
|
|
func (m *Tuple) Validate() error { |
3084
|
|
|
return m.validate(false) |
3085
|
|
|
} |
3086
|
|
|
|
3087
|
|
|
// ValidateAll checks the field values on Tuple with the rules defined in the |
3088
|
|
|
// proto definition for this message. If any rules are violated, the result is |
3089
|
|
|
// a list of violation errors wrapped in TupleMultiError, or nil if none found. |
3090
|
|
|
func (m *Tuple) ValidateAll() error { |
3091
|
|
|
return m.validate(true) |
3092
|
|
|
} |
3093
|
|
|
|
3094
|
|
|
func (m *Tuple) validate(all bool) error { |
3095
|
|
|
if m == nil { |
3096
|
|
|
return nil |
3097
|
|
|
} |
3098
|
|
|
|
3099
|
|
|
var errors []error |
3100
|
|
|
|
3101
|
|
|
if m.GetEntity() == nil { |
3102
|
|
|
err := TupleValidationError{ |
3103
|
|
|
field: "Entity", |
3104
|
|
|
reason: "value is required", |
3105
|
|
|
} |
3106
|
|
|
if !all { |
3107
|
|
|
return err |
3108
|
|
|
} |
3109
|
|
|
errors = append(errors, err) |
3110
|
|
|
} |
3111
|
|
|
|
3112
|
|
|
if all { |
3113
|
|
|
switch v := interface{}(m.GetEntity()).(type) { |
3114
|
|
|
case interface{ ValidateAll() error }: |
3115
|
|
|
if err := v.ValidateAll(); err != nil { |
3116
|
|
|
errors = append(errors, TupleValidationError{ |
3117
|
|
|
field: "Entity", |
3118
|
|
|
reason: "embedded message failed validation", |
3119
|
|
|
cause: err, |
3120
|
|
|
}) |
3121
|
|
|
} |
3122
|
|
|
case interface{ Validate() error }: |
3123
|
|
|
if err := v.Validate(); err != nil { |
3124
|
|
|
errors = append(errors, TupleValidationError{ |
3125
|
|
|
field: "Entity", |
3126
|
|
|
reason: "embedded message failed validation", |
3127
|
|
|
cause: err, |
3128
|
|
|
}) |
3129
|
|
|
} |
3130
|
|
|
} |
3131
|
|
|
} else if v, ok := interface{}(m.GetEntity()).(interface{ Validate() error }); ok { |
3132
|
|
|
if err := v.Validate(); err != nil { |
3133
|
|
|
return TupleValidationError{ |
3134
|
|
|
field: "Entity", |
3135
|
|
|
reason: "embedded message failed validation", |
3136
|
|
|
cause: err, |
3137
|
|
|
} |
3138
|
|
|
} |
3139
|
|
|
} |
3140
|
|
|
|
3141
|
|
|
if len(m.GetRelation()) > 64 { |
3142
|
|
|
err := TupleValidationError{ |
3143
|
|
|
field: "Relation", |
3144
|
|
|
reason: "value length must be at most 64 bytes", |
3145
|
|
|
} |
3146
|
|
|
if !all { |
3147
|
|
|
return err |
3148
|
|
|
} |
3149
|
|
|
errors = append(errors, err) |
3150
|
|
|
} |
3151
|
|
|
|
3152
|
|
|
if !_Tuple_Relation_Pattern.MatchString(m.GetRelation()) { |
3153
|
|
|
err := TupleValidationError{ |
3154
|
|
|
field: "Relation", |
3155
|
|
|
reason: "value does not match regex pattern \"^[a-zA-Z_]{1,64}$\"", |
3156
|
|
|
} |
3157
|
|
|
if !all { |
3158
|
|
|
return err |
3159
|
|
|
} |
3160
|
|
|
errors = append(errors, err) |
3161
|
|
|
} |
3162
|
|
|
|
3163
|
|
|
if m.GetSubject() == nil { |
3164
|
|
|
err := TupleValidationError{ |
3165
|
|
|
field: "Subject", |
3166
|
|
|
reason: "value is required", |
3167
|
|
|
} |
3168
|
|
|
if !all { |
3169
|
|
|
return err |
3170
|
|
|
} |
3171
|
|
|
errors = append(errors, err) |
3172
|
|
|
} |
3173
|
|
|
|
3174
|
|
|
if all { |
3175
|
|
|
switch v := interface{}(m.GetSubject()).(type) { |
3176
|
|
|
case interface{ ValidateAll() error }: |
3177
|
|
|
if err := v.ValidateAll(); err != nil { |
3178
|
|
|
errors = append(errors, TupleValidationError{ |
3179
|
|
|
field: "Subject", |
3180
|
|
|
reason: "embedded message failed validation", |
3181
|
|
|
cause: err, |
3182
|
|
|
}) |
3183
|
|
|
} |
3184
|
|
|
case interface{ Validate() error }: |
3185
|
|
|
if err := v.Validate(); err != nil { |
3186
|
|
|
errors = append(errors, TupleValidationError{ |
3187
|
|
|
field: "Subject", |
3188
|
|
|
reason: "embedded message failed validation", |
3189
|
|
|
cause: err, |
3190
|
|
|
}) |
3191
|
|
|
} |
3192
|
|
|
} |
3193
|
|
|
} else if v, ok := interface{}(m.GetSubject()).(interface{ Validate() error }); ok { |
3194
|
|
|
if err := v.Validate(); err != nil { |
3195
|
|
|
return TupleValidationError{ |
3196
|
|
|
field: "Subject", |
3197
|
|
|
reason: "embedded message failed validation", |
3198
|
|
|
cause: err, |
3199
|
|
|
} |
3200
|
|
|
} |
3201
|
|
|
} |
3202
|
|
|
|
3203
|
|
|
if len(errors) > 0 { |
3204
|
|
|
return TupleMultiError(errors) |
3205
|
|
|
} |
3206
|
|
|
|
3207
|
|
|
return nil |
3208
|
|
|
} |
3209
|
|
|
|
3210
|
|
|
// TupleMultiError is an error wrapping multiple validation errors returned by |
3211
|
|
|
// Tuple.ValidateAll() if the designated constraints aren't met. |
3212
|
|
|
type TupleMultiError []error |
3213
|
|
|
|
3214
|
|
|
// Error returns a concatenation of all the error messages it wraps. |
3215
|
|
|
func (m TupleMultiError) Error() string { |
3216
|
|
|
var msgs []string |
3217
|
|
|
for _, err := range m { |
3218
|
|
|
msgs = append(msgs, err.Error()) |
3219
|
|
|
} |
3220
|
|
|
return strings.Join(msgs, "; ") |
3221
|
|
|
} |
3222
|
|
|
|
3223
|
|
|
// AllErrors returns a list of validation violation errors. |
3224
|
|
|
func (m TupleMultiError) AllErrors() []error { return m } |
3225
|
|
|
|
3226
|
|
|
// TupleValidationError is the validation error returned by Tuple.Validate if |
3227
|
|
|
// the designated constraints aren't met. |
3228
|
|
|
type TupleValidationError struct { |
3229
|
|
|
field string |
3230
|
|
|
reason string |
3231
|
|
|
cause error |
3232
|
|
|
key bool |
3233
|
|
|
} |
3234
|
|
|
|
3235
|
|
|
// Field function returns field value. |
3236
|
|
|
func (e TupleValidationError) Field() string { return e.field } |
3237
|
|
|
|
3238
|
|
|
// Reason function returns reason value. |
3239
|
|
|
func (e TupleValidationError) Reason() string { return e.reason } |
3240
|
|
|
|
3241
|
|
|
// Cause function returns cause value. |
3242
|
|
|
func (e TupleValidationError) Cause() error { return e.cause } |
3243
|
|
|
|
3244
|
|
|
// Key function returns key value. |
3245
|
|
|
func (e TupleValidationError) Key() bool { return e.key } |
3246
|
|
|
|
3247
|
|
|
// ErrorName returns error name. |
3248
|
|
|
func (e TupleValidationError) ErrorName() string { return "TupleValidationError" } |
3249
|
|
|
|
3250
|
|
|
// Error satisfies the builtin error interface |
3251
|
|
|
func (e TupleValidationError) Error() string { |
3252
|
|
|
cause := "" |
3253
|
|
|
if e.cause != nil { |
3254
|
|
|
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
3255
|
|
|
} |
3256
|
|
|
|
3257
|
|
|
key := "" |
3258
|
|
|
if e.key { |
3259
|
|
|
key = "key for " |
3260
|
|
|
} |
3261
|
|
|
|
3262
|
|
|
return fmt.Sprintf( |
3263
|
|
|
"invalid %sTuple.%s: %s%s", |
3264
|
|
|
key, |
3265
|
|
|
e.field, |
3266
|
|
|
e.reason, |
3267
|
|
|
cause) |
3268
|
|
|
} |
3269
|
|
|
|
3270
|
|
|
var _ error = TupleValidationError{} |
3271
|
|
|
|
3272
|
|
|
var _ interface { |
3273
|
|
|
Field() string |
3274
|
|
|
Reason() string |
3275
|
|
|
Key() bool |
3276
|
|
|
Cause() error |
3277
|
|
|
ErrorName() string |
3278
|
|
|
} = TupleValidationError{} |
3279
|
|
|
|
3280
|
|
|
var _Tuple_Relation_Pattern = regexp.MustCompile("^[a-zA-Z_]{1,64}$") |
3281
|
|
|
|
3282
|
|
|
// Validate checks the field values on Attribute with the rules defined in the |
3283
|
|
|
// proto definition for this message. If any rules are violated, the first |
3284
|
|
|
// error encountered is returned, or nil if there are no violations. |
3285
|
|
|
func (m *Attribute) Validate() error { |
3286
|
|
|
return m.validate(false) |
3287
|
|
|
} |
3288
|
|
|
|
3289
|
|
|
// ValidateAll checks the field values on Attribute with the rules defined in |
3290
|
|
|
// the proto definition for this message. If any rules are violated, the |
3291
|
|
|
// result is a list of violation errors wrapped in AttributeMultiError, or nil |
3292
|
|
|
// if none found. |
3293
|
|
|
func (m *Attribute) ValidateAll() error { |
3294
|
|
|
return m.validate(true) |
3295
|
|
|
} |
3296
|
|
|
|
3297
|
|
|
func (m *Attribute) validate(all bool) error { |
3298
|
|
|
if m == nil { |
3299
|
|
|
return nil |
3300
|
|
|
} |
3301
|
|
|
|
3302
|
|
|
var errors []error |
3303
|
|
|
|
3304
|
|
|
if m.GetEntity() == nil { |
3305
|
|
|
err := AttributeValidationError{ |
3306
|
|
|
field: "Entity", |
3307
|
|
|
reason: "value is required", |
3308
|
|
|
} |
3309
|
|
|
if !all { |
3310
|
|
|
return err |
3311
|
|
|
} |
3312
|
|
|
errors = append(errors, err) |
3313
|
|
|
} |
3314
|
|
|
|
3315
|
|
|
if all { |
3316
|
|
|
switch v := interface{}(m.GetEntity()).(type) { |
3317
|
|
|
case interface{ ValidateAll() error }: |
3318
|
|
|
if err := v.ValidateAll(); err != nil { |
3319
|
|
|
errors = append(errors, AttributeValidationError{ |
3320
|
|
|
field: "Entity", |
3321
|
|
|
reason: "embedded message failed validation", |
3322
|
|
|
cause: err, |
3323
|
|
|
}) |
3324
|
|
|
} |
3325
|
|
|
case interface{ Validate() error }: |
3326
|
|
|
if err := v.Validate(); err != nil { |
3327
|
|
|
errors = append(errors, AttributeValidationError{ |
3328
|
|
|
field: "Entity", |
3329
|
|
|
reason: "embedded message failed validation", |
3330
|
|
|
cause: err, |
3331
|
|
|
}) |
3332
|
|
|
} |
3333
|
|
|
} |
3334
|
|
|
} else if v, ok := interface{}(m.GetEntity()).(interface{ Validate() error }); ok { |
3335
|
|
|
if err := v.Validate(); err != nil { |
3336
|
|
|
return AttributeValidationError{ |
3337
|
|
|
field: "Entity", |
3338
|
|
|
reason: "embedded message failed validation", |
3339
|
|
|
cause: err, |
3340
|
|
|
} |
3341
|
|
|
} |
3342
|
|
|
} |
3343
|
|
|
|
3344
|
|
|
// no validation rules for Attribute |
3345
|
|
|
|
3346
|
|
|
if all { |
3347
|
|
|
switch v := interface{}(m.GetValue()).(type) { |
3348
|
|
|
case interface{ ValidateAll() error }: |
3349
|
|
|
if err := v.ValidateAll(); err != nil { |
3350
|
|
|
errors = append(errors, AttributeValidationError{ |
3351
|
|
|
field: "Value", |
3352
|
|
|
reason: "embedded message failed validation", |
3353
|
|
|
cause: err, |
3354
|
|
|
}) |
3355
|
|
|
} |
3356
|
|
|
case interface{ Validate() error }: |
3357
|
|
|
if err := v.Validate(); err != nil { |
3358
|
|
|
errors = append(errors, AttributeValidationError{ |
3359
|
|
|
field: "Value", |
3360
|
|
|
reason: "embedded message failed validation", |
3361
|
|
|
cause: err, |
3362
|
|
|
}) |
3363
|
|
|
} |
3364
|
|
|
} |
3365
|
|
|
} else if v, ok := interface{}(m.GetValue()).(interface{ Validate() error }); ok { |
3366
|
|
|
if err := v.Validate(); err != nil { |
3367
|
|
|
return AttributeValidationError{ |
3368
|
|
|
field: "Value", |
3369
|
|
|
reason: "embedded message failed validation", |
3370
|
|
|
cause: err, |
3371
|
|
|
} |
3372
|
|
|
} |
3373
|
|
|
} |
3374
|
|
|
|
3375
|
|
|
if len(errors) > 0 { |
3376
|
|
|
return AttributeMultiError(errors) |
3377
|
|
|
} |
3378
|
|
|
|
3379
|
|
|
return nil |
3380
|
|
|
} |
3381
|
|
|
|
3382
|
|
|
// AttributeMultiError is an error wrapping multiple validation errors returned |
3383
|
|
|
// by Attribute.ValidateAll() if the designated constraints aren't met. |
3384
|
|
|
type AttributeMultiError []error |
3385
|
|
|
|
3386
|
|
|
// Error returns a concatenation of all the error messages it wraps. |
3387
|
|
|
func (m AttributeMultiError) Error() string { |
3388
|
|
|
var msgs []string |
3389
|
|
|
for _, err := range m { |
3390
|
|
|
msgs = append(msgs, err.Error()) |
3391
|
|
|
} |
3392
|
|
|
return strings.Join(msgs, "; ") |
3393
|
|
|
} |
3394
|
|
|
|
3395
|
|
|
// AllErrors returns a list of validation violation errors. |
3396
|
|
|
func (m AttributeMultiError) AllErrors() []error { return m } |
3397
|
|
|
|
3398
|
|
|
// AttributeValidationError is the validation error returned by |
3399
|
|
|
// Attribute.Validate if the designated constraints aren't met. |
3400
|
|
|
type AttributeValidationError struct { |
3401
|
|
|
field string |
3402
|
|
|
reason string |
3403
|
|
|
cause error |
3404
|
|
|
key bool |
3405
|
|
|
} |
3406
|
|
|
|
3407
|
|
|
// Field function returns field value. |
3408
|
|
|
func (e AttributeValidationError) Field() string { return e.field } |
3409
|
|
|
|
3410
|
|
|
// Reason function returns reason value. |
3411
|
|
|
func (e AttributeValidationError) Reason() string { return e.reason } |
3412
|
|
|
|
3413
|
|
|
// Cause function returns cause value. |
3414
|
|
|
func (e AttributeValidationError) Cause() error { return e.cause } |
3415
|
|
|
|
3416
|
|
|
// Key function returns key value. |
3417
|
|
|
func (e AttributeValidationError) Key() bool { return e.key } |
3418
|
|
|
|
3419
|
|
|
// ErrorName returns error name. |
3420
|
|
|
func (e AttributeValidationError) ErrorName() string { return "AttributeValidationError" } |
3421
|
|
|
|
3422
|
|
|
// Error satisfies the builtin error interface |
3423
|
|
|
func (e AttributeValidationError) Error() string { |
3424
|
|
|
cause := "" |
3425
|
|
|
if e.cause != nil { |
3426
|
|
|
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
3427
|
|
|
} |
3428
|
|
|
|
3429
|
|
|
key := "" |
3430
|
|
|
if e.key { |
3431
|
|
|
key = "key for " |
3432
|
|
|
} |
3433
|
|
|
|
3434
|
|
|
return fmt.Sprintf( |
3435
|
|
|
"invalid %sAttribute.%s: %s%s", |
3436
|
|
|
key, |
3437
|
|
|
e.field, |
3438
|
|
|
e.reason, |
3439
|
|
|
cause) |
3440
|
|
|
} |
3441
|
|
|
|
3442
|
|
|
var _ error = AttributeValidationError{} |
3443
|
|
|
|
3444
|
|
|
var _ interface { |
3445
|
|
|
Field() string |
3446
|
|
|
Reason() string |
3447
|
|
|
Key() bool |
3448
|
|
|
Cause() error |
3449
|
|
|
ErrorName() string |
3450
|
|
|
} = AttributeValidationError{} |
3451
|
|
|
|
3452
|
|
|
// Validate checks the field values on Tuples with the rules defined in the |
3453
|
|
|
// proto definition for this message. If any rules are violated, the first |
3454
|
|
|
// error encountered is returned, or nil if there are no violations. |
3455
|
|
|
func (m *Tuples) Validate() error { |
3456
|
|
|
return m.validate(false) |
3457
|
|
|
} |
3458
|
|
|
|
3459
|
|
|
// ValidateAll checks the field values on Tuples with the rules defined in the |
3460
|
|
|
// proto definition for this message. If any rules are violated, the result is |
3461
|
|
|
// a list of violation errors wrapped in TuplesMultiError, or nil if none found. |
3462
|
|
|
func (m *Tuples) ValidateAll() error { |
3463
|
|
|
return m.validate(true) |
3464
|
|
|
} |
3465
|
|
|
|
3466
|
|
|
func (m *Tuples) validate(all bool) error { |
3467
|
|
|
if m == nil { |
3468
|
|
|
return nil |
3469
|
|
|
} |
3470
|
|
|
|
3471
|
|
|
var errors []error |
3472
|
|
|
|
3473
|
|
|
for idx, item := range m.GetTuples() { |
3474
|
|
|
_, _ = idx, item |
3475
|
|
|
|
3476
|
|
|
if all { |
3477
|
|
|
switch v := interface{}(item).(type) { |
3478
|
|
|
case interface{ ValidateAll() error }: |
3479
|
|
|
if err := v.ValidateAll(); err != nil { |
3480
|
|
|
errors = append(errors, TuplesValidationError{ |
3481
|
|
|
field: fmt.Sprintf("Tuples[%v]", idx), |
3482
|
|
|
reason: "embedded message failed validation", |
3483
|
|
|
cause: err, |
3484
|
|
|
}) |
3485
|
|
|
} |
3486
|
|
|
case interface{ Validate() error }: |
3487
|
|
|
if err := v.Validate(); err != nil { |
3488
|
|
|
errors = append(errors, TuplesValidationError{ |
3489
|
|
|
field: fmt.Sprintf("Tuples[%v]", idx), |
3490
|
|
|
reason: "embedded message failed validation", |
3491
|
|
|
cause: err, |
3492
|
|
|
}) |
3493
|
|
|
} |
3494
|
|
|
} |
3495
|
|
|
} else if v, ok := interface{}(item).(interface{ Validate() error }); ok { |
3496
|
|
|
if err := v.Validate(); err != nil { |
3497
|
|
|
return TuplesValidationError{ |
3498
|
|
|
field: fmt.Sprintf("Tuples[%v]", idx), |
3499
|
|
|
reason: "embedded message failed validation", |
3500
|
|
|
cause: err, |
3501
|
|
|
} |
3502
|
|
|
} |
3503
|
|
|
} |
3504
|
|
|
|
3505
|
|
|
} |
3506
|
|
|
|
3507
|
|
|
if len(errors) > 0 { |
3508
|
|
|
return TuplesMultiError(errors) |
3509
|
|
|
} |
3510
|
|
|
|
3511
|
|
|
return nil |
3512
|
|
|
} |
3513
|
|
|
|
3514
|
|
|
// TuplesMultiError is an error wrapping multiple validation errors returned by |
3515
|
|
|
// Tuples.ValidateAll() if the designated constraints aren't met. |
3516
|
|
|
type TuplesMultiError []error |
3517
|
|
|
|
3518
|
|
|
// Error returns a concatenation of all the error messages it wraps. |
3519
|
|
|
func (m TuplesMultiError) Error() string { |
3520
|
|
|
var msgs []string |
3521
|
|
|
for _, err := range m { |
3522
|
|
|
msgs = append(msgs, err.Error()) |
3523
|
|
|
} |
3524
|
|
|
return strings.Join(msgs, "; ") |
3525
|
|
|
} |
3526
|
|
|
|
3527
|
|
|
// AllErrors returns a list of validation violation errors. |
3528
|
|
|
func (m TuplesMultiError) AllErrors() []error { return m } |
3529
|
|
|
|
3530
|
|
|
// TuplesValidationError is the validation error returned by Tuples.Validate if |
3531
|
|
|
// the designated constraints aren't met. |
3532
|
|
|
type TuplesValidationError struct { |
3533
|
|
|
field string |
3534
|
|
|
reason string |
3535
|
|
|
cause error |
3536
|
|
|
key bool |
3537
|
|
|
} |
3538
|
|
|
|
3539
|
|
|
// Field function returns field value. |
3540
|
|
|
func (e TuplesValidationError) Field() string { return e.field } |
3541
|
|
|
|
3542
|
|
|
// Reason function returns reason value. |
3543
|
|
|
func (e TuplesValidationError) Reason() string { return e.reason } |
3544
|
|
|
|
3545
|
|
|
// Cause function returns cause value. |
3546
|
|
|
func (e TuplesValidationError) Cause() error { return e.cause } |
3547
|
|
|
|
3548
|
|
|
// Key function returns key value. |
3549
|
|
|
func (e TuplesValidationError) Key() bool { return e.key } |
3550
|
|
|
|
3551
|
|
|
// ErrorName returns error name. |
3552
|
|
|
func (e TuplesValidationError) ErrorName() string { return "TuplesValidationError" } |
3553
|
|
|
|
3554
|
|
|
// Error satisfies the builtin error interface |
3555
|
|
|
func (e TuplesValidationError) Error() string { |
3556
|
|
|
cause := "" |
3557
|
|
|
if e.cause != nil { |
3558
|
|
|
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
3559
|
|
|
} |
3560
|
|
|
|
3561
|
|
|
key := "" |
3562
|
|
|
if e.key { |
3563
|
|
|
key = "key for " |
3564
|
|
|
} |
3565
|
|
|
|
3566
|
|
|
return fmt.Sprintf( |
3567
|
|
|
"invalid %sTuples.%s: %s%s", |
3568
|
|
|
key, |
3569
|
|
|
e.field, |
3570
|
|
|
e.reason, |
3571
|
|
|
cause) |
3572
|
|
|
} |
3573
|
|
|
|
3574
|
|
|
var _ error = TuplesValidationError{} |
3575
|
|
|
|
3576
|
|
|
var _ interface { |
3577
|
|
|
Field() string |
3578
|
|
|
Reason() string |
3579
|
|
|
Key() bool |
3580
|
|
|
Cause() error |
3581
|
|
|
ErrorName() string |
3582
|
|
|
} = TuplesValidationError{} |
3583
|
|
|
|
3584
|
|
|
// Validate checks the field values on Attributes with the rules defined in the |
3585
|
|
|
// proto definition for this message. If any rules are violated, the first |
3586
|
|
|
// error encountered is returned, or nil if there are no violations. |
3587
|
|
|
func (m *Attributes) Validate() error { |
3588
|
|
|
return m.validate(false) |
3589
|
|
|
} |
3590
|
|
|
|
3591
|
|
|
// ValidateAll checks the field values on Attributes with the rules defined in |
3592
|
|
|
// the proto definition for this message. If any rules are violated, the |
3593
|
|
|
// result is a list of violation errors wrapped in AttributesMultiError, or |
3594
|
|
|
// nil if none found. |
3595
|
|
|
func (m *Attributes) ValidateAll() error { |
3596
|
|
|
return m.validate(true) |
3597
|
|
|
} |
3598
|
|
|
|
3599
|
|
|
func (m *Attributes) validate(all bool) error { |
3600
|
|
|
if m == nil { |
3601
|
|
|
return nil |
3602
|
|
|
} |
3603
|
|
|
|
3604
|
|
|
var errors []error |
3605
|
|
|
|
3606
|
|
|
for idx, item := range m.GetAttributes() { |
3607
|
|
|
_, _ = idx, item |
3608
|
|
|
|
3609
|
|
|
if all { |
3610
|
|
|
switch v := interface{}(item).(type) { |
3611
|
|
|
case interface{ ValidateAll() error }: |
3612
|
|
|
if err := v.ValidateAll(); err != nil { |
3613
|
|
|
errors = append(errors, AttributesValidationError{ |
3614
|
|
|
field: fmt.Sprintf("Attributes[%v]", idx), |
3615
|
|
|
reason: "embedded message failed validation", |
3616
|
|
|
cause: err, |
3617
|
|
|
}) |
3618
|
|
|
} |
3619
|
|
|
case interface{ Validate() error }: |
3620
|
|
|
if err := v.Validate(); err != nil { |
3621
|
|
|
errors = append(errors, AttributesValidationError{ |
3622
|
|
|
field: fmt.Sprintf("Attributes[%v]", idx), |
3623
|
|
|
reason: "embedded message failed validation", |
3624
|
|
|
cause: err, |
3625
|
|
|
}) |
3626
|
|
|
} |
3627
|
|
|
} |
3628
|
|
|
} else if v, ok := interface{}(item).(interface{ Validate() error }); ok { |
3629
|
|
|
if err := v.Validate(); err != nil { |
3630
|
|
|
return AttributesValidationError{ |
3631
|
|
|
field: fmt.Sprintf("Attributes[%v]", idx), |
3632
|
|
|
reason: "embedded message failed validation", |
3633
|
|
|
cause: err, |
3634
|
|
|
} |
3635
|
|
|
} |
3636
|
|
|
} |
3637
|
|
|
|
3638
|
|
|
} |
3639
|
|
|
|
3640
|
|
|
if len(errors) > 0 { |
3641
|
|
|
return AttributesMultiError(errors) |
3642
|
|
|
} |
3643
|
|
|
|
3644
|
|
|
return nil |
3645
|
|
|
} |
3646
|
|
|
|
3647
|
|
|
// AttributesMultiError is an error wrapping multiple validation errors |
3648
|
|
|
// returned by Attributes.ValidateAll() if the designated constraints aren't met. |
3649
|
|
|
type AttributesMultiError []error |
3650
|
|
|
|
3651
|
|
|
// Error returns a concatenation of all the error messages it wraps. |
3652
|
|
|
func (m AttributesMultiError) Error() string { |
3653
|
|
|
var msgs []string |
3654
|
|
|
for _, err := range m { |
3655
|
|
|
msgs = append(msgs, err.Error()) |
3656
|
|
|
} |
3657
|
|
|
return strings.Join(msgs, "; ") |
3658
|
|
|
} |
3659
|
|
|
|
3660
|
|
|
// AllErrors returns a list of validation violation errors. |
3661
|
|
|
func (m AttributesMultiError) AllErrors() []error { return m } |
3662
|
|
|
|
3663
|
|
|
// AttributesValidationError is the validation error returned by |
3664
|
|
|
// Attributes.Validate if the designated constraints aren't met. |
3665
|
|
|
type AttributesValidationError struct { |
3666
|
|
|
field string |
3667
|
|
|
reason string |
3668
|
|
|
cause error |
3669
|
|
|
key bool |
3670
|
|
|
} |
3671
|
|
|
|
3672
|
|
|
// Field function returns field value. |
3673
|
|
|
func (e AttributesValidationError) Field() string { return e.field } |
3674
|
|
|
|
3675
|
|
|
// Reason function returns reason value. |
3676
|
|
|
func (e AttributesValidationError) Reason() string { return e.reason } |
3677
|
|
|
|
3678
|
|
|
// Cause function returns cause value. |
3679
|
|
|
func (e AttributesValidationError) Cause() error { return e.cause } |
3680
|
|
|
|
3681
|
|
|
// Key function returns key value. |
3682
|
|
|
func (e AttributesValidationError) Key() bool { return e.key } |
3683
|
|
|
|
3684
|
|
|
// ErrorName returns error name. |
3685
|
|
|
func (e AttributesValidationError) ErrorName() string { return "AttributesValidationError" } |
3686
|
|
|
|
3687
|
|
|
// Error satisfies the builtin error interface |
3688
|
|
|
func (e AttributesValidationError) Error() string { |
3689
|
|
|
cause := "" |
3690
|
|
|
if e.cause != nil { |
3691
|
|
|
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
3692
|
|
|
} |
3693
|
|
|
|
3694
|
|
|
key := "" |
3695
|
|
|
if e.key { |
3696
|
|
|
key = "key for " |
3697
|
|
|
} |
3698
|
|
|
|
3699
|
|
|
return fmt.Sprintf( |
3700
|
|
|
"invalid %sAttributes.%s: %s%s", |
3701
|
|
|
key, |
3702
|
|
|
e.field, |
3703
|
|
|
e.reason, |
3704
|
|
|
cause) |
3705
|
|
|
} |
3706
|
|
|
|
3707
|
|
|
var _ error = AttributesValidationError{} |
3708
|
|
|
|
3709
|
|
|
var _ interface { |
3710
|
|
|
Field() string |
3711
|
|
|
Reason() string |
3712
|
|
|
Key() bool |
3713
|
|
|
Cause() error |
3714
|
|
|
ErrorName() string |
3715
|
|
|
} = AttributesValidationError{} |
3716
|
|
|
|
3717
|
|
|
// Validate checks the field values on Entity with the rules defined in the |
3718
|
|
|
// proto definition for this message. If any rules are violated, the first |
3719
|
|
|
// error encountered is returned, or nil if there are no violations. |
3720
|
|
|
func (m *Entity) Validate() error { |
3721
|
|
|
return m.validate(false) |
3722
|
|
|
} |
3723
|
|
|
|
3724
|
|
|
// ValidateAll checks the field values on Entity with the rules defined in the |
3725
|
|
|
// proto definition for this message. If any rules are violated, the result is |
3726
|
|
|
// a list of violation errors wrapped in EntityMultiError, or nil if none found. |
3727
|
|
|
func (m *Entity) ValidateAll() error { |
3728
|
|
|
return m.validate(true) |
3729
|
|
|
} |
3730
|
|
|
|
3731
|
|
|
func (m *Entity) validate(all bool) error { |
3732
|
|
|
if m == nil { |
3733
|
|
|
return nil |
3734
|
|
|
} |
3735
|
|
|
|
3736
|
|
|
var errors []error |
3737
|
|
|
|
3738
|
|
|
if len(m.GetType()) > 64 { |
3739
|
|
|
err := EntityValidationError{ |
3740
|
|
|
field: "Type", |
3741
|
|
|
reason: "value length must be at most 64 bytes", |
3742
|
|
|
} |
3743
|
|
|
if !all { |
3744
|
|
|
return err |
3745
|
|
|
} |
3746
|
|
|
errors = append(errors, err) |
3747
|
|
|
} |
3748
|
|
|
|
3749
|
|
|
if !_Entity_Type_Pattern.MatchString(m.GetType()) { |
3750
|
|
|
err := EntityValidationError{ |
3751
|
|
|
field: "Type", |
3752
|
|
|
reason: "value does not match regex pattern \"^[a-zA-Z_]{1,64}$\"", |
3753
|
|
|
} |
3754
|
|
|
if !all { |
3755
|
|
|
return err |
3756
|
|
|
} |
3757
|
|
|
errors = append(errors, err) |
3758
|
|
|
} |
3759
|
|
|
|
3760
|
|
|
if len(m.GetId()) > 128 { |
3761
|
|
|
err := EntityValidationError{ |
3762
|
|
|
field: "Id", |
3763
|
|
|
reason: "value length must be at most 128 bytes", |
3764
|
|
|
} |
3765
|
|
|
if !all { |
3766
|
|
|
return err |
3767
|
|
|
} |
3768
|
|
|
errors = append(errors, err) |
3769
|
|
|
} |
3770
|
|
|
|
3771
|
|
|
if !_Entity_Id_Pattern.MatchString(m.GetId()) { |
3772
|
|
|
err := EntityValidationError{ |
3773
|
|
|
field: "Id", |
3774
|
|
|
reason: "value does not match regex pattern \"^([a-zA-Z0-9_\\\\-@\\\\.:+]{1,128}|\\\\*)$\"", |
3775
|
|
|
} |
3776
|
|
|
if !all { |
3777
|
|
|
return err |
3778
|
|
|
} |
3779
|
|
|
errors = append(errors, err) |
3780
|
|
|
} |
3781
|
|
|
|
3782
|
|
|
if len(errors) > 0 { |
3783
|
|
|
return EntityMultiError(errors) |
3784
|
|
|
} |
3785
|
|
|
|
3786
|
|
|
return nil |
3787
|
|
|
} |
3788
|
|
|
|
3789
|
|
|
// EntityMultiError is an error wrapping multiple validation errors returned by |
3790
|
|
|
// Entity.ValidateAll() if the designated constraints aren't met. |
3791
|
|
|
type EntityMultiError []error |
3792
|
|
|
|
3793
|
|
|
// Error returns a concatenation of all the error messages it wraps. |
3794
|
|
|
func (m EntityMultiError) Error() string { |
3795
|
|
|
var msgs []string |
3796
|
|
|
for _, err := range m { |
3797
|
|
|
msgs = append(msgs, err.Error()) |
3798
|
|
|
} |
3799
|
|
|
return strings.Join(msgs, "; ") |
3800
|
|
|
} |
3801
|
|
|
|
3802
|
|
|
// AllErrors returns a list of validation violation errors. |
3803
|
|
|
func (m EntityMultiError) AllErrors() []error { return m } |
3804
|
|
|
|
3805
|
|
|
// EntityValidationError is the validation error returned by Entity.Validate if |
3806
|
|
|
// the designated constraints aren't met. |
3807
|
|
|
type EntityValidationError struct { |
3808
|
|
|
field string |
3809
|
|
|
reason string |
3810
|
|
|
cause error |
3811
|
|
|
key bool |
3812
|
|
|
} |
3813
|
|
|
|
3814
|
|
|
// Field function returns field value. |
3815
|
|
|
func (e EntityValidationError) Field() string { return e.field } |
3816
|
|
|
|
3817
|
|
|
// Reason function returns reason value. |
3818
|
|
|
func (e EntityValidationError) Reason() string { return e.reason } |
3819
|
|
|
|
3820
|
|
|
// Cause function returns cause value. |
3821
|
|
|
func (e EntityValidationError) Cause() error { return e.cause } |
3822
|
|
|
|
3823
|
|
|
// Key function returns key value. |
3824
|
|
|
func (e EntityValidationError) Key() bool { return e.key } |
3825
|
|
|
|
3826
|
|
|
// ErrorName returns error name. |
3827
|
|
|
func (e EntityValidationError) ErrorName() string { return "EntityValidationError" } |
3828
|
|
|
|
3829
|
|
|
// Error satisfies the builtin error interface |
3830
|
|
|
func (e EntityValidationError) Error() string { |
3831
|
|
|
cause := "" |
3832
|
|
|
if e.cause != nil { |
3833
|
|
|
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
3834
|
|
|
} |
3835
|
|
|
|
3836
|
|
|
key := "" |
3837
|
|
|
if e.key { |
3838
|
|
|
key = "key for " |
3839
|
|
|
} |
3840
|
|
|
|
3841
|
|
|
return fmt.Sprintf( |
3842
|
|
|
"invalid %sEntity.%s: %s%s", |
3843
|
|
|
key, |
3844
|
|
|
e.field, |
3845
|
|
|
e.reason, |
3846
|
|
|
cause) |
3847
|
|
|
} |
3848
|
|
|
|
3849
|
|
|
var _ error = EntityValidationError{} |
3850
|
|
|
|
3851
|
|
|
var _ interface { |
3852
|
|
|
Field() string |
3853
|
|
|
Reason() string |
3854
|
|
|
Key() bool |
3855
|
|
|
Cause() error |
3856
|
|
|
ErrorName() string |
3857
|
|
|
} = EntityValidationError{} |
3858
|
|
|
|
3859
|
|
|
var _Entity_Type_Pattern = regexp.MustCompile("^[a-zA-Z_]{1,64}$") |
3860
|
|
|
|
3861
|
|
|
var _Entity_Id_Pattern = regexp.MustCompile("^([a-zA-Z0-9_\\-@\\.:+]{1,128}|\\*)$") |
3862
|
|
|
|
3863
|
|
|
// Validate checks the field values on EntityAndRelation with the rules defined |
3864
|
|
|
// in the proto definition for this message. If any rules are violated, the |
3865
|
|
|
// first error encountered is returned, or nil if there are no violations. |
3866
|
|
|
func (m *EntityAndRelation) Validate() error { |
3867
|
|
|
return m.validate(false) |
3868
|
|
|
} |
3869
|
|
|
|
3870
|
|
|
// ValidateAll checks the field values on EntityAndRelation with the rules |
3871
|
|
|
// defined in the proto definition for this message. If any rules are |
3872
|
|
|
// violated, the result is a list of violation errors wrapped in |
3873
|
|
|
// EntityAndRelationMultiError, or nil if none found. |
3874
|
|
|
func (m *EntityAndRelation) ValidateAll() error { |
3875
|
|
|
return m.validate(true) |
3876
|
|
|
} |
3877
|
|
|
|
3878
|
|
|
func (m *EntityAndRelation) validate(all bool) error { |
3879
|
|
|
if m == nil { |
3880
|
|
|
return nil |
3881
|
|
|
} |
3882
|
|
|
|
3883
|
|
|
var errors []error |
3884
|
|
|
|
3885
|
|
|
if m.GetEntity() == nil { |
3886
|
|
|
err := EntityAndRelationValidationError{ |
3887
|
|
|
field: "Entity", |
3888
|
|
|
reason: "value is required", |
3889
|
|
|
} |
3890
|
|
|
if !all { |
3891
|
|
|
return err |
3892
|
|
|
} |
3893
|
|
|
errors = append(errors, err) |
3894
|
|
|
} |
3895
|
|
|
|
3896
|
|
|
if all { |
3897
|
|
|
switch v := interface{}(m.GetEntity()).(type) { |
3898
|
|
|
case interface{ ValidateAll() error }: |
3899
|
|
|
if err := v.ValidateAll(); err != nil { |
3900
|
|
|
errors = append(errors, EntityAndRelationValidationError{ |
3901
|
|
|
field: "Entity", |
3902
|
|
|
reason: "embedded message failed validation", |
3903
|
|
|
cause: err, |
3904
|
|
|
}) |
3905
|
|
|
} |
3906
|
|
|
case interface{ Validate() error }: |
3907
|
|
|
if err := v.Validate(); err != nil { |
3908
|
|
|
errors = append(errors, EntityAndRelationValidationError{ |
3909
|
|
|
field: "Entity", |
3910
|
|
|
reason: "embedded message failed validation", |
3911
|
|
|
cause: err, |
3912
|
|
|
}) |
3913
|
|
|
} |
3914
|
|
|
} |
3915
|
|
|
} else if v, ok := interface{}(m.GetEntity()).(interface{ Validate() error }); ok { |
3916
|
|
|
if err := v.Validate(); err != nil { |
3917
|
|
|
return EntityAndRelationValidationError{ |
3918
|
|
|
field: "Entity", |
3919
|
|
|
reason: "embedded message failed validation", |
3920
|
|
|
cause: err, |
3921
|
|
|
} |
3922
|
|
|
} |
3923
|
|
|
} |
3924
|
|
|
|
3925
|
|
|
if len(m.GetRelation()) > 64 { |
3926
|
|
|
err := EntityAndRelationValidationError{ |
3927
|
|
|
field: "Relation", |
3928
|
|
|
reason: "value length must be at most 64 bytes", |
3929
|
|
|
} |
3930
|
|
|
if !all { |
3931
|
|
|
return err |
3932
|
|
|
} |
3933
|
|
|
errors = append(errors, err) |
3934
|
|
|
} |
3935
|
|
|
|
3936
|
|
|
if !_EntityAndRelation_Relation_Pattern.MatchString(m.GetRelation()) { |
3937
|
|
|
err := EntityAndRelationValidationError{ |
3938
|
|
|
field: "Relation", |
3939
|
|
|
reason: "value does not match regex pattern \"^[a-zA-Z_]{1,64}$\"", |
3940
|
|
|
} |
3941
|
|
|
if !all { |
3942
|
|
|
return err |
3943
|
|
|
} |
3944
|
|
|
errors = append(errors, err) |
3945
|
|
|
} |
3946
|
|
|
|
3947
|
|
|
if len(errors) > 0 { |
3948
|
|
|
return EntityAndRelationMultiError(errors) |
3949
|
|
|
} |
3950
|
|
|
|
3951
|
|
|
return nil |
3952
|
|
|
} |
3953
|
|
|
|
3954
|
|
|
// EntityAndRelationMultiError is an error wrapping multiple validation errors |
3955
|
|
|
// returned by EntityAndRelation.ValidateAll() if the designated constraints |
3956
|
|
|
// aren't met. |
3957
|
|
|
type EntityAndRelationMultiError []error |
3958
|
|
|
|
3959
|
|
|
// Error returns a concatenation of all the error messages it wraps. |
3960
|
|
|
func (m EntityAndRelationMultiError) Error() string { |
3961
|
|
|
var msgs []string |
3962
|
|
|
for _, err := range m { |
3963
|
|
|
msgs = append(msgs, err.Error()) |
3964
|
|
|
} |
3965
|
|
|
return strings.Join(msgs, "; ") |
3966
|
|
|
} |
3967
|
|
|
|
3968
|
|
|
// AllErrors returns a list of validation violation errors. |
3969
|
|
|
func (m EntityAndRelationMultiError) AllErrors() []error { return m } |
3970
|
|
|
|
3971
|
|
|
// EntityAndRelationValidationError is the validation error returned by |
3972
|
|
|
// EntityAndRelation.Validate if the designated constraints aren't met. |
3973
|
|
|
type EntityAndRelationValidationError struct { |
3974
|
|
|
field string |
3975
|
|
|
reason string |
3976
|
|
|
cause error |
3977
|
|
|
key bool |
3978
|
|
|
} |
3979
|
|
|
|
3980
|
|
|
// Field function returns field value. |
3981
|
|
|
func (e EntityAndRelationValidationError) Field() string { return e.field } |
3982
|
|
|
|
3983
|
|
|
// Reason function returns reason value. |
3984
|
|
|
func (e EntityAndRelationValidationError) Reason() string { return e.reason } |
3985
|
|
|
|
3986
|
|
|
// Cause function returns cause value. |
3987
|
|
|
func (e EntityAndRelationValidationError) Cause() error { return e.cause } |
3988
|
|
|
|
3989
|
|
|
// Key function returns key value. |
3990
|
|
|
func (e EntityAndRelationValidationError) Key() bool { return e.key } |
3991
|
|
|
|
3992
|
|
|
// ErrorName returns error name. |
3993
|
|
|
func (e EntityAndRelationValidationError) ErrorName() string { |
3994
|
|
|
return "EntityAndRelationValidationError" |
3995
|
|
|
} |
3996
|
|
|
|
3997
|
|
|
// Error satisfies the builtin error interface |
3998
|
|
|
func (e EntityAndRelationValidationError) Error() string { |
3999
|
|
|
cause := "" |
4000
|
|
|
if e.cause != nil { |
4001
|
|
|
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
4002
|
|
|
} |
4003
|
|
|
|
4004
|
|
|
key := "" |
4005
|
|
|
if e.key { |
4006
|
|
|
key = "key for " |
4007
|
|
|
} |
4008
|
|
|
|
4009
|
|
|
return fmt.Sprintf( |
4010
|
|
|
"invalid %sEntityAndRelation.%s: %s%s", |
4011
|
|
|
key, |
4012
|
|
|
e.field, |
4013
|
|
|
e.reason, |
4014
|
|
|
cause) |
4015
|
|
|
} |
4016
|
|
|
|
4017
|
|
|
var _ error = EntityAndRelationValidationError{} |
4018
|
|
|
|
4019
|
|
|
var _ interface { |
4020
|
|
|
Field() string |
4021
|
|
|
Reason() string |
4022
|
|
|
Key() bool |
4023
|
|
|
Cause() error |
4024
|
|
|
ErrorName() string |
4025
|
|
|
} = EntityAndRelationValidationError{} |
4026
|
|
|
|
4027
|
|
|
var _EntityAndRelation_Relation_Pattern = regexp.MustCompile("^[a-zA-Z_]{1,64}$") |
4028
|
|
|
|
4029
|
|
|
// Validate checks the field values on Subject with the rules defined in the |
4030
|
|
|
// proto definition for this message. If any rules are violated, the first |
4031
|
|
|
// error encountered is returned, or nil if there are no violations. |
4032
|
|
|
func (m *Subject) Validate() error { |
4033
|
|
|
return m.validate(false) |
4034
|
|
|
} |
4035
|
|
|
|
4036
|
|
|
// ValidateAll checks the field values on Subject with the rules defined in the |
4037
|
|
|
// proto definition for this message. If any rules are violated, the result is |
4038
|
|
|
// a list of violation errors wrapped in SubjectMultiError, or nil if none found. |
4039
|
|
|
func (m *Subject) ValidateAll() error { |
4040
|
|
|
return m.validate(true) |
4041
|
|
|
} |
4042
|
|
|
|
4043
|
|
|
func (m *Subject) validate(all bool) error { |
4044
|
|
|
if m == nil { |
4045
|
|
|
return nil |
4046
|
|
|
} |
4047
|
|
|
|
4048
|
|
|
var errors []error |
4049
|
|
|
|
4050
|
|
|
if len(m.GetType()) > 64 { |
4051
|
|
|
err := SubjectValidationError{ |
4052
|
|
|
field: "Type", |
4053
|
|
|
reason: "value length must be at most 64 bytes", |
4054
|
|
|
} |
4055
|
|
|
if !all { |
4056
|
|
|
return err |
4057
|
|
|
} |
4058
|
|
|
errors = append(errors, err) |
4059
|
|
|
} |
4060
|
|
|
|
4061
|
|
|
if !_Subject_Type_Pattern.MatchString(m.GetType()) { |
4062
|
|
|
err := SubjectValidationError{ |
4063
|
|
|
field: "Type", |
4064
|
|
|
reason: "value does not match regex pattern \"^[a-zA-Z_]{1,64}$\"", |
4065
|
|
|
} |
4066
|
|
|
if !all { |
4067
|
|
|
return err |
4068
|
|
|
} |
4069
|
|
|
errors = append(errors, err) |
4070
|
|
|
} |
4071
|
|
|
|
4072
|
|
|
if len(m.GetId()) > 128 { |
4073
|
|
|
err := SubjectValidationError{ |
4074
|
|
|
field: "Id", |
4075
|
|
|
reason: "value length must be at most 128 bytes", |
4076
|
|
|
} |
4077
|
|
|
if !all { |
4078
|
|
|
return err |
4079
|
|
|
} |
4080
|
|
|
errors = append(errors, err) |
4081
|
|
|
} |
4082
|
|
|
|
4083
|
|
|
if !_Subject_Id_Pattern.MatchString(m.GetId()) { |
4084
|
|
|
err := SubjectValidationError{ |
4085
|
|
|
field: "Id", |
4086
|
|
|
reason: "value does not match regex pattern \"^([a-zA-Z0-9_\\\\-@\\\\.:+]{1,128}|\\\\*)$\"", |
4087
|
|
|
} |
4088
|
|
|
if !all { |
4089
|
|
|
return err |
4090
|
|
|
} |
4091
|
|
|
errors = append(errors, err) |
4092
|
|
|
} |
4093
|
|
|
|
4094
|
|
|
if m.GetRelation() != "" { |
4095
|
|
|
|
4096
|
|
|
if len(m.GetRelation()) > 64 { |
4097
|
|
|
err := SubjectValidationError{ |
4098
|
|
|
field: "Relation", |
4099
|
|
|
reason: "value length must be at most 64 bytes", |
4100
|
|
|
} |
4101
|
|
|
if !all { |
4102
|
|
|
return err |
4103
|
|
|
} |
4104
|
|
|
errors = append(errors, err) |
4105
|
|
|
} |
4106
|
|
|
|
4107
|
|
|
if !_Subject_Relation_Pattern.MatchString(m.GetRelation()) { |
4108
|
|
|
err := SubjectValidationError{ |
4109
|
|
|
field: "Relation", |
4110
|
|
|
reason: "value does not match regex pattern \"^[a-zA-Z_]{1,64}$\"", |
4111
|
|
|
} |
4112
|
|
|
if !all { |
4113
|
|
|
return err |
4114
|
|
|
} |
4115
|
|
|
errors = append(errors, err) |
4116
|
|
|
} |
4117
|
|
|
|
4118
|
|
|
} |
4119
|
|
|
|
4120
|
|
|
if len(errors) > 0 { |
4121
|
|
|
return SubjectMultiError(errors) |
4122
|
|
|
} |
4123
|
|
|
|
4124
|
|
|
return nil |
4125
|
|
|
} |
4126
|
|
|
|
4127
|
|
|
// SubjectMultiError is an error wrapping multiple validation errors returned |
4128
|
|
|
// by Subject.ValidateAll() if the designated constraints aren't met. |
4129
|
|
|
type SubjectMultiError []error |
4130
|
|
|
|
4131
|
|
|
// Error returns a concatenation of all the error messages it wraps. |
4132
|
|
|
func (m SubjectMultiError) Error() string { |
4133
|
|
|
var msgs []string |
4134
|
|
|
for _, err := range m { |
4135
|
|
|
msgs = append(msgs, err.Error()) |
4136
|
|
|
} |
4137
|
|
|
return strings.Join(msgs, "; ") |
4138
|
|
|
} |
4139
|
|
|
|
4140
|
|
|
// AllErrors returns a list of validation violation errors. |
4141
|
|
|
func (m SubjectMultiError) AllErrors() []error { return m } |
4142
|
|
|
|
4143
|
|
|
// SubjectValidationError is the validation error returned by Subject.Validate |
4144
|
|
|
// if the designated constraints aren't met. |
4145
|
|
|
type SubjectValidationError struct { |
4146
|
|
|
field string |
4147
|
|
|
reason string |
4148
|
|
|
cause error |
4149
|
|
|
key bool |
4150
|
|
|
} |
4151
|
|
|
|
4152
|
|
|
// Field function returns field value. |
4153
|
|
|
func (e SubjectValidationError) Field() string { return e.field } |
4154
|
|
|
|
4155
|
|
|
// Reason function returns reason value. |
4156
|
|
|
func (e SubjectValidationError) Reason() string { return e.reason } |
4157
|
|
|
|
4158
|
|
|
// Cause function returns cause value. |
4159
|
|
|
func (e SubjectValidationError) Cause() error { return e.cause } |
4160
|
|
|
|
4161
|
|
|
// Key function returns key value. |
4162
|
|
|
func (e SubjectValidationError) Key() bool { return e.key } |
4163
|
|
|
|
4164
|
|
|
// ErrorName returns error name. |
4165
|
|
|
func (e SubjectValidationError) ErrorName() string { return "SubjectValidationError" } |
4166
|
|
|
|
4167
|
|
|
// Error satisfies the builtin error interface |
4168
|
|
|
func (e SubjectValidationError) Error() string { |
4169
|
|
|
cause := "" |
4170
|
|
|
if e.cause != nil { |
4171
|
|
|
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
4172
|
|
|
} |
4173
|
|
|
|
4174
|
|
|
key := "" |
4175
|
|
|
if e.key { |
4176
|
|
|
key = "key for " |
4177
|
|
|
} |
4178
|
|
|
|
4179
|
|
|
return fmt.Sprintf( |
4180
|
|
|
"invalid %sSubject.%s: %s%s", |
4181
|
|
|
key, |
4182
|
|
|
e.field, |
4183
|
|
|
e.reason, |
4184
|
|
|
cause) |
4185
|
|
|
} |
4186
|
|
|
|
4187
|
|
|
var _ error = SubjectValidationError{} |
4188
|
|
|
|
4189
|
|
|
var _ interface { |
4190
|
|
|
Field() string |
4191
|
|
|
Reason() string |
4192
|
|
|
Key() bool |
4193
|
|
|
Cause() error |
4194
|
|
|
ErrorName() string |
4195
|
|
|
} = SubjectValidationError{} |
4196
|
|
|
|
4197
|
|
|
var _Subject_Type_Pattern = regexp.MustCompile("^[a-zA-Z_]{1,64}$") |
4198
|
|
|
|
4199
|
|
|
var _Subject_Id_Pattern = regexp.MustCompile("^([a-zA-Z0-9_\\-@\\.:+]{1,128}|\\*)$") |
4200
|
|
|
|
4201
|
|
|
var _Subject_Relation_Pattern = regexp.MustCompile("^[a-zA-Z_]{1,64}$") |
4202
|
|
|
|
4203
|
|
|
// Validate checks the field values on AttributeFilter with the rules defined |
4204
|
|
|
// in the proto definition for this message. If any rules are violated, the |
4205
|
|
|
// first error encountered is returned, or nil if there are no violations. |
4206
|
|
|
func (m *AttributeFilter) Validate() error { |
4207
|
|
|
return m.validate(false) |
4208
|
|
|
} |
4209
|
|
|
|
4210
|
|
|
// ValidateAll checks the field values on AttributeFilter with the rules |
4211
|
|
|
// defined in the proto definition for this message. If any rules are |
4212
|
|
|
// violated, the result is a list of violation errors wrapped in |
4213
|
|
|
// AttributeFilterMultiError, or nil if none found. |
4214
|
|
|
func (m *AttributeFilter) ValidateAll() error { |
4215
|
|
|
return m.validate(true) |
4216
|
|
|
} |
4217
|
|
|
|
4218
|
|
|
func (m *AttributeFilter) validate(all bool) error { |
4219
|
|
|
if m == nil { |
4220
|
|
|
return nil |
4221
|
|
|
} |
4222
|
|
|
|
4223
|
|
|
var errors []error |
4224
|
|
|
|
4225
|
|
|
if all { |
4226
|
|
|
switch v := interface{}(m.GetEntity()).(type) { |
4227
|
|
|
case interface{ ValidateAll() error }: |
4228
|
|
|
if err := v.ValidateAll(); err != nil { |
4229
|
|
|
errors = append(errors, AttributeFilterValidationError{ |
4230
|
|
|
field: "Entity", |
4231
|
|
|
reason: "embedded message failed validation", |
4232
|
|
|
cause: err, |
4233
|
|
|
}) |
4234
|
|
|
} |
4235
|
|
|
case interface{ Validate() error }: |
4236
|
|
|
if err := v.Validate(); err != nil { |
4237
|
|
|
errors = append(errors, AttributeFilterValidationError{ |
4238
|
|
|
field: "Entity", |
4239
|
|
|
reason: "embedded message failed validation", |
4240
|
|
|
cause: err, |
4241
|
|
|
}) |
4242
|
|
|
} |
4243
|
|
|
} |
4244
|
|
|
} else if v, ok := interface{}(m.GetEntity()).(interface{ Validate() error }); ok { |
4245
|
|
|
if err := v.Validate(); err != nil { |
4246
|
|
|
return AttributeFilterValidationError{ |
4247
|
|
|
field: "Entity", |
4248
|
|
|
reason: "embedded message failed validation", |
4249
|
|
|
cause: err, |
4250
|
|
|
} |
4251
|
|
|
} |
4252
|
|
|
} |
4253
|
|
|
|
4254
|
|
|
if len(errors) > 0 { |
4255
|
|
|
return AttributeFilterMultiError(errors) |
4256
|
|
|
} |
4257
|
|
|
|
4258
|
|
|
return nil |
4259
|
|
|
} |
4260
|
|
|
|
4261
|
|
|
// AttributeFilterMultiError is an error wrapping multiple validation errors |
4262
|
|
|
// returned by AttributeFilter.ValidateAll() if the designated constraints |
4263
|
|
|
// aren't met. |
4264
|
|
|
type AttributeFilterMultiError []error |
4265
|
|
|
|
4266
|
|
|
// Error returns a concatenation of all the error messages it wraps. |
4267
|
|
|
func (m AttributeFilterMultiError) Error() string { |
4268
|
|
|
var msgs []string |
4269
|
|
|
for _, err := range m { |
4270
|
|
|
msgs = append(msgs, err.Error()) |
4271
|
|
|
} |
4272
|
|
|
return strings.Join(msgs, "; ") |
4273
|
|
|
} |
4274
|
|
|
|
4275
|
|
|
// AllErrors returns a list of validation violation errors. |
4276
|
|
|
func (m AttributeFilterMultiError) AllErrors() []error { return m } |
4277
|
|
|
|
4278
|
|
|
// AttributeFilterValidationError is the validation error returned by |
4279
|
|
|
// AttributeFilter.Validate if the designated constraints aren't met. |
4280
|
|
|
type AttributeFilterValidationError struct { |
4281
|
|
|
field string |
4282
|
|
|
reason string |
4283
|
|
|
cause error |
4284
|
|
|
key bool |
4285
|
|
|
} |
4286
|
|
|
|
4287
|
|
|
// Field function returns field value. |
4288
|
|
|
func (e AttributeFilterValidationError) Field() string { return e.field } |
4289
|
|
|
|
4290
|
|
|
// Reason function returns reason value. |
4291
|
|
|
func (e AttributeFilterValidationError) Reason() string { return e.reason } |
4292
|
|
|
|
4293
|
|
|
// Cause function returns cause value. |
4294
|
|
|
func (e AttributeFilterValidationError) Cause() error { return e.cause } |
4295
|
|
|
|
4296
|
|
|
// Key function returns key value. |
4297
|
|
|
func (e AttributeFilterValidationError) Key() bool { return e.key } |
4298
|
|
|
|
4299
|
|
|
// ErrorName returns error name. |
4300
|
|
|
func (e AttributeFilterValidationError) ErrorName() string { return "AttributeFilterValidationError" } |
4301
|
|
|
|
4302
|
|
|
// Error satisfies the builtin error interface |
4303
|
|
|
func (e AttributeFilterValidationError) Error() string { |
4304
|
|
|
cause := "" |
4305
|
|
|
if e.cause != nil { |
4306
|
|
|
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
4307
|
|
|
} |
4308
|
|
|
|
4309
|
|
|
key := "" |
4310
|
|
|
if e.key { |
4311
|
|
|
key = "key for " |
4312
|
|
|
} |
4313
|
|
|
|
4314
|
|
|
return fmt.Sprintf( |
4315
|
|
|
"invalid %sAttributeFilter.%s: %s%s", |
4316
|
|
|
key, |
4317
|
|
|
e.field, |
4318
|
|
|
e.reason, |
4319
|
|
|
cause) |
4320
|
|
|
} |
4321
|
|
|
|
4322
|
|
|
var _ error = AttributeFilterValidationError{} |
4323
|
|
|
|
4324
|
|
|
var _ interface { |
4325
|
|
|
Field() string |
4326
|
|
|
Reason() string |
4327
|
|
|
Key() bool |
4328
|
|
|
Cause() error |
4329
|
|
|
ErrorName() string |
4330
|
|
|
} = AttributeFilterValidationError{} |
4331
|
|
|
|
4332
|
|
|
// Validate checks the field values on TupleFilter with the rules defined in |
4333
|
|
|
// the proto definition for this message. If any rules are violated, the first |
4334
|
|
|
// error encountered is returned, or nil if there are no violations. |
4335
|
|
|
func (m *TupleFilter) Validate() error { |
4336
|
|
|
return m.validate(false) |
4337
|
|
|
} |
4338
|
|
|
|
4339
|
|
|
// ValidateAll checks the field values on TupleFilter with the rules defined in |
4340
|
|
|
// the proto definition for this message. If any rules are violated, the |
4341
|
|
|
// result is a list of violation errors wrapped in TupleFilterMultiError, or |
4342
|
|
|
// nil if none found. |
4343
|
|
|
func (m *TupleFilter) ValidateAll() error { |
4344
|
|
|
return m.validate(true) |
4345
|
|
|
} |
4346
|
|
|
|
4347
|
|
|
func (m *TupleFilter) validate(all bool) error { |
4348
|
|
|
if m == nil { |
4349
|
|
|
return nil |
4350
|
|
|
} |
4351
|
|
|
|
4352
|
|
|
var errors []error |
4353
|
|
|
|
4354
|
|
|
if all { |
4355
|
|
|
switch v := interface{}(m.GetEntity()).(type) { |
4356
|
|
|
case interface{ ValidateAll() error }: |
4357
|
|
|
if err := v.ValidateAll(); err != nil { |
4358
|
|
|
errors = append(errors, TupleFilterValidationError{ |
4359
|
|
|
field: "Entity", |
4360
|
|
|
reason: "embedded message failed validation", |
4361
|
|
|
cause: err, |
4362
|
|
|
}) |
4363
|
|
|
} |
4364
|
|
|
case interface{ Validate() error }: |
4365
|
|
|
if err := v.Validate(); err != nil { |
4366
|
|
|
errors = append(errors, TupleFilterValidationError{ |
4367
|
|
|
field: "Entity", |
4368
|
|
|
reason: "embedded message failed validation", |
4369
|
|
|
cause: err, |
4370
|
|
|
}) |
4371
|
|
|
} |
4372
|
|
|
} |
4373
|
|
|
} else if v, ok := interface{}(m.GetEntity()).(interface{ Validate() error }); ok { |
4374
|
|
|
if err := v.Validate(); err != nil { |
4375
|
|
|
return TupleFilterValidationError{ |
4376
|
|
|
field: "Entity", |
4377
|
|
|
reason: "embedded message failed validation", |
4378
|
|
|
cause: err, |
4379
|
|
|
} |
4380
|
|
|
} |
4381
|
|
|
} |
4382
|
|
|
|
4383
|
|
|
if m.GetRelation() != "" { |
4384
|
|
|
|
4385
|
|
|
if len(m.GetRelation()) > 64 { |
4386
|
|
|
err := TupleFilterValidationError{ |
4387
|
|
|
field: "Relation", |
4388
|
|
|
reason: "value length must be at most 64 bytes", |
4389
|
|
|
} |
4390
|
|
|
if !all { |
4391
|
|
|
return err |
4392
|
|
|
} |
4393
|
|
|
errors = append(errors, err) |
4394
|
|
|
} |
4395
|
|
|
|
4396
|
|
|
if !_TupleFilter_Relation_Pattern.MatchString(m.GetRelation()) { |
4397
|
|
|
err := TupleFilterValidationError{ |
4398
|
|
|
field: "Relation", |
4399
|
|
|
reason: "value does not match regex pattern \"^[a-zA-Z_]{1,64}$\"", |
4400
|
|
|
} |
4401
|
|
|
if !all { |
4402
|
|
|
return err |
4403
|
|
|
} |
4404
|
|
|
errors = append(errors, err) |
4405
|
|
|
} |
4406
|
|
|
|
4407
|
|
|
} |
4408
|
|
|
|
4409
|
|
|
if all { |
4410
|
|
|
switch v := interface{}(m.GetSubject()).(type) { |
4411
|
|
|
case interface{ ValidateAll() error }: |
4412
|
|
|
if err := v.ValidateAll(); err != nil { |
4413
|
|
|
errors = append(errors, TupleFilterValidationError{ |
4414
|
|
|
field: "Subject", |
4415
|
|
|
reason: "embedded message failed validation", |
4416
|
|
|
cause: err, |
4417
|
|
|
}) |
4418
|
|
|
} |
4419
|
|
|
case interface{ Validate() error }: |
4420
|
|
|
if err := v.Validate(); err != nil { |
4421
|
|
|
errors = append(errors, TupleFilterValidationError{ |
4422
|
|
|
field: "Subject", |
4423
|
|
|
reason: "embedded message failed validation", |
4424
|
|
|
cause: err, |
4425
|
|
|
}) |
4426
|
|
|
} |
4427
|
|
|
} |
4428
|
|
|
} else if v, ok := interface{}(m.GetSubject()).(interface{ Validate() error }); ok { |
4429
|
|
|
if err := v.Validate(); err != nil { |
4430
|
|
|
return TupleFilterValidationError{ |
4431
|
|
|
field: "Subject", |
4432
|
|
|
reason: "embedded message failed validation", |
4433
|
|
|
cause: err, |
4434
|
|
|
} |
4435
|
|
|
} |
4436
|
|
|
} |
4437
|
|
|
|
4438
|
|
|
if len(errors) > 0 { |
4439
|
|
|
return TupleFilterMultiError(errors) |
4440
|
|
|
} |
4441
|
|
|
|
4442
|
|
|
return nil |
4443
|
|
|
} |
4444
|
|
|
|
4445
|
|
|
// TupleFilterMultiError is an error wrapping multiple validation errors |
4446
|
|
|
// returned by TupleFilter.ValidateAll() if the designated constraints aren't met. |
4447
|
|
|
type TupleFilterMultiError []error |
4448
|
|
|
|
4449
|
|
|
// Error returns a concatenation of all the error messages it wraps. |
4450
|
|
|
func (m TupleFilterMultiError) Error() string { |
4451
|
|
|
var msgs []string |
4452
|
|
|
for _, err := range m { |
4453
|
|
|
msgs = append(msgs, err.Error()) |
4454
|
|
|
} |
4455
|
|
|
return strings.Join(msgs, "; ") |
4456
|
|
|
} |
4457
|
|
|
|
4458
|
|
|
// AllErrors returns a list of validation violation errors. |
4459
|
|
|
func (m TupleFilterMultiError) AllErrors() []error { return m } |
4460
|
|
|
|
4461
|
|
|
// TupleFilterValidationError is the validation error returned by |
4462
|
|
|
// TupleFilter.Validate if the designated constraints aren't met. |
4463
|
|
|
type TupleFilterValidationError struct { |
4464
|
|
|
field string |
4465
|
|
|
reason string |
4466
|
|
|
cause error |
4467
|
|
|
key bool |
4468
|
|
|
} |
4469
|
|
|
|
4470
|
|
|
// Field function returns field value. |
4471
|
|
|
func (e TupleFilterValidationError) Field() string { return e.field } |
4472
|
|
|
|
4473
|
|
|
// Reason function returns reason value. |
4474
|
|
|
func (e TupleFilterValidationError) Reason() string { return e.reason } |
4475
|
|
|
|
4476
|
|
|
// Cause function returns cause value. |
4477
|
|
|
func (e TupleFilterValidationError) Cause() error { return e.cause } |
4478
|
|
|
|
4479
|
|
|
// Key function returns key value. |
4480
|
|
|
func (e TupleFilterValidationError) Key() bool { return e.key } |
4481
|
|
|
|
4482
|
|
|
// ErrorName returns error name. |
4483
|
|
|
func (e TupleFilterValidationError) ErrorName() string { return "TupleFilterValidationError" } |
4484
|
|
|
|
4485
|
|
|
// Error satisfies the builtin error interface |
4486
|
|
|
func (e TupleFilterValidationError) Error() string { |
4487
|
|
|
cause := "" |
4488
|
|
|
if e.cause != nil { |
4489
|
|
|
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
4490
|
|
|
} |
4491
|
|
|
|
4492
|
|
|
key := "" |
4493
|
|
|
if e.key { |
4494
|
|
|
key = "key for " |
4495
|
|
|
} |
4496
|
|
|
|
4497
|
|
|
return fmt.Sprintf( |
4498
|
|
|
"invalid %sTupleFilter.%s: %s%s", |
4499
|
|
|
key, |
4500
|
|
|
e.field, |
4501
|
|
|
e.reason, |
4502
|
|
|
cause) |
4503
|
|
|
} |
4504
|
|
|
|
4505
|
|
|
var _ error = TupleFilterValidationError{} |
4506
|
|
|
|
4507
|
|
|
var _ interface { |
4508
|
|
|
Field() string |
4509
|
|
|
Reason() string |
4510
|
|
|
Key() bool |
4511
|
|
|
Cause() error |
4512
|
|
|
ErrorName() string |
4513
|
|
|
} = TupleFilterValidationError{} |
4514
|
|
|
|
4515
|
|
|
var _TupleFilter_Relation_Pattern = regexp.MustCompile("^[a-zA-Z_]{1,64}$") |
4516
|
|
|
|
4517
|
|
|
// Validate checks the field values on EntityFilter with the rules defined in |
4518
|
|
|
// the proto definition for this message. If any rules are violated, the first |
4519
|
|
|
// error encountered is returned, or nil if there are no violations. |
4520
|
|
|
func (m *EntityFilter) Validate() error { |
4521
|
|
|
return m.validate(false) |
4522
|
|
|
} |
4523
|
|
|
|
4524
|
|
|
// ValidateAll checks the field values on EntityFilter with the rules defined |
4525
|
|
|
// in the proto definition for this message. If any rules are violated, the |
4526
|
|
|
// result is a list of violation errors wrapped in EntityFilterMultiError, or |
4527
|
|
|
// nil if none found. |
4528
|
|
|
func (m *EntityFilter) ValidateAll() error { |
4529
|
|
|
return m.validate(true) |
4530
|
|
|
} |
4531
|
|
|
|
4532
|
|
|
func (m *EntityFilter) validate(all bool) error { |
4533
|
|
|
if m == nil { |
4534
|
|
|
return nil |
4535
|
|
|
} |
4536
|
|
|
|
4537
|
|
|
var errors []error |
4538
|
|
|
|
4539
|
|
|
// no validation rules for Type |
4540
|
|
|
|
4541
|
|
|
if len(errors) > 0 { |
4542
|
|
|
return EntityFilterMultiError(errors) |
4543
|
|
|
} |
4544
|
|
|
|
4545
|
|
|
return nil |
4546
|
|
|
} |
4547
|
|
|
|
4548
|
|
|
// EntityFilterMultiError is an error wrapping multiple validation errors |
4549
|
|
|
// returned by EntityFilter.ValidateAll() if the designated constraints aren't met. |
4550
|
|
|
type EntityFilterMultiError []error |
4551
|
|
|
|
4552
|
|
|
// Error returns a concatenation of all the error messages it wraps. |
4553
|
|
|
func (m EntityFilterMultiError) Error() string { |
4554
|
|
|
var msgs []string |
4555
|
|
|
for _, err := range m { |
4556
|
|
|
msgs = append(msgs, err.Error()) |
4557
|
|
|
} |
4558
|
|
|
return strings.Join(msgs, "; ") |
4559
|
|
|
} |
4560
|
|
|
|
4561
|
|
|
// AllErrors returns a list of validation violation errors. |
4562
|
|
|
func (m EntityFilterMultiError) AllErrors() []error { return m } |
4563
|
|
|
|
4564
|
|
|
// EntityFilterValidationError is the validation error returned by |
4565
|
|
|
// EntityFilter.Validate if the designated constraints aren't met. |
4566
|
|
|
type EntityFilterValidationError struct { |
4567
|
|
|
field string |
4568
|
|
|
reason string |
4569
|
|
|
cause error |
4570
|
|
|
key bool |
4571
|
|
|
} |
4572
|
|
|
|
4573
|
|
|
// Field function returns field value. |
4574
|
|
|
func (e EntityFilterValidationError) Field() string { return e.field } |
4575
|
|
|
|
4576
|
|
|
// Reason function returns reason value. |
4577
|
|
|
func (e EntityFilterValidationError) Reason() string { return e.reason } |
4578
|
|
|
|
4579
|
|
|
// Cause function returns cause value. |
4580
|
|
|
func (e EntityFilterValidationError) Cause() error { return e.cause } |
4581
|
|
|
|
4582
|
|
|
// Key function returns key value. |
4583
|
|
|
func (e EntityFilterValidationError) Key() bool { return e.key } |
4584
|
|
|
|
4585
|
|
|
// ErrorName returns error name. |
4586
|
|
|
func (e EntityFilterValidationError) ErrorName() string { return "EntityFilterValidationError" } |
4587
|
|
|
|
4588
|
|
|
// Error satisfies the builtin error interface |
4589
|
|
|
func (e EntityFilterValidationError) Error() string { |
4590
|
|
|
cause := "" |
4591
|
|
|
if e.cause != nil { |
4592
|
|
|
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
4593
|
|
|
} |
4594
|
|
|
|
4595
|
|
|
key := "" |
4596
|
|
|
if e.key { |
4597
|
|
|
key = "key for " |
4598
|
|
|
} |
4599
|
|
|
|
4600
|
|
|
return fmt.Sprintf( |
4601
|
|
|
"invalid %sEntityFilter.%s: %s%s", |
4602
|
|
|
key, |
4603
|
|
|
e.field, |
4604
|
|
|
e.reason, |
4605
|
|
|
cause) |
4606
|
|
|
} |
4607
|
|
|
|
4608
|
|
|
var _ error = EntityFilterValidationError{} |
4609
|
|
|
|
4610
|
|
|
var _ interface { |
4611
|
|
|
Field() string |
4612
|
|
|
Reason() string |
4613
|
|
|
Key() bool |
4614
|
|
|
Cause() error |
4615
|
|
|
ErrorName() string |
4616
|
|
|
} = EntityFilterValidationError{} |
4617
|
|
|
|
4618
|
|
|
// Validate checks the field values on SubjectFilter with the rules defined in |
4619
|
|
|
// the proto definition for this message. If any rules are violated, the first |
4620
|
|
|
// error encountered is returned, or nil if there are no violations. |
4621
|
|
|
func (m *SubjectFilter) Validate() error { |
4622
|
|
|
return m.validate(false) |
4623
|
|
|
} |
4624
|
|
|
|
4625
|
|
|
// ValidateAll checks the field values on SubjectFilter with the rules defined |
4626
|
|
|
// in the proto definition for this message. If any rules are violated, the |
4627
|
|
|
// result is a list of violation errors wrapped in SubjectFilterMultiError, or |
4628
|
|
|
// nil if none found. |
4629
|
|
|
func (m *SubjectFilter) ValidateAll() error { |
4630
|
|
|
return m.validate(true) |
4631
|
|
|
} |
4632
|
|
|
|
4633
|
|
|
func (m *SubjectFilter) validate(all bool) error { |
4634
|
|
|
if m == nil { |
4635
|
|
|
return nil |
4636
|
|
|
} |
4637
|
|
|
|
4638
|
|
|
var errors []error |
4639
|
|
|
|
4640
|
|
|
// no validation rules for Type |
4641
|
|
|
|
4642
|
|
|
if m.GetRelation() != "" { |
4643
|
|
|
|
4644
|
|
|
if len(m.GetRelation()) > 64 { |
4645
|
|
|
err := SubjectFilterValidationError{ |
4646
|
|
|
field: "Relation", |
4647
|
|
|
reason: "value length must be at most 64 bytes", |
4648
|
|
|
} |
4649
|
|
|
if !all { |
4650
|
|
|
return err |
4651
|
|
|
} |
4652
|
|
|
errors = append(errors, err) |
4653
|
|
|
} |
4654
|
|
|
|
4655
|
|
|
if !_SubjectFilter_Relation_Pattern.MatchString(m.GetRelation()) { |
4656
|
|
|
err := SubjectFilterValidationError{ |
4657
|
|
|
field: "Relation", |
4658
|
|
|
reason: "value does not match regex pattern \"^[a-zA-Z_]{1,64}$\"", |
4659
|
|
|
} |
4660
|
|
|
if !all { |
4661
|
|
|
return err |
4662
|
|
|
} |
4663
|
|
|
errors = append(errors, err) |
4664
|
|
|
} |
4665
|
|
|
|
4666
|
|
|
} |
4667
|
|
|
|
4668
|
|
|
if len(errors) > 0 { |
4669
|
|
|
return SubjectFilterMultiError(errors) |
4670
|
|
|
} |
4671
|
|
|
|
4672
|
|
|
return nil |
4673
|
|
|
} |
4674
|
|
|
|
4675
|
|
|
// SubjectFilterMultiError is an error wrapping multiple validation errors |
4676
|
|
|
// returned by SubjectFilter.ValidateAll() if the designated constraints |
4677
|
|
|
// aren't met. |
4678
|
|
|
type SubjectFilterMultiError []error |
4679
|
|
|
|
4680
|
|
|
// Error returns a concatenation of all the error messages it wraps. |
4681
|
|
|
func (m SubjectFilterMultiError) Error() string { |
4682
|
|
|
var msgs []string |
4683
|
|
|
for _, err := range m { |
4684
|
|
|
msgs = append(msgs, err.Error()) |
4685
|
|
|
} |
4686
|
|
|
return strings.Join(msgs, "; ") |
4687
|
|
|
} |
4688
|
|
|
|
4689
|
|
|
// AllErrors returns a list of validation violation errors. |
4690
|
|
|
func (m SubjectFilterMultiError) AllErrors() []error { return m } |
4691
|
|
|
|
4692
|
|
|
// SubjectFilterValidationError is the validation error returned by |
4693
|
|
|
// SubjectFilter.Validate if the designated constraints aren't met. |
4694
|
|
|
type SubjectFilterValidationError struct { |
4695
|
|
|
field string |
4696
|
|
|
reason string |
4697
|
|
|
cause error |
4698
|
|
|
key bool |
4699
|
|
|
} |
4700
|
|
|
|
4701
|
|
|
// Field function returns field value. |
4702
|
|
|
func (e SubjectFilterValidationError) Field() string { return e.field } |
4703
|
|
|
|
4704
|
|
|
// Reason function returns reason value. |
4705
|
|
|
func (e SubjectFilterValidationError) Reason() string { return e.reason } |
4706
|
|
|
|
4707
|
|
|
// Cause function returns cause value. |
4708
|
|
|
func (e SubjectFilterValidationError) Cause() error { return e.cause } |
4709
|
|
|
|
4710
|
|
|
// Key function returns key value. |
4711
|
|
|
func (e SubjectFilterValidationError) Key() bool { return e.key } |
4712
|
|
|
|
4713
|
|
|
// ErrorName returns error name. |
4714
|
|
|
func (e SubjectFilterValidationError) ErrorName() string { return "SubjectFilterValidationError" } |
4715
|
|
|
|
4716
|
|
|
// Error satisfies the builtin error interface |
4717
|
|
|
func (e SubjectFilterValidationError) Error() string { |
4718
|
|
|
cause := "" |
4719
|
|
|
if e.cause != nil { |
4720
|
|
|
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
4721
|
|
|
} |
4722
|
|
|
|
4723
|
|
|
key := "" |
4724
|
|
|
if e.key { |
4725
|
|
|
key = "key for " |
4726
|
|
|
} |
4727
|
|
|
|
4728
|
|
|
return fmt.Sprintf( |
4729
|
|
|
"invalid %sSubjectFilter.%s: %s%s", |
4730
|
|
|
key, |
4731
|
|
|
e.field, |
4732
|
|
|
e.reason, |
4733
|
|
|
cause) |
4734
|
|
|
} |
4735
|
|
|
|
4736
|
|
|
var _ error = SubjectFilterValidationError{} |
4737
|
|
|
|
4738
|
|
|
var _ interface { |
4739
|
|
|
Field() string |
4740
|
|
|
Reason() string |
4741
|
|
|
Key() bool |
4742
|
|
|
Cause() error |
4743
|
|
|
ErrorName() string |
4744
|
|
|
} = SubjectFilterValidationError{} |
4745
|
|
|
|
4746
|
|
|
var _SubjectFilter_Relation_Pattern = regexp.MustCompile("^[a-zA-Z_]{1,64}$") |
4747
|
|
|
|
4748
|
|
|
// Validate checks the field values on ExpandTreeNode with the rules defined in |
4749
|
|
|
// the proto definition for this message. If any rules are violated, the first |
4750
|
|
|
// error encountered is returned, or nil if there are no violations. |
4751
|
|
|
func (m *ExpandTreeNode) Validate() error { |
4752
|
|
|
return m.validate(false) |
4753
|
|
|
} |
4754
|
|
|
|
4755
|
|
|
// ValidateAll checks the field values on ExpandTreeNode with the rules defined |
4756
|
|
|
// in the proto definition for this message. If any rules are violated, the |
4757
|
|
|
// result is a list of violation errors wrapped in ExpandTreeNodeMultiError, |
4758
|
|
|
// or nil if none found. |
4759
|
|
|
func (m *ExpandTreeNode) ValidateAll() error { |
4760
|
|
|
return m.validate(true) |
4761
|
|
|
} |
4762
|
|
|
|
4763
|
|
|
func (m *ExpandTreeNode) validate(all bool) error { |
4764
|
|
|
if m == nil { |
4765
|
|
|
return nil |
4766
|
|
|
} |
4767
|
|
|
|
4768
|
|
|
var errors []error |
4769
|
|
|
|
4770
|
|
|
// no validation rules for Operation |
4771
|
|
|
|
4772
|
|
|
for idx, item := range m.GetChildren() { |
4773
|
|
|
_, _ = idx, item |
4774
|
|
|
|
4775
|
|
|
if all { |
4776
|
|
|
switch v := interface{}(item).(type) { |
4777
|
|
|
case interface{ ValidateAll() error }: |
4778
|
|
|
if err := v.ValidateAll(); err != nil { |
4779
|
|
|
errors = append(errors, ExpandTreeNodeValidationError{ |
4780
|
|
|
field: fmt.Sprintf("Children[%v]", idx), |
4781
|
|
|
reason: "embedded message failed validation", |
4782
|
|
|
cause: err, |
4783
|
|
|
}) |
4784
|
|
|
} |
4785
|
|
|
case interface{ Validate() error }: |
4786
|
|
|
if err := v.Validate(); err != nil { |
4787
|
|
|
errors = append(errors, ExpandTreeNodeValidationError{ |
4788
|
|
|
field: fmt.Sprintf("Children[%v]", idx), |
4789
|
|
|
reason: "embedded message failed validation", |
4790
|
|
|
cause: err, |
4791
|
|
|
}) |
4792
|
|
|
} |
4793
|
|
|
} |
4794
|
|
|
} else if v, ok := interface{}(item).(interface{ Validate() error }); ok { |
4795
|
|
|
if err := v.Validate(); err != nil { |
4796
|
|
|
return ExpandTreeNodeValidationError{ |
4797
|
|
|
field: fmt.Sprintf("Children[%v]", idx), |
4798
|
|
|
reason: "embedded message failed validation", |
4799
|
|
|
cause: err, |
4800
|
|
|
} |
4801
|
|
|
} |
4802
|
|
|
} |
4803
|
|
|
|
4804
|
|
|
} |
4805
|
|
|
|
4806
|
|
|
if len(errors) > 0 { |
4807
|
|
|
return ExpandTreeNodeMultiError(errors) |
4808
|
|
|
} |
4809
|
|
|
|
4810
|
|
|
return nil |
4811
|
|
|
} |
4812
|
|
|
|
4813
|
|
|
// ExpandTreeNodeMultiError is an error wrapping multiple validation errors |
4814
|
|
|
// returned by ExpandTreeNode.ValidateAll() if the designated constraints |
4815
|
|
|
// aren't met. |
4816
|
|
|
type ExpandTreeNodeMultiError []error |
4817
|
|
|
|
4818
|
|
|
// Error returns a concatenation of all the error messages it wraps. |
4819
|
|
|
func (m ExpandTreeNodeMultiError) Error() string { |
4820
|
|
|
var msgs []string |
4821
|
|
|
for _, err := range m { |
4822
|
|
|
msgs = append(msgs, err.Error()) |
4823
|
|
|
} |
4824
|
|
|
return strings.Join(msgs, "; ") |
4825
|
|
|
} |
4826
|
|
|
|
4827
|
|
|
// AllErrors returns a list of validation violation errors. |
4828
|
|
|
func (m ExpandTreeNodeMultiError) AllErrors() []error { return m } |
4829
|
|
|
|
4830
|
|
|
// ExpandTreeNodeValidationError is the validation error returned by |
4831
|
|
|
// ExpandTreeNode.Validate if the designated constraints aren't met. |
4832
|
|
|
type ExpandTreeNodeValidationError struct { |
4833
|
|
|
field string |
4834
|
|
|
reason string |
4835
|
|
|
cause error |
4836
|
|
|
key bool |
4837
|
|
|
} |
4838
|
|
|
|
4839
|
|
|
// Field function returns field value. |
4840
|
|
|
func (e ExpandTreeNodeValidationError) Field() string { return e.field } |
4841
|
|
|
|
4842
|
|
|
// Reason function returns reason value. |
4843
|
|
|
func (e ExpandTreeNodeValidationError) Reason() string { return e.reason } |
4844
|
|
|
|
4845
|
|
|
// Cause function returns cause value. |
4846
|
|
|
func (e ExpandTreeNodeValidationError) Cause() error { return e.cause } |
4847
|
|
|
|
4848
|
|
|
// Key function returns key value. |
4849
|
|
|
func (e ExpandTreeNodeValidationError) Key() bool { return e.key } |
4850
|
|
|
|
4851
|
|
|
// ErrorName returns error name. |
4852
|
|
|
func (e ExpandTreeNodeValidationError) ErrorName() string { return "ExpandTreeNodeValidationError" } |
4853
|
|
|
|
4854
|
|
|
// Error satisfies the builtin error interface |
4855
|
|
|
func (e ExpandTreeNodeValidationError) Error() string { |
4856
|
|
|
cause := "" |
4857
|
|
|
if e.cause != nil { |
4858
|
|
|
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
4859
|
|
|
} |
4860
|
|
|
|
4861
|
|
|
key := "" |
4862
|
|
|
if e.key { |
4863
|
|
|
key = "key for " |
4864
|
|
|
} |
4865
|
|
|
|
4866
|
|
|
return fmt.Sprintf( |
4867
|
|
|
"invalid %sExpandTreeNode.%s: %s%s", |
4868
|
|
|
key, |
4869
|
|
|
e.field, |
4870
|
|
|
e.reason, |
4871
|
|
|
cause) |
4872
|
|
|
} |
4873
|
|
|
|
4874
|
|
|
var _ error = ExpandTreeNodeValidationError{} |
4875
|
|
|
|
4876
|
|
|
var _ interface { |
4877
|
|
|
Field() string |
4878
|
|
|
Reason() string |
4879
|
|
|
Key() bool |
4880
|
|
|
Cause() error |
4881
|
|
|
ErrorName() string |
4882
|
|
|
} = ExpandTreeNodeValidationError{} |
4883
|
|
|
|
4884
|
|
|
// Validate checks the field values on Expand with the rules defined in the |
4885
|
|
|
// proto definition for this message. If any rules are violated, the first |
4886
|
|
|
// error encountered is returned, or nil if there are no violations. |
4887
|
|
|
func (m *Expand) Validate() error { |
4888
|
|
|
return m.validate(false) |
4889
|
|
|
} |
4890
|
|
|
|
4891
|
|
|
// ValidateAll checks the field values on Expand with the rules defined in the |
4892
|
|
|
// proto definition for this message. If any rules are violated, the result is |
4893
|
|
|
// a list of violation errors wrapped in ExpandMultiError, or nil if none found. |
4894
|
|
|
func (m *Expand) ValidateAll() error { |
4895
|
|
|
return m.validate(true) |
4896
|
|
|
} |
4897
|
|
|
|
4898
|
|
|
func (m *Expand) validate(all bool) error { |
4899
|
|
|
if m == nil { |
4900
|
|
|
return nil |
4901
|
|
|
} |
4902
|
|
|
|
4903
|
|
|
var errors []error |
4904
|
|
|
|
4905
|
|
|
if all { |
4906
|
|
|
switch v := interface{}(m.GetEntity()).(type) { |
4907
|
|
|
case interface{ ValidateAll() error }: |
4908
|
|
|
if err := v.ValidateAll(); err != nil { |
4909
|
|
|
errors = append(errors, ExpandValidationError{ |
4910
|
|
|
field: "Entity", |
4911
|
|
|
reason: "embedded message failed validation", |
4912
|
|
|
cause: err, |
4913
|
|
|
}) |
4914
|
|
|
} |
4915
|
|
|
case interface{ Validate() error }: |
4916
|
|
|
if err := v.Validate(); err != nil { |
4917
|
|
|
errors = append(errors, ExpandValidationError{ |
4918
|
|
|
field: "Entity", |
4919
|
|
|
reason: "embedded message failed validation", |
4920
|
|
|
cause: err, |
4921
|
|
|
}) |
4922
|
|
|
} |
4923
|
|
|
} |
4924
|
|
|
} else if v, ok := interface{}(m.GetEntity()).(interface{ Validate() error }); ok { |
4925
|
|
|
if err := v.Validate(); err != nil { |
4926
|
|
|
return ExpandValidationError{ |
4927
|
|
|
field: "Entity", |
4928
|
|
|
reason: "embedded message failed validation", |
4929
|
|
|
cause: err, |
4930
|
|
|
} |
4931
|
|
|
} |
4932
|
|
|
} |
4933
|
|
|
|
4934
|
|
|
// no validation rules for Permission |
4935
|
|
|
|
4936
|
|
|
for idx, item := range m.GetArguments() { |
4937
|
|
|
_, _ = idx, item |
4938
|
|
|
|
4939
|
|
|
if all { |
4940
|
|
|
switch v := interface{}(item).(type) { |
4941
|
|
|
case interface{ ValidateAll() error }: |
4942
|
|
|
if err := v.ValidateAll(); err != nil { |
4943
|
|
|
errors = append(errors, ExpandValidationError{ |
4944
|
|
|
field: fmt.Sprintf("Arguments[%v]", idx), |
4945
|
|
|
reason: "embedded message failed validation", |
4946
|
|
|
cause: err, |
4947
|
|
|
}) |
4948
|
|
|
} |
4949
|
|
|
case interface{ Validate() error }: |
4950
|
|
|
if err := v.Validate(); err != nil { |
4951
|
|
|
errors = append(errors, ExpandValidationError{ |
4952
|
|
|
field: fmt.Sprintf("Arguments[%v]", idx), |
4953
|
|
|
reason: "embedded message failed validation", |
4954
|
|
|
cause: err, |
4955
|
|
|
}) |
4956
|
|
|
} |
4957
|
|
|
} |
4958
|
|
|
} else if v, ok := interface{}(item).(interface{ Validate() error }); ok { |
4959
|
|
|
if err := v.Validate(); err != nil { |
4960
|
|
|
return ExpandValidationError{ |
4961
|
|
|
field: fmt.Sprintf("Arguments[%v]", idx), |
4962
|
|
|
reason: "embedded message failed validation", |
4963
|
|
|
cause: err, |
4964
|
|
|
} |
4965
|
|
|
} |
4966
|
|
|
} |
4967
|
|
|
|
4968
|
|
|
} |
4969
|
|
|
|
4970
|
|
|
switch v := m.Node.(type) { |
4971
|
|
|
case *Expand_Expand: |
4972
|
|
|
if v == nil { |
4973
|
|
|
err := ExpandValidationError{ |
4974
|
|
|
field: "Node", |
4975
|
|
|
reason: "oneof value cannot be a typed-nil", |
4976
|
|
|
} |
4977
|
|
|
if !all { |
4978
|
|
|
return err |
4979
|
|
|
} |
4980
|
|
|
errors = append(errors, err) |
4981
|
|
|
} |
4982
|
|
|
|
4983
|
|
|
if all { |
4984
|
|
|
switch v := interface{}(m.GetExpand()).(type) { |
4985
|
|
|
case interface{ ValidateAll() error }: |
4986
|
|
|
if err := v.ValidateAll(); err != nil { |
4987
|
|
|
errors = append(errors, ExpandValidationError{ |
4988
|
|
|
field: "Expand", |
4989
|
|
|
reason: "embedded message failed validation", |
4990
|
|
|
cause: err, |
4991
|
|
|
}) |
4992
|
|
|
} |
4993
|
|
|
case interface{ Validate() error }: |
4994
|
|
|
if err := v.Validate(); err != nil { |
4995
|
|
|
errors = append(errors, ExpandValidationError{ |
4996
|
|
|
field: "Expand", |
4997
|
|
|
reason: "embedded message failed validation", |
4998
|
|
|
cause: err, |
4999
|
|
|
}) |
5000
|
|
|
} |
5001
|
|
|
} |
5002
|
|
|
} else if v, ok := interface{}(m.GetExpand()).(interface{ Validate() error }); ok { |
5003
|
|
|
if err := v.Validate(); err != nil { |
5004
|
|
|
return ExpandValidationError{ |
5005
|
|
|
field: "Expand", |
5006
|
|
|
reason: "embedded message failed validation", |
5007
|
|
|
cause: err, |
5008
|
|
|
} |
5009
|
|
|
} |
5010
|
|
|
} |
5011
|
|
|
|
5012
|
|
|
case *Expand_Leaf: |
5013
|
|
|
if v == nil { |
5014
|
|
|
err := ExpandValidationError{ |
5015
|
|
|
field: "Node", |
5016
|
|
|
reason: "oneof value cannot be a typed-nil", |
5017
|
|
|
} |
5018
|
|
|
if !all { |
5019
|
|
|
return err |
5020
|
|
|
} |
5021
|
|
|
errors = append(errors, err) |
5022
|
|
|
} |
5023
|
|
|
|
5024
|
|
|
if all { |
5025
|
|
|
switch v := interface{}(m.GetLeaf()).(type) { |
5026
|
|
|
case interface{ ValidateAll() error }: |
5027
|
|
|
if err := v.ValidateAll(); err != nil { |
5028
|
|
|
errors = append(errors, ExpandValidationError{ |
5029
|
|
|
field: "Leaf", |
5030
|
|
|
reason: "embedded message failed validation", |
5031
|
|
|
cause: err, |
5032
|
|
|
}) |
5033
|
|
|
} |
5034
|
|
|
case interface{ Validate() error }: |
5035
|
|
|
if err := v.Validate(); err != nil { |
5036
|
|
|
errors = append(errors, ExpandValidationError{ |
5037
|
|
|
field: "Leaf", |
5038
|
|
|
reason: "embedded message failed validation", |
5039
|
|
|
cause: err, |
5040
|
|
|
}) |
5041
|
|
|
} |
5042
|
|
|
} |
5043
|
|
|
} else if v, ok := interface{}(m.GetLeaf()).(interface{ Validate() error }); ok { |
5044
|
|
|
if err := v.Validate(); err != nil { |
5045
|
|
|
return ExpandValidationError{ |
5046
|
|
|
field: "Leaf", |
5047
|
|
|
reason: "embedded message failed validation", |
5048
|
|
|
cause: err, |
5049
|
|
|
} |
5050
|
|
|
} |
5051
|
|
|
} |
5052
|
|
|
|
5053
|
|
|
default: |
5054
|
|
|
_ = v // ensures v is used |
5055
|
|
|
} |
5056
|
|
|
|
5057
|
|
|
if len(errors) > 0 { |
5058
|
|
|
return ExpandMultiError(errors) |
5059
|
|
|
} |
5060
|
|
|
|
5061
|
|
|
return nil |
5062
|
|
|
} |
5063
|
|
|
|
5064
|
|
|
// ExpandMultiError is an error wrapping multiple validation errors returned by |
5065
|
|
|
// Expand.ValidateAll() if the designated constraints aren't met. |
5066
|
|
|
type ExpandMultiError []error |
5067
|
|
|
|
5068
|
|
|
// Error returns a concatenation of all the error messages it wraps. |
5069
|
|
|
func (m ExpandMultiError) Error() string { |
5070
|
|
|
var msgs []string |
5071
|
|
|
for _, err := range m { |
5072
|
|
|
msgs = append(msgs, err.Error()) |
5073
|
|
|
} |
5074
|
|
|
return strings.Join(msgs, "; ") |
5075
|
|
|
} |
5076
|
|
|
|
5077
|
|
|
// AllErrors returns a list of validation violation errors. |
5078
|
|
|
func (m ExpandMultiError) AllErrors() []error { return m } |
5079
|
|
|
|
5080
|
|
|
// ExpandValidationError is the validation error returned by Expand.Validate if |
5081
|
|
|
// the designated constraints aren't met. |
5082
|
|
|
type ExpandValidationError struct { |
5083
|
|
|
field string |
5084
|
|
|
reason string |
5085
|
|
|
cause error |
5086
|
|
|
key bool |
5087
|
|
|
} |
5088
|
|
|
|
5089
|
|
|
// Field function returns field value. |
5090
|
|
|
func (e ExpandValidationError) Field() string { return e.field } |
5091
|
|
|
|
5092
|
|
|
// Reason function returns reason value. |
5093
|
|
|
func (e ExpandValidationError) Reason() string { return e.reason } |
5094
|
|
|
|
5095
|
|
|
// Cause function returns cause value. |
5096
|
|
|
func (e ExpandValidationError) Cause() error { return e.cause } |
5097
|
|
|
|
5098
|
|
|
// Key function returns key value. |
5099
|
|
|
func (e ExpandValidationError) Key() bool { return e.key } |
5100
|
|
|
|
5101
|
|
|
// ErrorName returns error name. |
5102
|
|
|
func (e ExpandValidationError) ErrorName() string { return "ExpandValidationError" } |
5103
|
|
|
|
5104
|
|
|
// Error satisfies the builtin error interface |
5105
|
|
|
func (e ExpandValidationError) Error() string { |
5106
|
|
|
cause := "" |
5107
|
|
|
if e.cause != nil { |
5108
|
|
|
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
5109
|
|
|
} |
5110
|
|
|
|
5111
|
|
|
key := "" |
5112
|
|
|
if e.key { |
5113
|
|
|
key = "key for " |
5114
|
|
|
} |
5115
|
|
|
|
5116
|
|
|
return fmt.Sprintf( |
5117
|
|
|
"invalid %sExpand.%s: %s%s", |
5118
|
|
|
key, |
5119
|
|
|
e.field, |
5120
|
|
|
e.reason, |
5121
|
|
|
cause) |
5122
|
|
|
} |
5123
|
|
|
|
5124
|
|
|
var _ error = ExpandValidationError{} |
5125
|
|
|
|
5126
|
|
|
var _ interface { |
5127
|
|
|
Field() string |
5128
|
|
|
Reason() string |
5129
|
|
|
Key() bool |
5130
|
|
|
Cause() error |
5131
|
|
|
ErrorName() string |
5132
|
|
|
} = ExpandValidationError{} |
5133
|
|
|
|
5134
|
|
|
// Validate checks the field values on ExpandLeaf with the rules defined in the |
5135
|
|
|
// proto definition for this message. If any rules are violated, the first |
5136
|
|
|
// error encountered is returned, or nil if there are no violations. |
5137
|
|
|
func (m *ExpandLeaf) Validate() error { |
5138
|
|
|
return m.validate(false) |
5139
|
|
|
} |
5140
|
|
|
|
5141
|
|
|
// ValidateAll checks the field values on ExpandLeaf with the rules defined in |
5142
|
|
|
// the proto definition for this message. If any rules are violated, the |
5143
|
|
|
// result is a list of violation errors wrapped in ExpandLeafMultiError, or |
5144
|
|
|
// nil if none found. |
5145
|
|
|
func (m *ExpandLeaf) ValidateAll() error { |
5146
|
|
|
return m.validate(true) |
5147
|
|
|
} |
5148
|
|
|
|
5149
|
|
|
func (m *ExpandLeaf) validate(all bool) error { |
5150
|
|
|
if m == nil { |
5151
|
|
|
return nil |
5152
|
|
|
} |
5153
|
|
|
|
5154
|
|
|
var errors []error |
5155
|
|
|
|
5156
|
|
|
oneofTypePresent := false |
5157
|
|
|
switch v := m.Type.(type) { |
5158
|
|
|
case *ExpandLeaf_Subjects: |
5159
|
|
|
if v == nil { |
5160
|
|
|
err := ExpandLeafValidationError{ |
5161
|
|
|
field: "Type", |
5162
|
|
|
reason: "oneof value cannot be a typed-nil", |
5163
|
|
|
} |
5164
|
|
|
if !all { |
5165
|
|
|
return err |
5166
|
|
|
} |
5167
|
|
|
errors = append(errors, err) |
5168
|
|
|
} |
5169
|
|
|
oneofTypePresent = true |
5170
|
|
|
|
5171
|
|
|
if all { |
5172
|
|
|
switch v := interface{}(m.GetSubjects()).(type) { |
5173
|
|
|
case interface{ ValidateAll() error }: |
5174
|
|
|
if err := v.ValidateAll(); err != nil { |
5175
|
|
|
errors = append(errors, ExpandLeafValidationError{ |
5176
|
|
|
field: "Subjects", |
5177
|
|
|
reason: "embedded message failed validation", |
5178
|
|
|
cause: err, |
5179
|
|
|
}) |
5180
|
|
|
} |
5181
|
|
|
case interface{ Validate() error }: |
5182
|
|
|
if err := v.Validate(); err != nil { |
5183
|
|
|
errors = append(errors, ExpandLeafValidationError{ |
5184
|
|
|
field: "Subjects", |
5185
|
|
|
reason: "embedded message failed validation", |
5186
|
|
|
cause: err, |
5187
|
|
|
}) |
5188
|
|
|
} |
5189
|
|
|
} |
5190
|
|
|
} else if v, ok := interface{}(m.GetSubjects()).(interface{ Validate() error }); ok { |
5191
|
|
|
if err := v.Validate(); err != nil { |
5192
|
|
|
return ExpandLeafValidationError{ |
5193
|
|
|
field: "Subjects", |
5194
|
|
|
reason: "embedded message failed validation", |
5195
|
|
|
cause: err, |
5196
|
|
|
} |
5197
|
|
|
} |
5198
|
|
|
} |
5199
|
|
|
|
5200
|
|
|
case *ExpandLeaf_Values: |
5201
|
|
|
if v == nil { |
5202
|
|
|
err := ExpandLeafValidationError{ |
5203
|
|
|
field: "Type", |
5204
|
|
|
reason: "oneof value cannot be a typed-nil", |
5205
|
|
|
} |
5206
|
|
|
if !all { |
5207
|
|
|
return err |
5208
|
|
|
} |
5209
|
|
|
errors = append(errors, err) |
5210
|
|
|
} |
5211
|
|
|
oneofTypePresent = true |
5212
|
|
|
|
5213
|
|
|
if all { |
5214
|
|
|
switch v := interface{}(m.GetValues()).(type) { |
5215
|
|
|
case interface{ ValidateAll() error }: |
5216
|
|
|
if err := v.ValidateAll(); err != nil { |
5217
|
|
|
errors = append(errors, ExpandLeafValidationError{ |
5218
|
|
|
field: "Values", |
5219
|
|
|
reason: "embedded message failed validation", |
5220
|
|
|
cause: err, |
5221
|
|
|
}) |
5222
|
|
|
} |
5223
|
|
|
case interface{ Validate() error }: |
5224
|
|
|
if err := v.Validate(); err != nil { |
5225
|
|
|
errors = append(errors, ExpandLeafValidationError{ |
5226
|
|
|
field: "Values", |
5227
|
|
|
reason: "embedded message failed validation", |
5228
|
|
|
cause: err, |
5229
|
|
|
}) |
5230
|
|
|
} |
5231
|
|
|
} |
5232
|
|
|
} else if v, ok := interface{}(m.GetValues()).(interface{ Validate() error }); ok { |
5233
|
|
|
if err := v.Validate(); err != nil { |
5234
|
|
|
return ExpandLeafValidationError{ |
5235
|
|
|
field: "Values", |
5236
|
|
|
reason: "embedded message failed validation", |
5237
|
|
|
cause: err, |
5238
|
|
|
} |
5239
|
|
|
} |
5240
|
|
|
} |
5241
|
|
|
|
5242
|
|
|
case *ExpandLeaf_Value: |
5243
|
|
|
if v == nil { |
5244
|
|
|
err := ExpandLeafValidationError{ |
5245
|
|
|
field: "Type", |
5246
|
|
|
reason: "oneof value cannot be a typed-nil", |
5247
|
|
|
} |
5248
|
|
|
if !all { |
5249
|
|
|
return err |
5250
|
|
|
} |
5251
|
|
|
errors = append(errors, err) |
5252
|
|
|
} |
5253
|
|
|
oneofTypePresent = true |
5254
|
|
|
|
5255
|
|
|
if all { |
5256
|
|
|
switch v := interface{}(m.GetValue()).(type) { |
5257
|
|
|
case interface{ ValidateAll() error }: |
5258
|
|
|
if err := v.ValidateAll(); err != nil { |
5259
|
|
|
errors = append(errors, ExpandLeafValidationError{ |
5260
|
|
|
field: "Value", |
5261
|
|
|
reason: "embedded message failed validation", |
5262
|
|
|
cause: err, |
5263
|
|
|
}) |
5264
|
|
|
} |
5265
|
|
|
case interface{ Validate() error }: |
5266
|
|
|
if err := v.Validate(); err != nil { |
5267
|
|
|
errors = append(errors, ExpandLeafValidationError{ |
5268
|
|
|
field: "Value", |
5269
|
|
|
reason: "embedded message failed validation", |
5270
|
|
|
cause: err, |
5271
|
|
|
}) |
5272
|
|
|
} |
5273
|
|
|
} |
5274
|
|
|
} else if v, ok := interface{}(m.GetValue()).(interface{ Validate() error }); ok { |
5275
|
|
|
if err := v.Validate(); err != nil { |
5276
|
|
|
return ExpandLeafValidationError{ |
5277
|
|
|
field: "Value", |
5278
|
|
|
reason: "embedded message failed validation", |
5279
|
|
|
cause: err, |
5280
|
|
|
} |
5281
|
|
|
} |
5282
|
|
|
} |
5283
|
|
|
|
5284
|
|
|
default: |
5285
|
|
|
_ = v // ensures v is used |
5286
|
|
|
} |
5287
|
|
|
if !oneofTypePresent { |
5288
|
|
|
err := ExpandLeafValidationError{ |
5289
|
|
|
field: "Type", |
5290
|
|
|
reason: "value is required", |
5291
|
|
|
} |
5292
|
|
|
if !all { |
5293
|
|
|
return err |
5294
|
|
|
} |
5295
|
|
|
errors = append(errors, err) |
5296
|
|
|
} |
5297
|
|
|
|
5298
|
|
|
if len(errors) > 0 { |
5299
|
|
|
return ExpandLeafMultiError(errors) |
5300
|
|
|
} |
5301
|
|
|
|
5302
|
|
|
return nil |
5303
|
|
|
} |
5304
|
|
|
|
5305
|
|
|
// ExpandLeafMultiError is an error wrapping multiple validation errors |
5306
|
|
|
// returned by ExpandLeaf.ValidateAll() if the designated constraints aren't met. |
5307
|
|
|
type ExpandLeafMultiError []error |
5308
|
|
|
|
5309
|
|
|
// Error returns a concatenation of all the error messages it wraps. |
5310
|
|
|
func (m ExpandLeafMultiError) Error() string { |
5311
|
|
|
var msgs []string |
5312
|
|
|
for _, err := range m { |
5313
|
|
|
msgs = append(msgs, err.Error()) |
5314
|
|
|
} |
5315
|
|
|
return strings.Join(msgs, "; ") |
5316
|
|
|
} |
5317
|
|
|
|
5318
|
|
|
// AllErrors returns a list of validation violation errors. |
5319
|
|
|
func (m ExpandLeafMultiError) AllErrors() []error { return m } |
5320
|
|
|
|
5321
|
|
|
// ExpandLeafValidationError is the validation error returned by |
5322
|
|
|
// ExpandLeaf.Validate if the designated constraints aren't met. |
5323
|
|
|
type ExpandLeafValidationError struct { |
5324
|
|
|
field string |
5325
|
|
|
reason string |
5326
|
|
|
cause error |
5327
|
|
|
key bool |
5328
|
|
|
} |
5329
|
|
|
|
5330
|
|
|
// Field function returns field value. |
5331
|
|
|
func (e ExpandLeafValidationError) Field() string { return e.field } |
5332
|
|
|
|
5333
|
|
|
// Reason function returns reason value. |
5334
|
|
|
func (e ExpandLeafValidationError) Reason() string { return e.reason } |
5335
|
|
|
|
5336
|
|
|
// Cause function returns cause value. |
5337
|
|
|
func (e ExpandLeafValidationError) Cause() error { return e.cause } |
5338
|
|
|
|
5339
|
|
|
// Key function returns key value. |
5340
|
|
|
func (e ExpandLeafValidationError) Key() bool { return e.key } |
5341
|
|
|
|
5342
|
|
|
// ErrorName returns error name. |
5343
|
|
|
func (e ExpandLeafValidationError) ErrorName() string { return "ExpandLeafValidationError" } |
5344
|
|
|
|
5345
|
|
|
// Error satisfies the builtin error interface |
5346
|
|
|
func (e ExpandLeafValidationError) Error() string { |
5347
|
|
|
cause := "" |
5348
|
|
|
if e.cause != nil { |
5349
|
|
|
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
5350
|
|
|
} |
5351
|
|
|
|
5352
|
|
|
key := "" |
5353
|
|
|
if e.key { |
5354
|
|
|
key = "key for " |
5355
|
|
|
} |
5356
|
|
|
|
5357
|
|
|
return fmt.Sprintf( |
5358
|
|
|
"invalid %sExpandLeaf.%s: %s%s", |
5359
|
|
|
key, |
5360
|
|
|
e.field, |
5361
|
|
|
e.reason, |
5362
|
|
|
cause) |
5363
|
|
|
} |
5364
|
|
|
|
5365
|
|
|
var _ error = ExpandLeafValidationError{} |
5366
|
|
|
|
5367
|
|
|
var _ interface { |
5368
|
|
|
Field() string |
5369
|
|
|
Reason() string |
5370
|
|
|
Key() bool |
5371
|
|
|
Cause() error |
5372
|
|
|
ErrorName() string |
5373
|
|
|
} = ExpandLeafValidationError{} |
5374
|
|
|
|
5375
|
|
|
// Validate checks the field values on Values with the rules defined in the |
5376
|
|
|
// proto definition for this message. If any rules are violated, the first |
5377
|
|
|
// error encountered is returned, or nil if there are no violations. |
5378
|
|
|
func (m *Values) Validate() error { |
5379
|
|
|
return m.validate(false) |
5380
|
|
|
} |
5381
|
|
|
|
5382
|
|
|
// ValidateAll checks the field values on Values with the rules defined in the |
5383
|
|
|
// proto definition for this message. If any rules are violated, the result is |
5384
|
|
|
// a list of violation errors wrapped in ValuesMultiError, or nil if none found. |
5385
|
|
|
func (m *Values) ValidateAll() error { |
5386
|
|
|
return m.validate(true) |
5387
|
|
|
} |
5388
|
|
|
|
5389
|
|
|
func (m *Values) validate(all bool) error { |
5390
|
|
|
if m == nil { |
5391
|
|
|
return nil |
5392
|
|
|
} |
5393
|
|
|
|
5394
|
|
|
var errors []error |
5395
|
|
|
|
5396
|
|
|
{ |
5397
|
|
|
sorted_keys := make([]string, len(m.GetValues())) |
5398
|
|
|
i := 0 |
5399
|
|
|
for key := range m.GetValues() { |
5400
|
|
|
sorted_keys[i] = key |
5401
|
|
|
i++ |
5402
|
|
|
} |
5403
|
|
|
sort.Slice(sorted_keys, func(i, j int) bool { return sorted_keys[i] < sorted_keys[j] }) |
5404
|
|
|
for _, key := range sorted_keys { |
5405
|
|
|
val := m.GetValues()[key] |
5406
|
|
|
_ = val |
5407
|
|
|
|
5408
|
|
|
// no validation rules for Values[key] |
5409
|
|
|
|
5410
|
|
|
if all { |
5411
|
|
|
switch v := interface{}(val).(type) { |
5412
|
|
|
case interface{ ValidateAll() error }: |
5413
|
|
|
if err := v.ValidateAll(); err != nil { |
5414
|
|
|
errors = append(errors, ValuesValidationError{ |
5415
|
|
|
field: fmt.Sprintf("Values[%v]", key), |
5416
|
|
|
reason: "embedded message failed validation", |
5417
|
|
|
cause: err, |
5418
|
|
|
}) |
5419
|
|
|
} |
5420
|
|
|
case interface{ Validate() error }: |
5421
|
|
|
if err := v.Validate(); err != nil { |
5422
|
|
|
errors = append(errors, ValuesValidationError{ |
5423
|
|
|
field: fmt.Sprintf("Values[%v]", key), |
5424
|
|
|
reason: "embedded message failed validation", |
5425
|
|
|
cause: err, |
5426
|
|
|
}) |
5427
|
|
|
} |
5428
|
|
|
} |
5429
|
|
|
} else if v, ok := interface{}(val).(interface{ Validate() error }); ok { |
5430
|
|
|
if err := v.Validate(); err != nil { |
5431
|
|
|
return ValuesValidationError{ |
5432
|
|
|
field: fmt.Sprintf("Values[%v]", key), |
5433
|
|
|
reason: "embedded message failed validation", |
5434
|
|
|
cause: err, |
5435
|
|
|
} |
5436
|
|
|
} |
5437
|
|
|
} |
5438
|
|
|
|
5439
|
|
|
} |
5440
|
|
|
} |
5441
|
|
|
|
5442
|
|
|
if len(errors) > 0 { |
5443
|
|
|
return ValuesMultiError(errors) |
5444
|
|
|
} |
5445
|
|
|
|
5446
|
|
|
return nil |
5447
|
|
|
} |
5448
|
|
|
|
5449
|
|
|
// ValuesMultiError is an error wrapping multiple validation errors returned by |
5450
|
|
|
// Values.ValidateAll() if the designated constraints aren't met. |
5451
|
|
|
type ValuesMultiError []error |
5452
|
|
|
|
5453
|
|
|
// Error returns a concatenation of all the error messages it wraps. |
5454
|
|
|
func (m ValuesMultiError) Error() string { |
5455
|
|
|
var msgs []string |
5456
|
|
|
for _, err := range m { |
5457
|
|
|
msgs = append(msgs, err.Error()) |
5458
|
|
|
} |
5459
|
|
|
return strings.Join(msgs, "; ") |
5460
|
|
|
} |
5461
|
|
|
|
5462
|
|
|
// AllErrors returns a list of validation violation errors. |
5463
|
|
|
func (m ValuesMultiError) AllErrors() []error { return m } |
5464
|
|
|
|
5465
|
|
|
// ValuesValidationError is the validation error returned by Values.Validate if |
5466
|
|
|
// the designated constraints aren't met. |
5467
|
|
|
type ValuesValidationError struct { |
5468
|
|
|
field string |
5469
|
|
|
reason string |
5470
|
|
|
cause error |
5471
|
|
|
key bool |
5472
|
|
|
} |
5473
|
|
|
|
5474
|
|
|
// Field function returns field value. |
5475
|
|
|
func (e ValuesValidationError) Field() string { return e.field } |
5476
|
|
|
|
5477
|
|
|
// Reason function returns reason value. |
5478
|
|
|
func (e ValuesValidationError) Reason() string { return e.reason } |
5479
|
|
|
|
5480
|
|
|
// Cause function returns cause value. |
5481
|
|
|
func (e ValuesValidationError) Cause() error { return e.cause } |
5482
|
|
|
|
5483
|
|
|
// Key function returns key value. |
5484
|
|
|
func (e ValuesValidationError) Key() bool { return e.key } |
5485
|
|
|
|
5486
|
|
|
// ErrorName returns error name. |
5487
|
|
|
func (e ValuesValidationError) ErrorName() string { return "ValuesValidationError" } |
5488
|
|
|
|
5489
|
|
|
// Error satisfies the builtin error interface |
5490
|
|
|
func (e ValuesValidationError) Error() string { |
5491
|
|
|
cause := "" |
5492
|
|
|
if e.cause != nil { |
5493
|
|
|
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
5494
|
|
|
} |
5495
|
|
|
|
5496
|
|
|
key := "" |
5497
|
|
|
if e.key { |
5498
|
|
|
key = "key for " |
5499
|
|
|
} |
5500
|
|
|
|
5501
|
|
|
return fmt.Sprintf( |
5502
|
|
|
"invalid %sValues.%s: %s%s", |
5503
|
|
|
key, |
5504
|
|
|
e.field, |
5505
|
|
|
e.reason, |
5506
|
|
|
cause) |
5507
|
|
|
} |
5508
|
|
|
|
5509
|
|
|
var _ error = ValuesValidationError{} |
5510
|
|
|
|
5511
|
|
|
var _ interface { |
5512
|
|
|
Field() string |
5513
|
|
|
Reason() string |
5514
|
|
|
Key() bool |
5515
|
|
|
Cause() error |
5516
|
|
|
ErrorName() string |
5517
|
|
|
} = ValuesValidationError{} |
5518
|
|
|
|
5519
|
|
|
// Validate checks the field values on Subjects with the rules defined in the |
5520
|
|
|
// proto definition for this message. If any rules are violated, the first |
5521
|
|
|
// error encountered is returned, or nil if there are no violations. |
5522
|
|
|
func (m *Subjects) Validate() error { |
5523
|
|
|
return m.validate(false) |
5524
|
|
|
} |
5525
|
|
|
|
5526
|
|
|
// ValidateAll checks the field values on Subjects with the rules defined in |
5527
|
|
|
// the proto definition for this message. If any rules are violated, the |
5528
|
|
|
// result is a list of violation errors wrapped in SubjectsMultiError, or nil |
5529
|
|
|
// if none found. |
5530
|
|
|
func (m *Subjects) ValidateAll() error { |
5531
|
|
|
return m.validate(true) |
5532
|
|
|
} |
5533
|
|
|
|
5534
|
|
|
func (m *Subjects) validate(all bool) error { |
5535
|
|
|
if m == nil { |
5536
|
|
|
return nil |
5537
|
|
|
} |
5538
|
|
|
|
5539
|
|
|
var errors []error |
5540
|
|
|
|
5541
|
|
|
for idx, item := range m.GetSubjects() { |
5542
|
|
|
_, _ = idx, item |
5543
|
|
|
|
5544
|
|
|
if all { |
5545
|
|
|
switch v := interface{}(item).(type) { |
5546
|
|
|
case interface{ ValidateAll() error }: |
5547
|
|
|
if err := v.ValidateAll(); err != nil { |
5548
|
|
|
errors = append(errors, SubjectsValidationError{ |
5549
|
|
|
field: fmt.Sprintf("Subjects[%v]", idx), |
5550
|
|
|
reason: "embedded message failed validation", |
5551
|
|
|
cause: err, |
5552
|
|
|
}) |
5553
|
|
|
} |
5554
|
|
|
case interface{ Validate() error }: |
5555
|
|
|
if err := v.Validate(); err != nil { |
5556
|
|
|
errors = append(errors, SubjectsValidationError{ |
5557
|
|
|
field: fmt.Sprintf("Subjects[%v]", idx), |
5558
|
|
|
reason: "embedded message failed validation", |
5559
|
|
|
cause: err, |
5560
|
|
|
}) |
5561
|
|
|
} |
5562
|
|
|
} |
5563
|
|
|
} else if v, ok := interface{}(item).(interface{ Validate() error }); ok { |
5564
|
|
|
if err := v.Validate(); err != nil { |
5565
|
|
|
return SubjectsValidationError{ |
5566
|
|
|
field: fmt.Sprintf("Subjects[%v]", idx), |
5567
|
|
|
reason: "embedded message failed validation", |
5568
|
|
|
cause: err, |
5569
|
|
|
} |
5570
|
|
|
} |
5571
|
|
|
} |
5572
|
|
|
|
5573
|
|
|
} |
5574
|
|
|
|
5575
|
|
|
if len(errors) > 0 { |
5576
|
|
|
return SubjectsMultiError(errors) |
5577
|
|
|
} |
5578
|
|
|
|
5579
|
|
|
return nil |
5580
|
|
|
} |
5581
|
|
|
|
5582
|
|
|
// SubjectsMultiError is an error wrapping multiple validation errors returned |
5583
|
|
|
// by Subjects.ValidateAll() if the designated constraints aren't met. |
5584
|
|
|
type SubjectsMultiError []error |
5585
|
|
|
|
5586
|
|
|
// Error returns a concatenation of all the error messages it wraps. |
5587
|
|
|
func (m SubjectsMultiError) Error() string { |
5588
|
|
|
var msgs []string |
5589
|
|
|
for _, err := range m { |
5590
|
|
|
msgs = append(msgs, err.Error()) |
5591
|
|
|
} |
5592
|
|
|
return strings.Join(msgs, "; ") |
5593
|
|
|
} |
5594
|
|
|
|
5595
|
|
|
// AllErrors returns a list of validation violation errors. |
5596
|
|
|
func (m SubjectsMultiError) AllErrors() []error { return m } |
5597
|
|
|
|
5598
|
|
|
// SubjectsValidationError is the validation error returned by |
5599
|
|
|
// Subjects.Validate if the designated constraints aren't met. |
5600
|
|
|
type SubjectsValidationError struct { |
5601
|
|
|
field string |
5602
|
|
|
reason string |
5603
|
|
|
cause error |
5604
|
|
|
key bool |
5605
|
|
|
} |
5606
|
|
|
|
5607
|
|
|
// Field function returns field value. |
5608
|
|
|
func (e SubjectsValidationError) Field() string { return e.field } |
5609
|
|
|
|
5610
|
|
|
// Reason function returns reason value. |
5611
|
|
|
func (e SubjectsValidationError) Reason() string { return e.reason } |
5612
|
|
|
|
5613
|
|
|
// Cause function returns cause value. |
5614
|
|
|
func (e SubjectsValidationError) Cause() error { return e.cause } |
5615
|
|
|
|
5616
|
|
|
// Key function returns key value. |
5617
|
|
|
func (e SubjectsValidationError) Key() bool { return e.key } |
5618
|
|
|
|
5619
|
|
|
// ErrorName returns error name. |
5620
|
|
|
func (e SubjectsValidationError) ErrorName() string { return "SubjectsValidationError" } |
5621
|
|
|
|
5622
|
|
|
// Error satisfies the builtin error interface |
5623
|
|
|
func (e SubjectsValidationError) Error() string { |
5624
|
|
|
cause := "" |
5625
|
|
|
if e.cause != nil { |
5626
|
|
|
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
5627
|
|
|
} |
5628
|
|
|
|
5629
|
|
|
key := "" |
5630
|
|
|
if e.key { |
5631
|
|
|
key = "key for " |
5632
|
|
|
} |
5633
|
|
|
|
5634
|
|
|
return fmt.Sprintf( |
5635
|
|
|
"invalid %sSubjects.%s: %s%s", |
5636
|
|
|
key, |
5637
|
|
|
e.field, |
5638
|
|
|
e.reason, |
5639
|
|
|
cause) |
5640
|
|
|
} |
5641
|
|
|
|
5642
|
|
|
var _ error = SubjectsValidationError{} |
5643
|
|
|
|
5644
|
|
|
var _ interface { |
5645
|
|
|
Field() string |
5646
|
|
|
Reason() string |
5647
|
|
|
Key() bool |
5648
|
|
|
Cause() error |
5649
|
|
|
ErrorName() string |
5650
|
|
|
} = SubjectsValidationError{} |
5651
|
|
|
|
5652
|
|
|
// Validate checks the field values on Tenant with the rules defined in the |
5653
|
|
|
// proto definition for this message. If any rules are violated, the first |
5654
|
|
|
// error encountered is returned, or nil if there are no violations. |
5655
|
|
|
func (m *Tenant) Validate() error { |
5656
|
|
|
return m.validate(false) |
5657
|
|
|
} |
5658
|
|
|
|
5659
|
|
|
// ValidateAll checks the field values on Tenant with the rules defined in the |
5660
|
|
|
// proto definition for this message. If any rules are violated, the result is |
5661
|
|
|
// a list of violation errors wrapped in TenantMultiError, or nil if none found. |
5662
|
|
|
func (m *Tenant) ValidateAll() error { |
5663
|
|
|
return m.validate(true) |
5664
|
|
|
} |
5665
|
|
|
|
5666
|
|
|
func (m *Tenant) validate(all bool) error { |
5667
|
|
|
if m == nil { |
5668
|
|
|
return nil |
5669
|
|
|
} |
5670
|
|
|
|
5671
|
|
|
var errors []error |
5672
|
|
|
|
5673
|
|
|
// no validation rules for Id |
5674
|
|
|
|
5675
|
|
|
// no validation rules for Name |
5676
|
|
|
|
5677
|
|
|
if all { |
5678
|
|
|
switch v := interface{}(m.GetCreatedAt()).(type) { |
5679
|
|
|
case interface{ ValidateAll() error }: |
5680
|
|
|
if err := v.ValidateAll(); err != nil { |
5681
|
|
|
errors = append(errors, TenantValidationError{ |
5682
|
|
|
field: "CreatedAt", |
5683
|
|
|
reason: "embedded message failed validation", |
5684
|
|
|
cause: err, |
5685
|
|
|
}) |
5686
|
|
|
} |
5687
|
|
|
case interface{ Validate() error }: |
5688
|
|
|
if err := v.Validate(); err != nil { |
5689
|
|
|
errors = append(errors, TenantValidationError{ |
5690
|
|
|
field: "CreatedAt", |
5691
|
|
|
reason: "embedded message failed validation", |
5692
|
|
|
cause: err, |
5693
|
|
|
}) |
5694
|
|
|
} |
5695
|
|
|
} |
5696
|
|
|
} else if v, ok := interface{}(m.GetCreatedAt()).(interface{ Validate() error }); ok { |
5697
|
|
|
if err := v.Validate(); err != nil { |
5698
|
|
|
return TenantValidationError{ |
5699
|
|
|
field: "CreatedAt", |
5700
|
|
|
reason: "embedded message failed validation", |
5701
|
|
|
cause: err, |
5702
|
|
|
} |
5703
|
|
|
} |
5704
|
|
|
} |
5705
|
|
|
|
5706
|
|
|
if len(errors) > 0 { |
5707
|
|
|
return TenantMultiError(errors) |
5708
|
|
|
} |
5709
|
|
|
|
5710
|
|
|
return nil |
5711
|
|
|
} |
5712
|
|
|
|
5713
|
|
|
// TenantMultiError is an error wrapping multiple validation errors returned by |
5714
|
|
|
// Tenant.ValidateAll() if the designated constraints aren't met. |
5715
|
|
|
type TenantMultiError []error |
5716
|
|
|
|
5717
|
|
|
// Error returns a concatenation of all the error messages it wraps. |
5718
|
|
|
func (m TenantMultiError) Error() string { |
5719
|
|
|
var msgs []string |
5720
|
|
|
for _, err := range m { |
5721
|
|
|
msgs = append(msgs, err.Error()) |
5722
|
|
|
} |
5723
|
|
|
return strings.Join(msgs, "; ") |
5724
|
|
|
} |
5725
|
|
|
|
5726
|
|
|
// AllErrors returns a list of validation violation errors. |
5727
|
|
|
func (m TenantMultiError) AllErrors() []error { return m } |
5728
|
|
|
|
5729
|
|
|
// TenantValidationError is the validation error returned by Tenant.Validate if |
5730
|
|
|
// the designated constraints aren't met. |
5731
|
|
|
type TenantValidationError struct { |
5732
|
|
|
field string |
5733
|
|
|
reason string |
5734
|
|
|
cause error |
5735
|
|
|
key bool |
5736
|
|
|
} |
5737
|
|
|
|
5738
|
|
|
// Field function returns field value. |
5739
|
|
|
func (e TenantValidationError) Field() string { return e.field } |
5740
|
|
|
|
5741
|
|
|
// Reason function returns reason value. |
5742
|
|
|
func (e TenantValidationError) Reason() string { return e.reason } |
5743
|
|
|
|
5744
|
|
|
// Cause function returns cause value. |
5745
|
|
|
func (e TenantValidationError) Cause() error { return e.cause } |
5746
|
|
|
|
5747
|
|
|
// Key function returns key value. |
5748
|
|
|
func (e TenantValidationError) Key() bool { return e.key } |
5749
|
|
|
|
5750
|
|
|
// ErrorName returns error name. |
5751
|
|
|
func (e TenantValidationError) ErrorName() string { return "TenantValidationError" } |
5752
|
|
|
|
5753
|
|
|
// Error satisfies the builtin error interface |
5754
|
|
|
func (e TenantValidationError) Error() string { |
5755
|
|
|
cause := "" |
5756
|
|
|
if e.cause != nil { |
5757
|
|
|
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
5758
|
|
|
} |
5759
|
|
|
|
5760
|
|
|
key := "" |
5761
|
|
|
if e.key { |
5762
|
|
|
key = "key for " |
5763
|
|
|
} |
5764
|
|
|
|
5765
|
|
|
return fmt.Sprintf( |
5766
|
|
|
"invalid %sTenant.%s: %s%s", |
5767
|
|
|
key, |
5768
|
|
|
e.field, |
5769
|
|
|
e.reason, |
5770
|
|
|
cause) |
5771
|
|
|
} |
5772
|
|
|
|
5773
|
|
|
var _ error = TenantValidationError{} |
5774
|
|
|
|
5775
|
|
|
var _ interface { |
5776
|
|
|
Field() string |
5777
|
|
|
Reason() string |
5778
|
|
|
Key() bool |
5779
|
|
|
Cause() error |
5780
|
|
|
ErrorName() string |
5781
|
|
|
} = TenantValidationError{} |
5782
|
|
|
|
5783
|
|
|
// Validate checks the field values on DataChanges with the rules defined in |
5784
|
|
|
// the proto definition for this message. If any rules are violated, the first |
5785
|
|
|
// error encountered is returned, or nil if there are no violations. |
5786
|
|
|
func (m *DataChanges) Validate() error { |
5787
|
|
|
return m.validate(false) |
5788
|
|
|
} |
5789
|
|
|
|
5790
|
|
|
// ValidateAll checks the field values on DataChanges with the rules defined in |
5791
|
|
|
// the proto definition for this message. If any rules are violated, the |
5792
|
|
|
// result is a list of violation errors wrapped in DataChangesMultiError, or |
5793
|
|
|
// nil if none found. |
5794
|
|
|
func (m *DataChanges) ValidateAll() error { |
5795
|
|
|
return m.validate(true) |
5796
|
|
|
} |
5797
|
|
|
|
5798
|
|
|
func (m *DataChanges) validate(all bool) error { |
5799
|
|
|
if m == nil { |
5800
|
|
|
return nil |
5801
|
|
|
} |
5802
|
|
|
|
5803
|
|
|
var errors []error |
5804
|
|
|
|
5805
|
|
|
// no validation rules for SnapToken |
5806
|
|
|
|
5807
|
|
|
for idx, item := range m.GetDataChanges() { |
5808
|
|
|
_, _ = idx, item |
5809
|
|
|
|
5810
|
|
|
if all { |
5811
|
|
|
switch v := interface{}(item).(type) { |
5812
|
|
|
case interface{ ValidateAll() error }: |
5813
|
|
|
if err := v.ValidateAll(); err != nil { |
5814
|
|
|
errors = append(errors, DataChangesValidationError{ |
5815
|
|
|
field: fmt.Sprintf("DataChanges[%v]", idx), |
5816
|
|
|
reason: "embedded message failed validation", |
5817
|
|
|
cause: err, |
5818
|
|
|
}) |
5819
|
|
|
} |
5820
|
|
|
case interface{ Validate() error }: |
5821
|
|
|
if err := v.Validate(); err != nil { |
5822
|
|
|
errors = append(errors, DataChangesValidationError{ |
5823
|
|
|
field: fmt.Sprintf("DataChanges[%v]", idx), |
5824
|
|
|
reason: "embedded message failed validation", |
5825
|
|
|
cause: err, |
5826
|
|
|
}) |
5827
|
|
|
} |
5828
|
|
|
} |
5829
|
|
|
} else if v, ok := interface{}(item).(interface{ Validate() error }); ok { |
5830
|
|
|
if err := v.Validate(); err != nil { |
5831
|
|
|
return DataChangesValidationError{ |
5832
|
|
|
field: fmt.Sprintf("DataChanges[%v]", idx), |
5833
|
|
|
reason: "embedded message failed validation", |
5834
|
|
|
cause: err, |
5835
|
|
|
} |
5836
|
|
|
} |
5837
|
|
|
} |
5838
|
|
|
|
5839
|
|
|
} |
5840
|
|
|
|
5841
|
|
|
if len(errors) > 0 { |
5842
|
|
|
return DataChangesMultiError(errors) |
5843
|
|
|
} |
5844
|
|
|
|
5845
|
|
|
return nil |
5846
|
|
|
} |
5847
|
|
|
|
5848
|
|
|
// DataChangesMultiError is an error wrapping multiple validation errors |
5849
|
|
|
// returned by DataChanges.ValidateAll() if the designated constraints aren't met. |
5850
|
|
|
type DataChangesMultiError []error |
5851
|
|
|
|
5852
|
|
|
// Error returns a concatenation of all the error messages it wraps. |
5853
|
|
|
func (m DataChangesMultiError) Error() string { |
5854
|
|
|
var msgs []string |
5855
|
|
|
for _, err := range m { |
5856
|
|
|
msgs = append(msgs, err.Error()) |
5857
|
|
|
} |
5858
|
|
|
return strings.Join(msgs, "; ") |
5859
|
|
|
} |
5860
|
|
|
|
5861
|
|
|
// AllErrors returns a list of validation violation errors. |
5862
|
|
|
func (m DataChangesMultiError) AllErrors() []error { return m } |
5863
|
|
|
|
5864
|
|
|
// DataChangesValidationError is the validation error returned by |
5865
|
|
|
// DataChanges.Validate if the designated constraints aren't met. |
5866
|
|
|
type DataChangesValidationError struct { |
5867
|
|
|
field string |
5868
|
|
|
reason string |
5869
|
|
|
cause error |
5870
|
|
|
key bool |
5871
|
|
|
} |
5872
|
|
|
|
5873
|
|
|
// Field function returns field value. |
5874
|
|
|
func (e DataChangesValidationError) Field() string { return e.field } |
5875
|
|
|
|
5876
|
|
|
// Reason function returns reason value. |
5877
|
|
|
func (e DataChangesValidationError) Reason() string { return e.reason } |
5878
|
|
|
|
5879
|
|
|
// Cause function returns cause value. |
5880
|
|
|
func (e DataChangesValidationError) Cause() error { return e.cause } |
5881
|
|
|
|
5882
|
|
|
// Key function returns key value. |
5883
|
|
|
func (e DataChangesValidationError) Key() bool { return e.key } |
5884
|
|
|
|
5885
|
|
|
// ErrorName returns error name. |
5886
|
|
|
func (e DataChangesValidationError) ErrorName() string { return "DataChangesValidationError" } |
5887
|
|
|
|
5888
|
|
|
// Error satisfies the builtin error interface |
5889
|
|
|
func (e DataChangesValidationError) Error() string { |
5890
|
|
|
cause := "" |
5891
|
|
|
if e.cause != nil { |
5892
|
|
|
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
5893
|
|
|
} |
5894
|
|
|
|
5895
|
|
|
key := "" |
5896
|
|
|
if e.key { |
5897
|
|
|
key = "key for " |
5898
|
|
|
} |
5899
|
|
|
|
5900
|
|
|
return fmt.Sprintf( |
5901
|
|
|
"invalid %sDataChanges.%s: %s%s", |
5902
|
|
|
key, |
5903
|
|
|
e.field, |
5904
|
|
|
e.reason, |
5905
|
|
|
cause) |
5906
|
|
|
} |
5907
|
|
|
|
5908
|
|
|
var _ error = DataChangesValidationError{} |
5909
|
|
|
|
5910
|
|
|
var _ interface { |
5911
|
|
|
Field() string |
5912
|
|
|
Reason() string |
5913
|
|
|
Key() bool |
5914
|
|
|
Cause() error |
5915
|
|
|
ErrorName() string |
5916
|
|
|
} = DataChangesValidationError{} |
5917
|
|
|
|
5918
|
|
|
// Validate checks the field values on DataChange with the rules defined in the |
5919
|
|
|
// proto definition for this message. If any rules are violated, the first |
5920
|
|
|
// error encountered is returned, or nil if there are no violations. |
5921
|
|
|
func (m *DataChange) Validate() error { |
5922
|
|
|
return m.validate(false) |
5923
|
|
|
} |
5924
|
|
|
|
5925
|
|
|
// ValidateAll checks the field values on DataChange with the rules defined in |
5926
|
|
|
// the proto definition for this message. If any rules are violated, the |
5927
|
|
|
// result is a list of violation errors wrapped in DataChangeMultiError, or |
5928
|
|
|
// nil if none found. |
5929
|
|
|
func (m *DataChange) ValidateAll() error { |
5930
|
|
|
return m.validate(true) |
5931
|
|
|
} |
5932
|
|
|
|
5933
|
|
|
func (m *DataChange) validate(all bool) error { |
5934
|
|
|
if m == nil { |
5935
|
|
|
return nil |
5936
|
|
|
} |
5937
|
|
|
|
5938
|
|
|
var errors []error |
5939
|
|
|
|
5940
|
|
|
// no validation rules for Operation |
5941
|
|
|
|
5942
|
|
|
oneofTypePresent := false |
5943
|
|
|
switch v := m.Type.(type) { |
5944
|
|
|
case *DataChange_Tuple: |
5945
|
|
|
if v == nil { |
5946
|
|
|
err := DataChangeValidationError{ |
5947
|
|
|
field: "Type", |
5948
|
|
|
reason: "oneof value cannot be a typed-nil", |
5949
|
|
|
} |
5950
|
|
|
if !all { |
5951
|
|
|
return err |
5952
|
|
|
} |
5953
|
|
|
errors = append(errors, err) |
5954
|
|
|
} |
5955
|
|
|
oneofTypePresent = true |
5956
|
|
|
|
5957
|
|
|
if all { |
5958
|
|
|
switch v := interface{}(m.GetTuple()).(type) { |
5959
|
|
|
case interface{ ValidateAll() error }: |
5960
|
|
|
if err := v.ValidateAll(); err != nil { |
5961
|
|
|
errors = append(errors, DataChangeValidationError{ |
5962
|
|
|
field: "Tuple", |
5963
|
|
|
reason: "embedded message failed validation", |
5964
|
|
|
cause: err, |
5965
|
|
|
}) |
5966
|
|
|
} |
5967
|
|
|
case interface{ Validate() error }: |
5968
|
|
|
if err := v.Validate(); err != nil { |
5969
|
|
|
errors = append(errors, DataChangeValidationError{ |
5970
|
|
|
field: "Tuple", |
5971
|
|
|
reason: "embedded message failed validation", |
5972
|
|
|
cause: err, |
5973
|
|
|
}) |
5974
|
|
|
} |
5975
|
|
|
} |
5976
|
|
|
} else if v, ok := interface{}(m.GetTuple()).(interface{ Validate() error }); ok { |
5977
|
|
|
if err := v.Validate(); err != nil { |
5978
|
|
|
return DataChangeValidationError{ |
5979
|
|
|
field: "Tuple", |
5980
|
|
|
reason: "embedded message failed validation", |
5981
|
|
|
cause: err, |
5982
|
|
|
} |
5983
|
|
|
} |
5984
|
|
|
} |
5985
|
|
|
|
5986
|
|
|
case *DataChange_Attribute: |
5987
|
|
|
if v == nil { |
5988
|
|
|
err := DataChangeValidationError{ |
5989
|
|
|
field: "Type", |
5990
|
|
|
reason: "oneof value cannot be a typed-nil", |
5991
|
|
|
} |
5992
|
|
|
if !all { |
5993
|
|
|
return err |
5994
|
|
|
} |
5995
|
|
|
errors = append(errors, err) |
5996
|
|
|
} |
5997
|
|
|
oneofTypePresent = true |
5998
|
|
|
|
5999
|
|
|
if all { |
6000
|
|
|
switch v := interface{}(m.GetAttribute()).(type) { |
6001
|
|
|
case interface{ ValidateAll() error }: |
6002
|
|
|
if err := v.ValidateAll(); err != nil { |
6003
|
|
|
errors = append(errors, DataChangeValidationError{ |
6004
|
|
|
field: "Attribute", |
6005
|
|
|
reason: "embedded message failed validation", |
6006
|
|
|
cause: err, |
6007
|
|
|
}) |
6008
|
|
|
} |
6009
|
|
|
case interface{ Validate() error }: |
6010
|
|
|
if err := v.Validate(); err != nil { |
6011
|
|
|
errors = append(errors, DataChangeValidationError{ |
6012
|
|
|
field: "Attribute", |
6013
|
|
|
reason: "embedded message failed validation", |
6014
|
|
|
cause: err, |
6015
|
|
|
}) |
6016
|
|
|
} |
6017
|
|
|
} |
6018
|
|
|
} else if v, ok := interface{}(m.GetAttribute()).(interface{ Validate() error }); ok { |
6019
|
|
|
if err := v.Validate(); err != nil { |
6020
|
|
|
return DataChangeValidationError{ |
6021
|
|
|
field: "Attribute", |
6022
|
|
|
reason: "embedded message failed validation", |
6023
|
|
|
cause: err, |
6024
|
|
|
} |
6025
|
|
|
} |
6026
|
|
|
} |
6027
|
|
|
|
6028
|
|
|
default: |
6029
|
|
|
_ = v // ensures v is used |
6030
|
|
|
} |
6031
|
|
|
if !oneofTypePresent { |
6032
|
|
|
err := DataChangeValidationError{ |
6033
|
|
|
field: "Type", |
6034
|
|
|
reason: "value is required", |
6035
|
|
|
} |
6036
|
|
|
if !all { |
6037
|
|
|
return err |
6038
|
|
|
} |
6039
|
|
|
errors = append(errors, err) |
6040
|
|
|
} |
6041
|
|
|
|
6042
|
|
|
if len(errors) > 0 { |
6043
|
|
|
return DataChangeMultiError(errors) |
6044
|
|
|
} |
6045
|
|
|
|
6046
|
|
|
return nil |
6047
|
|
|
} |
6048
|
|
|
|
6049
|
|
|
// DataChangeMultiError is an error wrapping multiple validation errors |
6050
|
|
|
// returned by DataChange.ValidateAll() if the designated constraints aren't met. |
6051
|
|
|
type DataChangeMultiError []error |
6052
|
|
|
|
6053
|
|
|
// Error returns a concatenation of all the error messages it wraps. |
6054
|
|
|
func (m DataChangeMultiError) Error() string { |
6055
|
|
|
var msgs []string |
6056
|
|
|
for _, err := range m { |
6057
|
|
|
msgs = append(msgs, err.Error()) |
6058
|
|
|
} |
6059
|
|
|
return strings.Join(msgs, "; ") |
6060
|
|
|
} |
6061
|
|
|
|
6062
|
|
|
// AllErrors returns a list of validation violation errors. |
6063
|
|
|
func (m DataChangeMultiError) AllErrors() []error { return m } |
6064
|
|
|
|
6065
|
|
|
// DataChangeValidationError is the validation error returned by |
6066
|
|
|
// DataChange.Validate if the designated constraints aren't met. |
6067
|
|
|
type DataChangeValidationError struct { |
6068
|
|
|
field string |
6069
|
|
|
reason string |
6070
|
|
|
cause error |
6071
|
|
|
key bool |
6072
|
|
|
} |
6073
|
|
|
|
6074
|
|
|
// Field function returns field value. |
6075
|
|
|
func (e DataChangeValidationError) Field() string { return e.field } |
6076
|
|
|
|
6077
|
|
|
// Reason function returns reason value. |
6078
|
|
|
func (e DataChangeValidationError) Reason() string { return e.reason } |
6079
|
|
|
|
6080
|
|
|
// Cause function returns cause value. |
6081
|
|
|
func (e DataChangeValidationError) Cause() error { return e.cause } |
6082
|
|
|
|
6083
|
|
|
// Key function returns key value. |
6084
|
|
|
func (e DataChangeValidationError) Key() bool { return e.key } |
6085
|
|
|
|
6086
|
|
|
// ErrorName returns error name. |
6087
|
|
|
func (e DataChangeValidationError) ErrorName() string { return "DataChangeValidationError" } |
6088
|
|
|
|
6089
|
|
|
// Error satisfies the builtin error interface |
6090
|
|
|
func (e DataChangeValidationError) Error() string { |
6091
|
|
|
cause := "" |
6092
|
|
|
if e.cause != nil { |
6093
|
|
|
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
6094
|
|
|
} |
6095
|
|
|
|
6096
|
|
|
key := "" |
6097
|
|
|
if e.key { |
6098
|
|
|
key = "key for " |
6099
|
|
|
} |
6100
|
|
|
|
6101
|
|
|
return fmt.Sprintf( |
6102
|
|
|
"invalid %sDataChange.%s: %s%s", |
6103
|
|
|
key, |
6104
|
|
|
e.field, |
6105
|
|
|
e.reason, |
6106
|
|
|
cause) |
6107
|
|
|
} |
6108
|
|
|
|
6109
|
|
|
var _ error = DataChangeValidationError{} |
6110
|
|
|
|
6111
|
|
|
var _ interface { |
6112
|
|
|
Field() string |
6113
|
|
|
Reason() string |
6114
|
|
|
Key() bool |
6115
|
|
|
Cause() error |
6116
|
|
|
ErrorName() string |
6117
|
|
|
} = DataChangeValidationError{} |
6118
|
|
|
|
6119
|
|
|
// Validate checks the field values on StringValue with the rules defined in |
6120
|
|
|
// the proto definition for this message. If any rules are violated, the first |
6121
|
|
|
// error encountered is returned, or nil if there are no violations. |
6122
|
|
|
func (m *StringValue) Validate() error { |
6123
|
|
|
return m.validate(false) |
6124
|
|
|
} |
6125
|
|
|
|
6126
|
|
|
// ValidateAll checks the field values on StringValue with the rules defined in |
6127
|
|
|
// the proto definition for this message. If any rules are violated, the |
6128
|
|
|
// result is a list of violation errors wrapped in StringValueMultiError, or |
6129
|
|
|
// nil if none found. |
6130
|
|
|
func (m *StringValue) ValidateAll() error { |
6131
|
|
|
return m.validate(true) |
6132
|
|
|
} |
6133
|
|
|
|
6134
|
|
|
func (m *StringValue) validate(all bool) error { |
6135
|
|
|
if m == nil { |
6136
|
|
|
return nil |
6137
|
|
|
} |
6138
|
|
|
|
6139
|
|
|
var errors []error |
6140
|
|
|
|
6141
|
|
|
// no validation rules for Data |
6142
|
|
|
|
6143
|
|
|
if len(errors) > 0 { |
6144
|
|
|
return StringValueMultiError(errors) |
6145
|
|
|
} |
6146
|
|
|
|
6147
|
|
|
return nil |
6148
|
|
|
} |
6149
|
|
|
|
6150
|
|
|
// StringValueMultiError is an error wrapping multiple validation errors |
6151
|
|
|
// returned by StringValue.ValidateAll() if the designated constraints aren't met. |
6152
|
|
|
type StringValueMultiError []error |
6153
|
|
|
|
6154
|
|
|
// Error returns a concatenation of all the error messages it wraps. |
6155
|
|
|
func (m StringValueMultiError) Error() string { |
6156
|
|
|
var msgs []string |
6157
|
|
|
for _, err := range m { |
6158
|
|
|
msgs = append(msgs, err.Error()) |
6159
|
|
|
} |
6160
|
|
|
return strings.Join(msgs, "; ") |
6161
|
|
|
} |
6162
|
|
|
|
6163
|
|
|
// AllErrors returns a list of validation violation errors. |
6164
|
|
|
func (m StringValueMultiError) AllErrors() []error { return m } |
6165
|
|
|
|
6166
|
|
|
// StringValueValidationError is the validation error returned by |
6167
|
|
|
// StringValue.Validate if the designated constraints aren't met. |
6168
|
|
|
type StringValueValidationError struct { |
6169
|
|
|
field string |
6170
|
|
|
reason string |
6171
|
|
|
cause error |
6172
|
|
|
key bool |
6173
|
|
|
} |
6174
|
|
|
|
6175
|
|
|
// Field function returns field value. |
6176
|
|
|
func (e StringValueValidationError) Field() string { return e.field } |
6177
|
|
|
|
6178
|
|
|
// Reason function returns reason value. |
6179
|
|
|
func (e StringValueValidationError) Reason() string { return e.reason } |
6180
|
|
|
|
6181
|
|
|
// Cause function returns cause value. |
6182
|
|
|
func (e StringValueValidationError) Cause() error { return e.cause } |
6183
|
|
|
|
6184
|
|
|
// Key function returns key value. |
6185
|
|
|
func (e StringValueValidationError) Key() bool { return e.key } |
6186
|
|
|
|
6187
|
|
|
// ErrorName returns error name. |
6188
|
|
|
func (e StringValueValidationError) ErrorName() string { return "StringValueValidationError" } |
6189
|
|
|
|
6190
|
|
|
// Error satisfies the builtin error interface |
6191
|
|
|
func (e StringValueValidationError) Error() string { |
6192
|
|
|
cause := "" |
6193
|
|
|
if e.cause != nil { |
6194
|
|
|
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
6195
|
|
|
} |
6196
|
|
|
|
6197
|
|
|
key := "" |
6198
|
|
|
if e.key { |
6199
|
|
|
key = "key for " |
6200
|
|
|
} |
6201
|
|
|
|
6202
|
|
|
return fmt.Sprintf( |
6203
|
|
|
"invalid %sStringValue.%s: %s%s", |
6204
|
|
|
key, |
6205
|
|
|
e.field, |
6206
|
|
|
e.reason, |
6207
|
|
|
cause) |
6208
|
|
|
} |
6209
|
|
|
|
6210
|
|
|
var _ error = StringValueValidationError{} |
6211
|
|
|
|
6212
|
|
|
var _ interface { |
6213
|
|
|
Field() string |
6214
|
|
|
Reason() string |
6215
|
|
|
Key() bool |
6216
|
|
|
Cause() error |
6217
|
|
|
ErrorName() string |
6218
|
|
|
} = StringValueValidationError{} |
6219
|
|
|
|
6220
|
|
|
// Validate checks the field values on IntegerValue with the rules defined in |
6221
|
|
|
// the proto definition for this message. If any rules are violated, the first |
6222
|
|
|
// error encountered is returned, or nil if there are no violations. |
6223
|
|
|
func (m *IntegerValue) Validate() error { |
6224
|
|
|
return m.validate(false) |
6225
|
|
|
} |
6226
|
|
|
|
6227
|
|
|
// ValidateAll checks the field values on IntegerValue with the rules defined |
6228
|
|
|
// in the proto definition for this message. If any rules are violated, the |
6229
|
|
|
// result is a list of violation errors wrapped in IntegerValueMultiError, or |
6230
|
|
|
// nil if none found. |
6231
|
|
|
func (m *IntegerValue) ValidateAll() error { |
6232
|
|
|
return m.validate(true) |
6233
|
|
|
} |
6234
|
|
|
|
6235
|
|
|
func (m *IntegerValue) validate(all bool) error { |
6236
|
|
|
if m == nil { |
6237
|
|
|
return nil |
6238
|
|
|
} |
6239
|
|
|
|
6240
|
|
|
var errors []error |
6241
|
|
|
|
6242
|
|
|
// no validation rules for Data |
6243
|
|
|
|
6244
|
|
|
if len(errors) > 0 { |
6245
|
|
|
return IntegerValueMultiError(errors) |
6246
|
|
|
} |
6247
|
|
|
|
6248
|
|
|
return nil |
6249
|
|
|
} |
6250
|
|
|
|
6251
|
|
|
// IntegerValueMultiError is an error wrapping multiple validation errors |
6252
|
|
|
// returned by IntegerValue.ValidateAll() if the designated constraints aren't met. |
6253
|
|
|
type IntegerValueMultiError []error |
6254
|
|
|
|
6255
|
|
|
// Error returns a concatenation of all the error messages it wraps. |
6256
|
|
|
func (m IntegerValueMultiError) Error() string { |
6257
|
|
|
var msgs []string |
6258
|
|
|
for _, err := range m { |
6259
|
|
|
msgs = append(msgs, err.Error()) |
6260
|
|
|
} |
6261
|
|
|
return strings.Join(msgs, "; ") |
6262
|
|
|
} |
6263
|
|
|
|
6264
|
|
|
// AllErrors returns a list of validation violation errors. |
6265
|
|
|
func (m IntegerValueMultiError) AllErrors() []error { return m } |
6266
|
|
|
|
6267
|
|
|
// IntegerValueValidationError is the validation error returned by |
6268
|
|
|
// IntegerValue.Validate if the designated constraints aren't met. |
6269
|
|
|
type IntegerValueValidationError struct { |
6270
|
|
|
field string |
6271
|
|
|
reason string |
6272
|
|
|
cause error |
6273
|
|
|
key bool |
6274
|
|
|
} |
6275
|
|
|
|
6276
|
|
|
// Field function returns field value. |
6277
|
|
|
func (e IntegerValueValidationError) Field() string { return e.field } |
6278
|
|
|
|
6279
|
|
|
// Reason function returns reason value. |
6280
|
|
|
func (e IntegerValueValidationError) Reason() string { return e.reason } |
6281
|
|
|
|
6282
|
|
|
// Cause function returns cause value. |
6283
|
|
|
func (e IntegerValueValidationError) Cause() error { return e.cause } |
6284
|
|
|
|
6285
|
|
|
// Key function returns key value. |
6286
|
|
|
func (e IntegerValueValidationError) Key() bool { return e.key } |
6287
|
|
|
|
6288
|
|
|
// ErrorName returns error name. |
6289
|
|
|
func (e IntegerValueValidationError) ErrorName() string { return "IntegerValueValidationError" } |
6290
|
|
|
|
6291
|
|
|
// Error satisfies the builtin error interface |
6292
|
|
|
func (e IntegerValueValidationError) Error() string { |
6293
|
|
|
cause := "" |
6294
|
|
|
if e.cause != nil { |
6295
|
|
|
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
6296
|
|
|
} |
6297
|
|
|
|
6298
|
|
|
key := "" |
6299
|
|
|
if e.key { |
6300
|
|
|
key = "key for " |
6301
|
|
|
} |
6302
|
|
|
|
6303
|
|
|
return fmt.Sprintf( |
6304
|
|
|
"invalid %sIntegerValue.%s: %s%s", |
6305
|
|
|
key, |
6306
|
|
|
e.field, |
6307
|
|
|
e.reason, |
6308
|
|
|
cause) |
6309
|
|
|
} |
6310
|
|
|
|
6311
|
|
|
var _ error = IntegerValueValidationError{} |
6312
|
|
|
|
6313
|
|
|
var _ interface { |
6314
|
|
|
Field() string |
6315
|
|
|
Reason() string |
6316
|
|
|
Key() bool |
6317
|
|
|
Cause() error |
6318
|
|
|
ErrorName() string |
6319
|
|
|
} = IntegerValueValidationError{} |
6320
|
|
|
|
6321
|
|
|
// Validate checks the field values on DoubleValue with the rules defined in |
6322
|
|
|
// the proto definition for this message. If any rules are violated, the first |
6323
|
|
|
// error encountered is returned, or nil if there are no violations. |
6324
|
|
|
func (m *DoubleValue) Validate() error { |
6325
|
|
|
return m.validate(false) |
6326
|
|
|
} |
6327
|
|
|
|
6328
|
|
|
// ValidateAll checks the field values on DoubleValue with the rules defined in |
6329
|
|
|
// the proto definition for this message. If any rules are violated, the |
6330
|
|
|
// result is a list of violation errors wrapped in DoubleValueMultiError, or |
6331
|
|
|
// nil if none found. |
6332
|
|
|
func (m *DoubleValue) ValidateAll() error { |
6333
|
|
|
return m.validate(true) |
6334
|
|
|
} |
6335
|
|
|
|
6336
|
|
|
func (m *DoubleValue) validate(all bool) error { |
6337
|
|
|
if m == nil { |
6338
|
|
|
return nil |
6339
|
|
|
} |
6340
|
|
|
|
6341
|
|
|
var errors []error |
6342
|
|
|
|
6343
|
|
|
// no validation rules for Data |
6344
|
|
|
|
6345
|
|
|
if len(errors) > 0 { |
6346
|
|
|
return DoubleValueMultiError(errors) |
6347
|
|
|
} |
6348
|
|
|
|
6349
|
|
|
return nil |
6350
|
|
|
} |
6351
|
|
|
|
6352
|
|
|
// DoubleValueMultiError is an error wrapping multiple validation errors |
6353
|
|
|
// returned by DoubleValue.ValidateAll() if the designated constraints aren't met. |
6354
|
|
|
type DoubleValueMultiError []error |
6355
|
|
|
|
6356
|
|
|
// Error returns a concatenation of all the error messages it wraps. |
6357
|
|
|
func (m DoubleValueMultiError) Error() string { |
6358
|
|
|
var msgs []string |
6359
|
|
|
for _, err := range m { |
6360
|
|
|
msgs = append(msgs, err.Error()) |
6361
|
|
|
} |
6362
|
|
|
return strings.Join(msgs, "; ") |
6363
|
|
|
} |
6364
|
|
|
|
6365
|
|
|
// AllErrors returns a list of validation violation errors. |
6366
|
|
|
func (m DoubleValueMultiError) AllErrors() []error { return m } |
6367
|
|
|
|
6368
|
|
|
// DoubleValueValidationError is the validation error returned by |
6369
|
|
|
// DoubleValue.Validate if the designated constraints aren't met. |
6370
|
|
|
type DoubleValueValidationError struct { |
6371
|
|
|
field string |
6372
|
|
|
reason string |
6373
|
|
|
cause error |
6374
|
|
|
key bool |
6375
|
|
|
} |
6376
|
|
|
|
6377
|
|
|
// Field function returns field value. |
6378
|
|
|
func (e DoubleValueValidationError) Field() string { return e.field } |
6379
|
|
|
|
6380
|
|
|
// Reason function returns reason value. |
6381
|
|
|
func (e DoubleValueValidationError) Reason() string { return e.reason } |
6382
|
|
|
|
6383
|
|
|
// Cause function returns cause value. |
6384
|
|
|
func (e DoubleValueValidationError) Cause() error { return e.cause } |
6385
|
|
|
|
6386
|
|
|
// Key function returns key value. |
6387
|
|
|
func (e DoubleValueValidationError) Key() bool { return e.key } |
6388
|
|
|
|
6389
|
|
|
// ErrorName returns error name. |
6390
|
|
|
func (e DoubleValueValidationError) ErrorName() string { return "DoubleValueValidationError" } |
6391
|
|
|
|
6392
|
|
|
// Error satisfies the builtin error interface |
6393
|
|
|
func (e DoubleValueValidationError) Error() string { |
6394
|
|
|
cause := "" |
6395
|
|
|
if e.cause != nil { |
6396
|
|
|
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
6397
|
|
|
} |
6398
|
|
|
|
6399
|
|
|
key := "" |
6400
|
|
|
if e.key { |
6401
|
|
|
key = "key for " |
6402
|
|
|
} |
6403
|
|
|
|
6404
|
|
|
return fmt.Sprintf( |
6405
|
|
|
"invalid %sDoubleValue.%s: %s%s", |
6406
|
|
|
key, |
6407
|
|
|
e.field, |
6408
|
|
|
e.reason, |
6409
|
|
|
cause) |
6410
|
|
|
} |
6411
|
|
|
|
6412
|
|
|
var _ error = DoubleValueValidationError{} |
6413
|
|
|
|
6414
|
|
|
var _ interface { |
6415
|
|
|
Field() string |
6416
|
|
|
Reason() string |
6417
|
|
|
Key() bool |
6418
|
|
|
Cause() error |
6419
|
|
|
ErrorName() string |
6420
|
|
|
} = DoubleValueValidationError{} |
6421
|
|
|
|
6422
|
|
|
// Validate checks the field values on BooleanValue with the rules defined in |
6423
|
|
|
// the proto definition for this message. If any rules are violated, the first |
6424
|
|
|
// error encountered is returned, or nil if there are no violations. |
6425
|
|
|
func (m *BooleanValue) Validate() error { |
6426
|
|
|
return m.validate(false) |
6427
|
|
|
} |
6428
|
|
|
|
6429
|
|
|
// ValidateAll checks the field values on BooleanValue with the rules defined |
6430
|
|
|
// in the proto definition for this message. If any rules are violated, the |
6431
|
|
|
// result is a list of violation errors wrapped in BooleanValueMultiError, or |
6432
|
|
|
// nil if none found. |
6433
|
|
|
func (m *BooleanValue) ValidateAll() error { |
6434
|
|
|
return m.validate(true) |
6435
|
|
|
} |
6436
|
|
|
|
6437
|
|
|
func (m *BooleanValue) validate(all bool) error { |
6438
|
|
|
if m == nil { |
6439
|
|
|
return nil |
6440
|
|
|
} |
6441
|
|
|
|
6442
|
|
|
var errors []error |
6443
|
|
|
|
6444
|
|
|
// no validation rules for Data |
6445
|
|
|
|
6446
|
|
|
if len(errors) > 0 { |
6447
|
|
|
return BooleanValueMultiError(errors) |
6448
|
|
|
} |
6449
|
|
|
|
6450
|
|
|
return nil |
6451
|
|
|
} |
6452
|
|
|
|
6453
|
|
|
// BooleanValueMultiError is an error wrapping multiple validation errors |
6454
|
|
|
// returned by BooleanValue.ValidateAll() if the designated constraints aren't met. |
6455
|
|
|
type BooleanValueMultiError []error |
6456
|
|
|
|
6457
|
|
|
// Error returns a concatenation of all the error messages it wraps. |
6458
|
|
|
func (m BooleanValueMultiError) Error() string { |
6459
|
|
|
var msgs []string |
6460
|
|
|
for _, err := range m { |
6461
|
|
|
msgs = append(msgs, err.Error()) |
6462
|
|
|
} |
6463
|
|
|
return strings.Join(msgs, "; ") |
6464
|
|
|
} |
6465
|
|
|
|
6466
|
|
|
// AllErrors returns a list of validation violation errors. |
6467
|
|
|
func (m BooleanValueMultiError) AllErrors() []error { return m } |
6468
|
|
|
|
6469
|
|
|
// BooleanValueValidationError is the validation error returned by |
6470
|
|
|
// BooleanValue.Validate if the designated constraints aren't met. |
6471
|
|
|
type BooleanValueValidationError struct { |
6472
|
|
|
field string |
6473
|
|
|
reason string |
6474
|
|
|
cause error |
6475
|
|
|
key bool |
6476
|
|
|
} |
6477
|
|
|
|
6478
|
|
|
// Field function returns field value. |
6479
|
|
|
func (e BooleanValueValidationError) Field() string { return e.field } |
6480
|
|
|
|
6481
|
|
|
// Reason function returns reason value. |
6482
|
|
|
func (e BooleanValueValidationError) Reason() string { return e.reason } |
6483
|
|
|
|
6484
|
|
|
// Cause function returns cause value. |
6485
|
|
|
func (e BooleanValueValidationError) Cause() error { return e.cause } |
6486
|
|
|
|
6487
|
|
|
// Key function returns key value. |
6488
|
|
|
func (e BooleanValueValidationError) Key() bool { return e.key } |
6489
|
|
|
|
6490
|
|
|
// ErrorName returns error name. |
6491
|
|
|
func (e BooleanValueValidationError) ErrorName() string { return "BooleanValueValidationError" } |
6492
|
|
|
|
6493
|
|
|
// Error satisfies the builtin error interface |
6494
|
|
|
func (e BooleanValueValidationError) Error() string { |
6495
|
|
|
cause := "" |
6496
|
|
|
if e.cause != nil { |
6497
|
|
|
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
6498
|
|
|
} |
6499
|
|
|
|
6500
|
|
|
key := "" |
6501
|
|
|
if e.key { |
6502
|
|
|
key = "key for " |
6503
|
|
|
} |
6504
|
|
|
|
6505
|
|
|
return fmt.Sprintf( |
6506
|
|
|
"invalid %sBooleanValue.%s: %s%s", |
6507
|
|
|
key, |
6508
|
|
|
e.field, |
6509
|
|
|
e.reason, |
6510
|
|
|
cause) |
6511
|
|
|
} |
6512
|
|
|
|
6513
|
|
|
var _ error = BooleanValueValidationError{} |
6514
|
|
|
|
6515
|
|
|
var _ interface { |
6516
|
|
|
Field() string |
6517
|
|
|
Reason() string |
6518
|
|
|
Key() bool |
6519
|
|
|
Cause() error |
6520
|
|
|
ErrorName() string |
6521
|
|
|
} = BooleanValueValidationError{} |
6522
|
|
|
|
6523
|
|
|
// Validate checks the field values on StringArrayValue with the rules defined |
6524
|
|
|
// in the proto definition for this message. If any rules are violated, the |
6525
|
|
|
// first error encountered is returned, or nil if there are no violations. |
6526
|
|
|
func (m *StringArrayValue) Validate() error { |
6527
|
|
|
return m.validate(false) |
6528
|
|
|
} |
6529
|
|
|
|
6530
|
|
|
// ValidateAll checks the field values on StringArrayValue with the rules |
6531
|
|
|
// defined in the proto definition for this message. If any rules are |
6532
|
|
|
// violated, the result is a list of violation errors wrapped in |
6533
|
|
|
// StringArrayValueMultiError, or nil if none found. |
6534
|
|
|
func (m *StringArrayValue) ValidateAll() error { |
6535
|
|
|
return m.validate(true) |
6536
|
|
|
} |
6537
|
|
|
|
6538
|
|
|
func (m *StringArrayValue) validate(all bool) error { |
6539
|
|
|
if m == nil { |
6540
|
|
|
return nil |
6541
|
|
|
} |
6542
|
|
|
|
6543
|
|
|
var errors []error |
6544
|
|
|
|
6545
|
|
|
if len(errors) > 0 { |
6546
|
|
|
return StringArrayValueMultiError(errors) |
6547
|
|
|
} |
6548
|
|
|
|
6549
|
|
|
return nil |
6550
|
|
|
} |
6551
|
|
|
|
6552
|
|
|
// StringArrayValueMultiError is an error wrapping multiple validation errors |
6553
|
|
|
// returned by StringArrayValue.ValidateAll() if the designated constraints |
6554
|
|
|
// aren't met. |
6555
|
|
|
type StringArrayValueMultiError []error |
6556
|
|
|
|
6557
|
|
|
// Error returns a concatenation of all the error messages it wraps. |
6558
|
|
|
func (m StringArrayValueMultiError) Error() string { |
6559
|
|
|
var msgs []string |
6560
|
|
|
for _, err := range m { |
6561
|
|
|
msgs = append(msgs, err.Error()) |
6562
|
|
|
} |
6563
|
|
|
return strings.Join(msgs, "; ") |
6564
|
|
|
} |
6565
|
|
|
|
6566
|
|
|
// AllErrors returns a list of validation violation errors. |
6567
|
|
|
func (m StringArrayValueMultiError) AllErrors() []error { return m } |
6568
|
|
|
|
6569
|
|
|
// StringArrayValueValidationError is the validation error returned by |
6570
|
|
|
// StringArrayValue.Validate if the designated constraints aren't met. |
6571
|
|
|
type StringArrayValueValidationError struct { |
6572
|
|
|
field string |
6573
|
|
|
reason string |
6574
|
|
|
cause error |
6575
|
|
|
key bool |
6576
|
|
|
} |
6577
|
|
|
|
6578
|
|
|
// Field function returns field value. |
6579
|
|
|
func (e StringArrayValueValidationError) Field() string { return e.field } |
6580
|
|
|
|
6581
|
|
|
// Reason function returns reason value. |
6582
|
|
|
func (e StringArrayValueValidationError) Reason() string { return e.reason } |
6583
|
|
|
|
6584
|
|
|
// Cause function returns cause value. |
6585
|
|
|
func (e StringArrayValueValidationError) Cause() error { return e.cause } |
6586
|
|
|
|
6587
|
|
|
// Key function returns key value. |
6588
|
|
|
func (e StringArrayValueValidationError) Key() bool { return e.key } |
6589
|
|
|
|
6590
|
|
|
// ErrorName returns error name. |
6591
|
|
|
func (e StringArrayValueValidationError) ErrorName() string { return "StringArrayValueValidationError" } |
6592
|
|
|
|
6593
|
|
|
// Error satisfies the builtin error interface |
6594
|
|
|
func (e StringArrayValueValidationError) Error() string { |
6595
|
|
|
cause := "" |
6596
|
|
|
if e.cause != nil { |
6597
|
|
|
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
6598
|
|
|
} |
6599
|
|
|
|
6600
|
|
|
key := "" |
6601
|
|
|
if e.key { |
6602
|
|
|
key = "key for " |
6603
|
|
|
} |
6604
|
|
|
|
6605
|
|
|
return fmt.Sprintf( |
6606
|
|
|
"invalid %sStringArrayValue.%s: %s%s", |
6607
|
|
|
key, |
6608
|
|
|
e.field, |
6609
|
|
|
e.reason, |
6610
|
|
|
cause) |
6611
|
|
|
} |
6612
|
|
|
|
6613
|
|
|
var _ error = StringArrayValueValidationError{} |
6614
|
|
|
|
6615
|
|
|
var _ interface { |
6616
|
|
|
Field() string |
6617
|
|
|
Reason() string |
6618
|
|
|
Key() bool |
6619
|
|
|
Cause() error |
6620
|
|
|
ErrorName() string |
6621
|
|
|
} = StringArrayValueValidationError{} |
6622
|
|
|
|
6623
|
|
|
// Validate checks the field values on IntegerArrayValue with the rules defined |
6624
|
|
|
// in the proto definition for this message. If any rules are violated, the |
6625
|
|
|
// first error encountered is returned, or nil if there are no violations. |
6626
|
|
|
func (m *IntegerArrayValue) Validate() error { |
6627
|
|
|
return m.validate(false) |
6628
|
|
|
} |
6629
|
|
|
|
6630
|
|
|
// ValidateAll checks the field values on IntegerArrayValue with the rules |
6631
|
|
|
// defined in the proto definition for this message. If any rules are |
6632
|
|
|
// violated, the result is a list of violation errors wrapped in |
6633
|
|
|
// IntegerArrayValueMultiError, or nil if none found. |
6634
|
|
|
func (m *IntegerArrayValue) ValidateAll() error { |
6635
|
|
|
return m.validate(true) |
6636
|
|
|
} |
6637
|
|
|
|
6638
|
|
|
func (m *IntegerArrayValue) validate(all bool) error { |
6639
|
|
|
if m == nil { |
6640
|
|
|
return nil |
6641
|
|
|
} |
6642
|
|
|
|
6643
|
|
|
var errors []error |
6644
|
|
|
|
6645
|
|
|
if len(errors) > 0 { |
6646
|
|
|
return IntegerArrayValueMultiError(errors) |
6647
|
|
|
} |
6648
|
|
|
|
6649
|
|
|
return nil |
6650
|
|
|
} |
6651
|
|
|
|
6652
|
|
|
// IntegerArrayValueMultiError is an error wrapping multiple validation errors |
6653
|
|
|
// returned by IntegerArrayValue.ValidateAll() if the designated constraints |
6654
|
|
|
// aren't met. |
6655
|
|
|
type IntegerArrayValueMultiError []error |
6656
|
|
|
|
6657
|
|
|
// Error returns a concatenation of all the error messages it wraps. |
6658
|
|
|
func (m IntegerArrayValueMultiError) Error() string { |
6659
|
|
|
var msgs []string |
6660
|
|
|
for _, err := range m { |
6661
|
|
|
msgs = append(msgs, err.Error()) |
6662
|
|
|
} |
6663
|
|
|
return strings.Join(msgs, "; ") |
6664
|
|
|
} |
6665
|
|
|
|
6666
|
|
|
// AllErrors returns a list of validation violation errors. |
6667
|
|
|
func (m IntegerArrayValueMultiError) AllErrors() []error { return m } |
6668
|
|
|
|
6669
|
|
|
// IntegerArrayValueValidationError is the validation error returned by |
6670
|
|
|
// IntegerArrayValue.Validate if the designated constraints aren't met. |
6671
|
|
|
type IntegerArrayValueValidationError struct { |
6672
|
|
|
field string |
6673
|
|
|
reason string |
6674
|
|
|
cause error |
6675
|
|
|
key bool |
6676
|
|
|
} |
6677
|
|
|
|
6678
|
|
|
// Field function returns field value. |
6679
|
|
|
func (e IntegerArrayValueValidationError) Field() string { return e.field } |
6680
|
|
|
|
6681
|
|
|
// Reason function returns reason value. |
6682
|
|
|
func (e IntegerArrayValueValidationError) Reason() string { return e.reason } |
6683
|
|
|
|
6684
|
|
|
// Cause function returns cause value. |
6685
|
|
|
func (e IntegerArrayValueValidationError) Cause() error { return e.cause } |
6686
|
|
|
|
6687
|
|
|
// Key function returns key value. |
6688
|
|
|
func (e IntegerArrayValueValidationError) Key() bool { return e.key } |
6689
|
|
|
|
6690
|
|
|
// ErrorName returns error name. |
6691
|
|
|
func (e IntegerArrayValueValidationError) ErrorName() string { |
6692
|
|
|
return "IntegerArrayValueValidationError" |
6693
|
|
|
} |
6694
|
|
|
|
6695
|
|
|
// Error satisfies the builtin error interface |
6696
|
|
|
func (e IntegerArrayValueValidationError) Error() string { |
6697
|
|
|
cause := "" |
6698
|
|
|
if e.cause != nil { |
6699
|
|
|
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
6700
|
|
|
} |
6701
|
|
|
|
6702
|
|
|
key := "" |
6703
|
|
|
if e.key { |
6704
|
|
|
key = "key for " |
6705
|
|
|
} |
6706
|
|
|
|
6707
|
|
|
return fmt.Sprintf( |
6708
|
|
|
"invalid %sIntegerArrayValue.%s: %s%s", |
6709
|
|
|
key, |
6710
|
|
|
e.field, |
6711
|
|
|
e.reason, |
6712
|
|
|
cause) |
6713
|
|
|
} |
6714
|
|
|
|
6715
|
|
|
var _ error = IntegerArrayValueValidationError{} |
6716
|
|
|
|
6717
|
|
|
var _ interface { |
6718
|
|
|
Field() string |
6719
|
|
|
Reason() string |
6720
|
|
|
Key() bool |
6721
|
|
|
Cause() error |
6722
|
|
|
ErrorName() string |
6723
|
|
|
} = IntegerArrayValueValidationError{} |
6724
|
|
|
|
6725
|
|
|
// Validate checks the field values on DoubleArrayValue with the rules defined |
6726
|
|
|
// in the proto definition for this message. If any rules are violated, the |
6727
|
|
|
// first error encountered is returned, or nil if there are no violations. |
6728
|
|
|
func (m *DoubleArrayValue) Validate() error { |
6729
|
|
|
return m.validate(false) |
6730
|
|
|
} |
6731
|
|
|
|
6732
|
|
|
// ValidateAll checks the field values on DoubleArrayValue with the rules |
6733
|
|
|
// defined in the proto definition for this message. If any rules are |
6734
|
|
|
// violated, the result is a list of violation errors wrapped in |
6735
|
|
|
// DoubleArrayValueMultiError, or nil if none found. |
6736
|
|
|
func (m *DoubleArrayValue) ValidateAll() error { |
6737
|
|
|
return m.validate(true) |
6738
|
|
|
} |
6739
|
|
|
|
6740
|
|
|
func (m *DoubleArrayValue) validate(all bool) error { |
6741
|
|
|
if m == nil { |
6742
|
|
|
return nil |
6743
|
|
|
} |
6744
|
|
|
|
6745
|
|
|
var errors []error |
6746
|
|
|
|
6747
|
|
|
if len(errors) > 0 { |
6748
|
|
|
return DoubleArrayValueMultiError(errors) |
6749
|
|
|
} |
6750
|
|
|
|
6751
|
|
|
return nil |
6752
|
|
|
} |
6753
|
|
|
|
6754
|
|
|
// DoubleArrayValueMultiError is an error wrapping multiple validation errors |
6755
|
|
|
// returned by DoubleArrayValue.ValidateAll() if the designated constraints |
6756
|
|
|
// aren't met. |
6757
|
|
|
type DoubleArrayValueMultiError []error |
6758
|
|
|
|
6759
|
|
|
// Error returns a concatenation of all the error messages it wraps. |
6760
|
|
|
func (m DoubleArrayValueMultiError) Error() string { |
6761
|
|
|
var msgs []string |
6762
|
|
|
for _, err := range m { |
6763
|
|
|
msgs = append(msgs, err.Error()) |
6764
|
|
|
} |
6765
|
|
|
return strings.Join(msgs, "; ") |
6766
|
|
|
} |
6767
|
|
|
|
6768
|
|
|
// AllErrors returns a list of validation violation errors. |
6769
|
|
|
func (m DoubleArrayValueMultiError) AllErrors() []error { return m } |
6770
|
|
|
|
6771
|
|
|
// DoubleArrayValueValidationError is the validation error returned by |
6772
|
|
|
// DoubleArrayValue.Validate if the designated constraints aren't met. |
6773
|
|
|
type DoubleArrayValueValidationError struct { |
6774
|
|
|
field string |
6775
|
|
|
reason string |
6776
|
|
|
cause error |
6777
|
|
|
key bool |
6778
|
|
|
} |
6779
|
|
|
|
6780
|
|
|
// Field function returns field value. |
6781
|
|
|
func (e DoubleArrayValueValidationError) Field() string { return e.field } |
6782
|
|
|
|
6783
|
|
|
// Reason function returns reason value. |
6784
|
|
|
func (e DoubleArrayValueValidationError) Reason() string { return e.reason } |
6785
|
|
|
|
6786
|
|
|
// Cause function returns cause value. |
6787
|
|
|
func (e DoubleArrayValueValidationError) Cause() error { return e.cause } |
6788
|
|
|
|
6789
|
|
|
// Key function returns key value. |
6790
|
|
|
func (e DoubleArrayValueValidationError) Key() bool { return e.key } |
6791
|
|
|
|
6792
|
|
|
// ErrorName returns error name. |
6793
|
|
|
func (e DoubleArrayValueValidationError) ErrorName() string { return "DoubleArrayValueValidationError" } |
6794
|
|
|
|
6795
|
|
|
// Error satisfies the builtin error interface |
6796
|
|
|
func (e DoubleArrayValueValidationError) Error() string { |
6797
|
|
|
cause := "" |
6798
|
|
|
if e.cause != nil { |
6799
|
|
|
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
6800
|
|
|
} |
6801
|
|
|
|
6802
|
|
|
key := "" |
6803
|
|
|
if e.key { |
6804
|
|
|
key = "key for " |
6805
|
|
|
} |
6806
|
|
|
|
6807
|
|
|
return fmt.Sprintf( |
6808
|
|
|
"invalid %sDoubleArrayValue.%s: %s%s", |
6809
|
|
|
key, |
6810
|
|
|
e.field, |
6811
|
|
|
e.reason, |
6812
|
|
|
cause) |
6813
|
|
|
} |
6814
|
|
|
|
6815
|
|
|
var _ error = DoubleArrayValueValidationError{} |
6816
|
|
|
|
6817
|
|
|
var _ interface { |
6818
|
|
|
Field() string |
6819
|
|
|
Reason() string |
6820
|
|
|
Key() bool |
6821
|
|
|
Cause() error |
6822
|
|
|
ErrorName() string |
6823
|
|
|
} = DoubleArrayValueValidationError{} |
6824
|
|
|
|
6825
|
|
|
// Validate checks the field values on BooleanArrayValue with the rules defined |
6826
|
|
|
// in the proto definition for this message. If any rules are violated, the |
6827
|
|
|
// first error encountered is returned, or nil if there are no violations. |
6828
|
|
|
func (m *BooleanArrayValue) Validate() error { |
6829
|
|
|
return m.validate(false) |
6830
|
|
|
} |
6831
|
|
|
|
6832
|
|
|
// ValidateAll checks the field values on BooleanArrayValue with the rules |
6833
|
|
|
// defined in the proto definition for this message. If any rules are |
6834
|
|
|
// violated, the result is a list of violation errors wrapped in |
6835
|
|
|
// BooleanArrayValueMultiError, or nil if none found. |
6836
|
|
|
func (m *BooleanArrayValue) ValidateAll() error { |
6837
|
|
|
return m.validate(true) |
6838
|
|
|
} |
6839
|
|
|
|
6840
|
|
|
func (m *BooleanArrayValue) validate(all bool) error { |
6841
|
|
|
if m == nil { |
6842
|
|
|
return nil |
6843
|
|
|
} |
6844
|
|
|
|
6845
|
|
|
var errors []error |
6846
|
|
|
|
6847
|
|
|
if len(errors) > 0 { |
6848
|
|
|
return BooleanArrayValueMultiError(errors) |
6849
|
|
|
} |
6850
|
|
|
|
6851
|
|
|
return nil |
6852
|
|
|
} |
6853
|
|
|
|
6854
|
|
|
// BooleanArrayValueMultiError is an error wrapping multiple validation errors |
6855
|
|
|
// returned by BooleanArrayValue.ValidateAll() if the designated constraints |
6856
|
|
|
// aren't met. |
6857
|
|
|
type BooleanArrayValueMultiError []error |
6858
|
|
|
|
6859
|
|
|
// Error returns a concatenation of all the error messages it wraps. |
6860
|
|
|
func (m BooleanArrayValueMultiError) Error() string { |
6861
|
|
|
var msgs []string |
6862
|
|
|
for _, err := range m { |
6863
|
|
|
msgs = append(msgs, err.Error()) |
6864
|
|
|
} |
6865
|
|
|
return strings.Join(msgs, "; ") |
6866
|
|
|
} |
6867
|
|
|
|
6868
|
|
|
// AllErrors returns a list of validation violation errors. |
6869
|
|
|
func (m BooleanArrayValueMultiError) AllErrors() []error { return m } |
6870
|
|
|
|
6871
|
|
|
// BooleanArrayValueValidationError is the validation error returned by |
6872
|
|
|
// BooleanArrayValue.Validate if the designated constraints aren't met. |
6873
|
|
|
type BooleanArrayValueValidationError struct { |
6874
|
|
|
field string |
6875
|
|
|
reason string |
6876
|
|
|
cause error |
6877
|
|
|
key bool |
6878
|
|
|
} |
6879
|
|
|
|
6880
|
|
|
// Field function returns field value. |
6881
|
|
|
func (e BooleanArrayValueValidationError) Field() string { return e.field } |
6882
|
|
|
|
6883
|
|
|
// Reason function returns reason value. |
6884
|
|
|
func (e BooleanArrayValueValidationError) Reason() string { return e.reason } |
6885
|
|
|
|
6886
|
|
|
// Cause function returns cause value. |
6887
|
|
|
func (e BooleanArrayValueValidationError) Cause() error { return e.cause } |
6888
|
|
|
|
6889
|
|
|
// Key function returns key value. |
6890
|
|
|
func (e BooleanArrayValueValidationError) Key() bool { return e.key } |
6891
|
|
|
|
6892
|
|
|
// ErrorName returns error name. |
6893
|
|
|
func (e BooleanArrayValueValidationError) ErrorName() string { |
6894
|
|
|
return "BooleanArrayValueValidationError" |
6895
|
|
|
} |
6896
|
|
|
|
6897
|
|
|
// Error satisfies the builtin error interface |
6898
|
|
|
func (e BooleanArrayValueValidationError) Error() string { |
6899
|
|
|
cause := "" |
6900
|
|
|
if e.cause != nil { |
6901
|
|
|
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
6902
|
|
|
} |
6903
|
|
|
|
6904
|
|
|
key := "" |
6905
|
|
|
if e.key { |
6906
|
|
|
key = "key for " |
6907
|
|
|
} |
6908
|
|
|
|
6909
|
|
|
return fmt.Sprintf( |
6910
|
|
|
"invalid %sBooleanArrayValue.%s: %s%s", |
6911
|
|
|
key, |
6912
|
|
|
e.field, |
6913
|
|
|
e.reason, |
6914
|
|
|
cause) |
6915
|
|
|
} |
6916
|
|
|
|
6917
|
|
|
var _ error = BooleanArrayValueValidationError{} |
6918
|
|
|
|
6919
|
|
|
var _ interface { |
6920
|
|
|
Field() string |
6921
|
|
|
Reason() string |
6922
|
|
|
Key() bool |
6923
|
|
|
Cause() error |
6924
|
|
|
ErrorName() string |
6925
|
|
|
} = BooleanArrayValueValidationError{} |
6926
|
|
|
|
6927
|
|
|
// Validate checks the field values on DataBundle with the rules defined in the |
6928
|
|
|
// proto definition for this message. If any rules are violated, the first |
6929
|
|
|
// error encountered is returned, or nil if there are no violations. |
6930
|
|
|
func (m *DataBundle) Validate() error { |
6931
|
|
|
return m.validate(false) |
6932
|
|
|
} |
6933
|
|
|
|
6934
|
|
|
// ValidateAll checks the field values on DataBundle with the rules defined in |
6935
|
|
|
// the proto definition for this message. If any rules are violated, the |
6936
|
|
|
// result is a list of violation errors wrapped in DataBundleMultiError, or |
6937
|
|
|
// nil if none found. |
6938
|
|
|
func (m *DataBundle) ValidateAll() error { |
6939
|
|
|
return m.validate(true) |
6940
|
|
|
} |
6941
|
|
|
|
6942
|
|
|
func (m *DataBundle) validate(all bool) error { |
6943
|
|
|
if m == nil { |
6944
|
|
|
return nil |
6945
|
|
|
} |
6946
|
|
|
|
6947
|
|
|
var errors []error |
6948
|
|
|
|
6949
|
|
|
// no validation rules for Name |
6950
|
|
|
|
6951
|
|
|
for idx, item := range m.GetOperations() { |
6952
|
|
|
_, _ = idx, item |
6953
|
|
|
|
6954
|
|
|
if all { |
6955
|
|
|
switch v := interface{}(item).(type) { |
6956
|
|
|
case interface{ ValidateAll() error }: |
6957
|
|
|
if err := v.ValidateAll(); err != nil { |
6958
|
|
|
errors = append(errors, DataBundleValidationError{ |
6959
|
|
|
field: fmt.Sprintf("Operations[%v]", idx), |
6960
|
|
|
reason: "embedded message failed validation", |
6961
|
|
|
cause: err, |
6962
|
|
|
}) |
6963
|
|
|
} |
6964
|
|
|
case interface{ Validate() error }: |
6965
|
|
|
if err := v.Validate(); err != nil { |
6966
|
|
|
errors = append(errors, DataBundleValidationError{ |
6967
|
|
|
field: fmt.Sprintf("Operations[%v]", idx), |
6968
|
|
|
reason: "embedded message failed validation", |
6969
|
|
|
cause: err, |
6970
|
|
|
}) |
6971
|
|
|
} |
6972
|
|
|
} |
6973
|
|
|
} else if v, ok := interface{}(item).(interface{ Validate() error }); ok { |
6974
|
|
|
if err := v.Validate(); err != nil { |
6975
|
|
|
return DataBundleValidationError{ |
6976
|
|
|
field: fmt.Sprintf("Operations[%v]", idx), |
6977
|
|
|
reason: "embedded message failed validation", |
6978
|
|
|
cause: err, |
6979
|
|
|
} |
6980
|
|
|
} |
6981
|
|
|
} |
6982
|
|
|
|
6983
|
|
|
} |
6984
|
|
|
|
6985
|
|
|
if len(errors) > 0 { |
6986
|
|
|
return DataBundleMultiError(errors) |
6987
|
|
|
} |
6988
|
|
|
|
6989
|
|
|
return nil |
6990
|
|
|
} |
6991
|
|
|
|
6992
|
|
|
// DataBundleMultiError is an error wrapping multiple validation errors |
6993
|
|
|
// returned by DataBundle.ValidateAll() if the designated constraints aren't met. |
6994
|
|
|
type DataBundleMultiError []error |
6995
|
|
|
|
6996
|
|
|
// Error returns a concatenation of all the error messages it wraps. |
6997
|
|
|
func (m DataBundleMultiError) Error() string { |
6998
|
|
|
var msgs []string |
6999
|
|
|
for _, err := range m { |
7000
|
|
|
msgs = append(msgs, err.Error()) |
7001
|
|
|
} |
7002
|
|
|
return strings.Join(msgs, "; ") |
7003
|
|
|
} |
7004
|
|
|
|
7005
|
|
|
// AllErrors returns a list of validation violation errors. |
7006
|
|
|
func (m DataBundleMultiError) AllErrors() []error { return m } |
7007
|
|
|
|
7008
|
|
|
// DataBundleValidationError is the validation error returned by |
7009
|
|
|
// DataBundle.Validate if the designated constraints aren't met. |
7010
|
|
|
type DataBundleValidationError struct { |
7011
|
|
|
field string |
7012
|
|
|
reason string |
7013
|
|
|
cause error |
7014
|
|
|
key bool |
7015
|
|
|
} |
7016
|
|
|
|
7017
|
|
|
// Field function returns field value. |
7018
|
|
|
func (e DataBundleValidationError) Field() string { return e.field } |
7019
|
|
|
|
7020
|
|
|
// Reason function returns reason value. |
7021
|
|
|
func (e DataBundleValidationError) Reason() string { return e.reason } |
7022
|
|
|
|
7023
|
|
|
// Cause function returns cause value. |
7024
|
|
|
func (e DataBundleValidationError) Cause() error { return e.cause } |
7025
|
|
|
|
7026
|
|
|
// Key function returns key value. |
7027
|
|
|
func (e DataBundleValidationError) Key() bool { return e.key } |
7028
|
|
|
|
7029
|
|
|
// ErrorName returns error name. |
7030
|
|
|
func (e DataBundleValidationError) ErrorName() string { return "DataBundleValidationError" } |
7031
|
|
|
|
7032
|
|
|
// Error satisfies the builtin error interface |
7033
|
|
|
func (e DataBundleValidationError) Error() string { |
7034
|
|
|
cause := "" |
7035
|
|
|
if e.cause != nil { |
7036
|
|
|
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
7037
|
|
|
} |
7038
|
|
|
|
7039
|
|
|
key := "" |
7040
|
|
|
if e.key { |
7041
|
|
|
key = "key for " |
7042
|
|
|
} |
7043
|
|
|
|
7044
|
|
|
return fmt.Sprintf( |
7045
|
|
|
"invalid %sDataBundle.%s: %s%s", |
7046
|
|
|
key, |
7047
|
|
|
e.field, |
7048
|
|
|
e.reason, |
7049
|
|
|
cause) |
7050
|
|
|
} |
7051
|
|
|
|
7052
|
|
|
var _ error = DataBundleValidationError{} |
7053
|
|
|
|
7054
|
|
|
var _ interface { |
7055
|
|
|
Field() string |
7056
|
|
|
Reason() string |
7057
|
|
|
Key() bool |
7058
|
|
|
Cause() error |
7059
|
|
|
ErrorName() string |
7060
|
|
|
} = DataBundleValidationError{} |
7061
|
|
|
|
7062
|
|
|
// Validate checks the field values on Operation with the rules defined in the |
7063
|
|
|
// proto definition for this message. If any rules are violated, the first |
7064
|
|
|
// error encountered is returned, or nil if there are no violations. |
7065
|
|
|
func (m *Operation) Validate() error { |
7066
|
|
|
return m.validate(false) |
7067
|
|
|
} |
7068
|
|
|
|
7069
|
|
|
// ValidateAll checks the field values on Operation with the rules defined in |
7070
|
|
|
// the proto definition for this message. If any rules are violated, the |
7071
|
|
|
// result is a list of violation errors wrapped in OperationMultiError, or nil |
7072
|
|
|
// if none found. |
7073
|
|
|
func (m *Operation) ValidateAll() error { |
7074
|
|
|
return m.validate(true) |
7075
|
|
|
} |
7076
|
|
|
|
7077
|
|
|
func (m *Operation) validate(all bool) error { |
7078
|
|
|
if m == nil { |
7079
|
|
|
return nil |
7080
|
|
|
} |
7081
|
|
|
|
7082
|
|
|
var errors []error |
7083
|
|
|
|
7084
|
|
|
if len(errors) > 0 { |
7085
|
|
|
return OperationMultiError(errors) |
7086
|
|
|
} |
7087
|
|
|
|
7088
|
|
|
return nil |
7089
|
|
|
} |
7090
|
|
|
|
7091
|
|
|
// OperationMultiError is an error wrapping multiple validation errors returned |
7092
|
|
|
// by Operation.ValidateAll() if the designated constraints aren't met. |
7093
|
|
|
type OperationMultiError []error |
7094
|
|
|
|
7095
|
|
|
// Error returns a concatenation of all the error messages it wraps. |
7096
|
|
|
func (m OperationMultiError) Error() string { |
7097
|
|
|
var msgs []string |
7098
|
|
|
for _, err := range m { |
7099
|
|
|
msgs = append(msgs, err.Error()) |
7100
|
|
|
} |
7101
|
|
|
return strings.Join(msgs, "; ") |
7102
|
|
|
} |
7103
|
|
|
|
7104
|
|
|
// AllErrors returns a list of validation violation errors. |
7105
|
|
|
func (m OperationMultiError) AllErrors() []error { return m } |
7106
|
|
|
|
7107
|
|
|
// OperationValidationError is the validation error returned by |
7108
|
|
|
// Operation.Validate if the designated constraints aren't met. |
7109
|
|
|
type OperationValidationError struct { |
7110
|
|
|
field string |
7111
|
|
|
reason string |
7112
|
|
|
cause error |
7113
|
|
|
key bool |
7114
|
|
|
} |
7115
|
|
|
|
7116
|
|
|
// Field function returns field value. |
7117
|
|
|
func (e OperationValidationError) Field() string { return e.field } |
7118
|
|
|
|
7119
|
|
|
// Reason function returns reason value. |
7120
|
|
|
func (e OperationValidationError) Reason() string { return e.reason } |
7121
|
|
|
|
7122
|
|
|
// Cause function returns cause value. |
7123
|
|
|
func (e OperationValidationError) Cause() error { return e.cause } |
7124
|
|
|
|
7125
|
|
|
// Key function returns key value. |
7126
|
|
|
func (e OperationValidationError) Key() bool { return e.key } |
7127
|
|
|
|
7128
|
|
|
// ErrorName returns error name. |
7129
|
|
|
func (e OperationValidationError) ErrorName() string { return "OperationValidationError" } |
7130
|
|
|
|
7131
|
|
|
// Error satisfies the builtin error interface |
7132
|
|
|
func (e OperationValidationError) Error() string { |
7133
|
|
|
cause := "" |
7134
|
|
|
if e.cause != nil { |
7135
|
|
|
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
7136
|
|
|
} |
7137
|
|
|
|
7138
|
|
|
key := "" |
7139
|
|
|
if e.key { |
7140
|
|
|
key = "key for " |
7141
|
|
|
} |
7142
|
|
|
|
7143
|
|
|
return fmt.Sprintf( |
7144
|
|
|
"invalid %sOperation.%s: %s%s", |
7145
|
|
|
key, |
7146
|
|
|
e.field, |
7147
|
|
|
e.reason, |
7148
|
|
|
cause) |
7149
|
|
|
} |
7150
|
|
|
|
7151
|
|
|
var _ error = OperationValidationError{} |
7152
|
|
|
|
7153
|
|
|
var _ interface { |
7154
|
|
|
Field() string |
7155
|
|
|
Reason() string |
7156
|
|
|
Key() bool |
7157
|
|
|
Cause() error |
7158
|
|
|
ErrorName() string |
7159
|
|
|
} = OperationValidationError{} |
7160
|
|
|
|
7161
|
|
|
// Validate checks the field values on Partials with the rules defined in the |
7162
|
|
|
// proto definition for this message. If any rules are violated, the first |
7163
|
|
|
// error encountered is returned, or nil if there are no violations. |
7164
|
|
|
func (m *Partials) Validate() error { |
7165
|
|
|
return m.validate(false) |
7166
|
|
|
} |
7167
|
|
|
|
7168
|
|
|
// ValidateAll checks the field values on Partials with the rules defined in |
7169
|
|
|
// the proto definition for this message. If any rules are violated, the |
7170
|
|
|
// result is a list of violation errors wrapped in PartialsMultiError, or nil |
7171
|
|
|
// if none found. |
7172
|
|
|
func (m *Partials) ValidateAll() error { |
7173
|
|
|
return m.validate(true) |
7174
|
|
|
} |
7175
|
|
|
|
7176
|
|
|
func (m *Partials) validate(all bool) error { |
7177
|
|
|
if m == nil { |
7178
|
|
|
return nil |
7179
|
|
|
} |
7180
|
|
|
|
7181
|
|
|
var errors []error |
7182
|
|
|
|
7183
|
|
|
if len(errors) > 0 { |
7184
|
|
|
return PartialsMultiError(errors) |
7185
|
|
|
} |
7186
|
|
|
|
7187
|
|
|
return nil |
7188
|
|
|
} |
7189
|
|
|
|
7190
|
|
|
// PartialsMultiError is an error wrapping multiple validation errors returned |
7191
|
|
|
// by Partials.ValidateAll() if the designated constraints aren't met. |
7192
|
|
|
type PartialsMultiError []error |
7193
|
|
|
|
7194
|
|
|
// Error returns a concatenation of all the error messages it wraps. |
7195
|
|
|
func (m PartialsMultiError) Error() string { |
7196
|
|
|
var msgs []string |
7197
|
|
|
for _, err := range m { |
7198
|
|
|
msgs = append(msgs, err.Error()) |
7199
|
|
|
} |
7200
|
|
|
return strings.Join(msgs, "; ") |
7201
|
|
|
} |
7202
|
|
|
|
7203
|
|
|
// AllErrors returns a list of validation violation errors. |
7204
|
|
|
func (m PartialsMultiError) AllErrors() []error { return m } |
7205
|
|
|
|
7206
|
|
|
// PartialsValidationError is the validation error returned by |
7207
|
|
|
// Partials.Validate if the designated constraints aren't met. |
7208
|
|
|
type PartialsValidationError struct { |
7209
|
|
|
field string |
7210
|
|
|
reason string |
7211
|
|
|
cause error |
7212
|
|
|
key bool |
7213
|
|
|
} |
7214
|
|
|
|
7215
|
|
|
// Field function returns field value. |
7216
|
|
|
func (e PartialsValidationError) Field() string { return e.field } |
7217
|
|
|
|
7218
|
|
|
// Reason function returns reason value. |
7219
|
|
|
func (e PartialsValidationError) Reason() string { return e.reason } |
7220
|
|
|
|
7221
|
|
|
// Cause function returns cause value. |
7222
|
|
|
func (e PartialsValidationError) Cause() error { return e.cause } |
7223
|
|
|
|
7224
|
|
|
// Key function returns key value. |
7225
|
|
|
func (e PartialsValidationError) Key() bool { return e.key } |
7226
|
|
|
|
7227
|
|
|
// ErrorName returns error name. |
7228
|
|
|
func (e PartialsValidationError) ErrorName() string { return "PartialsValidationError" } |
7229
|
|
|
|
7230
|
|
|
// Error satisfies the builtin error interface |
7231
|
|
|
func (e PartialsValidationError) Error() string { |
7232
|
|
|
cause := "" |
7233
|
|
|
if e.cause != nil { |
7234
|
|
|
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
7235
|
|
|
} |
7236
|
|
|
|
7237
|
|
|
key := "" |
7238
|
|
|
if e.key { |
7239
|
|
|
key = "key for " |
7240
|
|
|
} |
7241
|
|
|
|
7242
|
|
|
return fmt.Sprintf( |
7243
|
|
|
"invalid %sPartials.%s: %s%s", |
7244
|
|
|
key, |
7245
|
|
|
e.field, |
7246
|
|
|
e.reason, |
7247
|
|
|
cause) |
7248
|
|
|
} |
7249
|
|
|
|
7250
|
|
|
var _ error = PartialsValidationError{} |
7251
|
|
|
|
7252
|
|
|
var _ interface { |
7253
|
|
|
Field() string |
7254
|
|
|
Reason() string |
7255
|
|
|
Key() bool |
7256
|
|
|
Cause() error |
7257
|
|
|
ErrorName() string |
7258
|
|
|
} = PartialsValidationError{} |
7259
|
|
|
|