Debian Codegraph @

envoy/extensions/watchdog/profile_action/v3/profile_action.pb.validate.go

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