github.com/lastbackend/toolkit@v0.0.0-20241020043710-cafa37b95aad/examples/http/gen/server/server.pb.validate.go (about) 1 // Code generated by protoc-gen-validate. DO NOT EDIT. 2 // source: github.com/lastbackend/toolkit/examples/http/apis/server.proto 3 4 package serverpb 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 HelloRequest with the rules defined in 39 // the proto definition for this message. If any rules are violated, the first 40 // error encountered is returned, or nil if there are no violations. 41 func (m *HelloRequest) Validate() error { 42 return m.validate(false) 43 } 44 45 // ValidateAll checks the field values on HelloRequest with the rules defined 46 // in the proto definition for this message. If any rules are violated, the 47 // result is a list of violation errors wrapped in HelloRequestMultiError, or 48 // nil if none found. 49 func (m *HelloRequest) ValidateAll() error { 50 return m.validate(true) 51 } 52 53 func (m *HelloRequest) validate(all bool) error { 54 if m == nil { 55 return nil 56 } 57 58 var errors []error 59 60 // no validation rules for Name 61 62 if len(errors) > 0 { 63 return HelloRequestMultiError(errors) 64 } 65 66 return nil 67 } 68 69 // HelloRequestMultiError is an error wrapping multiple validation errors 70 // returned by HelloRequest.ValidateAll() if the designated constraints aren't met. 71 type HelloRequestMultiError []error 72 73 // Error returns a concatenation of all the error messages it wraps. 74 func (m HelloRequestMultiError) Error() string { 75 var msgs []string 76 for _, err := range m { 77 msgs = append(msgs, err.Error()) 78 } 79 return strings.Join(msgs, "; ") 80 } 81 82 // AllErrors returns a list of validation violation errors. 83 func (m HelloRequestMultiError) AllErrors() []error { return m } 84 85 // HelloRequestValidationError is the validation error returned by 86 // HelloRequest.Validate if the designated constraints aren't met. 87 type HelloRequestValidationError struct { 88 field string 89 reason string 90 cause error 91 key bool 92 } 93 94 // Field function returns field value. 95 func (e HelloRequestValidationError) Field() string { return e.field } 96 97 // Reason function returns reason value. 98 func (e HelloRequestValidationError) Reason() string { return e.reason } 99 100 // Cause function returns cause value. 101 func (e HelloRequestValidationError) Cause() error { return e.cause } 102 103 // Key function returns key value. 104 func (e HelloRequestValidationError) Key() bool { return e.key } 105 106 // ErrorName returns error name. 107 func (e HelloRequestValidationError) ErrorName() string { return "HelloRequestValidationError" } 108 109 // Error satisfies the builtin error interface 110 func (e HelloRequestValidationError) Error() string { 111 cause := "" 112 if e.cause != nil { 113 cause = fmt.Sprintf(" | caused by: %v", e.cause) 114 } 115 116 key := "" 117 if e.key { 118 key = "key for " 119 } 120 121 return fmt.Sprintf( 122 "invalid %sHelloRequest.%s: %s%s", 123 key, 124 e.field, 125 e.reason, 126 cause) 127 } 128 129 var _ error = HelloRequestValidationError{} 130 131 var _ interface { 132 Field() string 133 Reason() string 134 Key() bool 135 Cause() error 136 ErrorName() string 137 } = HelloRequestValidationError{} 138 139 // Validate checks the field values on HelloResponse with the rules defined in 140 // the proto definition for this message. If any rules are violated, the first 141 // error encountered is returned, or nil if there are no violations. 142 func (m *HelloResponse) Validate() error { 143 return m.validate(false) 144 } 145 146 // ValidateAll checks the field values on HelloResponse with the rules defined 147 // in the proto definition for this message. If any rules are violated, the 148 // result is a list of violation errors wrapped in HelloResponseMultiError, or 149 // nil if none found. 150 func (m *HelloResponse) ValidateAll() error { 151 return m.validate(true) 152 } 153 154 func (m *HelloResponse) validate(all bool) error { 155 if m == nil { 156 return nil 157 } 158 159 var errors []error 160 161 // no validation rules for Message 162 163 if len(errors) > 0 { 164 return HelloResponseMultiError(errors) 165 } 166 167 return nil 168 } 169 170 // HelloResponseMultiError is an error wrapping multiple validation errors 171 // returned by HelloResponse.ValidateAll() if the designated constraints 172 // aren't met. 173 type HelloResponseMultiError []error 174 175 // Error returns a concatenation of all the error messages it wraps. 176 func (m HelloResponseMultiError) Error() string { 177 var msgs []string 178 for _, err := range m { 179 msgs = append(msgs, err.Error()) 180 } 181 return strings.Join(msgs, "; ") 182 } 183 184 // AllErrors returns a list of validation violation errors. 185 func (m HelloResponseMultiError) AllErrors() []error { return m } 186 187 // HelloResponseValidationError is the validation error returned by 188 // HelloResponse.Validate if the designated constraints aren't met. 189 type HelloResponseValidationError struct { 190 field string 191 reason string 192 cause error 193 key bool 194 } 195 196 // Field function returns field value. 197 func (e HelloResponseValidationError) Field() string { return e.field } 198 199 // Reason function returns reason value. 200 func (e HelloResponseValidationError) Reason() string { return e.reason } 201 202 // Cause function returns cause value. 203 func (e HelloResponseValidationError) Cause() error { return e.cause } 204 205 // Key function returns key value. 206 func (e HelloResponseValidationError) Key() bool { return e.key } 207 208 // ErrorName returns error name. 209 func (e HelloResponseValidationError) ErrorName() string { return "HelloResponseValidationError" } 210 211 // Error satisfies the builtin error interface 212 func (e HelloResponseValidationError) Error() string { 213 cause := "" 214 if e.cause != nil { 215 cause = fmt.Sprintf(" | caused by: %v", e.cause) 216 } 217 218 key := "" 219 if e.key { 220 key = "key for " 221 } 222 223 return fmt.Sprintf( 224 "invalid %sHelloResponse.%s: %s%s", 225 key, 226 e.field, 227 e.reason, 228 cause) 229 } 230 231 var _ error = HelloResponseValidationError{} 232 233 var _ interface { 234 Field() string 235 Reason() string 236 Key() bool 237 Cause() error 238 ErrorName() string 239 } = HelloResponseValidationError{}