Debian Codegraph @

envoy/config/transport_socket/alts/v2alpha/alts.pb.validate.go

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