ValidateFields checks the field values on MACPayload with the rules defined in the proto definition for this message. If any rules are violated, an error is returned.
(paths ...string)
| 320 | // in the proto definition for this message. If any rules are violated, an |
| 321 | // error is returned. |
| 322 | func (m *MACPayload) ValidateFields(paths ...string) error { |
| 323 | if m == nil { |
| 324 | return nil |
| 325 | } |
| 326 | |
| 327 | if len(paths) == 0 { |
| 328 | paths = MACPayloadFieldPathsNested |
| 329 | } |
| 330 | |
| 331 | for name, subs := range _processPaths(append(paths[:0:0], paths...)) { |
| 332 | _ = subs |
| 333 | switch name { |
| 334 | case "f_hdr": |
| 335 | |
| 336 | if m.GetFHdr() == nil { |
| 337 | return MACPayloadValidationError{ |
| 338 | field: "f_hdr", |
| 339 | reason: "value is required", |
| 340 | } |
| 341 | } |
| 342 | |
| 343 | if v, ok := interface{}(m.GetFHdr()).(interface{ ValidateFields(...string) error }); ok { |
| 344 | if err := v.ValidateFields(subs...); err != nil { |
| 345 | return MACPayloadValidationError{ |
| 346 | field: "f_hdr", |
| 347 | reason: "embedded message failed validation", |
| 348 | cause: err, |
| 349 | } |
| 350 | } |
| 351 | } |
| 352 | |
| 353 | case "f_port": |
| 354 | |
| 355 | if m.GetFPort() > 255 { |
| 356 | return MACPayloadValidationError{ |
| 357 | field: "f_port", |
| 358 | reason: "value must be less than or equal to 255", |
| 359 | } |
| 360 | } |
| 361 | |
| 362 | case "frm_payload": |
| 363 | // no validation rules for FrmPayload |
| 364 | case "decoded_payload": |
| 365 | |
| 366 | if v, ok := interface{}(m.GetDecodedPayload()).(interface{ ValidateFields(...string) error }); ok { |
| 367 | if err := v.ValidateFields(subs...); err != nil { |
| 368 | return MACPayloadValidationError{ |
| 369 | field: "decoded_payload", |
| 370 | reason: "embedded message failed validation", |
| 371 | cause: err, |
| 372 | } |
| 373 | } |
| 374 | } |
| 375 | |
| 376 | case "full_f_cnt": |
| 377 | // no validation rules for FullFCnt |
| 378 | default: |
| 379 | return MACPayloadValidationError{ |
no test coverage detected