ValidateFields checks the field values on MHDR with the rules defined in the proto definition for this message. If any rules are violated, an error is returned.
(paths ...string)
| 223 | // ValidateFields checks the field values on MHDR with the rules defined in the |
| 224 | // proto definition for this message. If any rules are violated, an error is returned. |
| 225 | func (m *MHDR) ValidateFields(paths ...string) error { |
| 226 | if m == nil { |
| 227 | return nil |
| 228 | } |
| 229 | |
| 230 | if len(paths) == 0 { |
| 231 | paths = MHDRFieldPathsNested |
| 232 | } |
| 233 | |
| 234 | for name, subs := range _processPaths(append(paths[:0:0], paths...)) { |
| 235 | _ = subs |
| 236 | switch name { |
| 237 | case "m_type": |
| 238 | |
| 239 | if _, ok := MType_name[int32(m.GetMType())]; !ok { |
| 240 | return MHDRValidationError{ |
| 241 | field: "m_type", |
| 242 | reason: "value must be one of the defined enum values", |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | case "major": |
| 247 | |
| 248 | if _, ok := Major_name[int32(m.GetMajor())]; !ok { |
| 249 | return MHDRValidationError{ |
| 250 | field: "major", |
| 251 | reason: "value must be one of the defined enum values", |
| 252 | } |
| 253 | } |
| 254 | |
| 255 | default: |
| 256 | return MHDRValidationError{ |
| 257 | field: name, |
| 258 | reason: "invalid field path", |
| 259 | } |
| 260 | } |
| 261 | } |
| 262 | return nil |
| 263 | } |
| 264 | |
| 265 | // MHDRValidationError is the validation error returned by MHDR.ValidateFields |
| 266 | // if the designated constraints aren't met. |
no test coverage detected