ValidateFields checks the field values on FHDR with the rules defined in the proto definition for this message. If any rules are violated, an error is returned.
(paths ...string)
| 442 | // ValidateFields checks the field values on FHDR with the rules defined in the |
| 443 | // proto definition for this message. If any rules are violated, an error is returned. |
| 444 | func (m *FHDR) ValidateFields(paths ...string) error { |
| 445 | if m == nil { |
| 446 | return nil |
| 447 | } |
| 448 | |
| 449 | if len(paths) == 0 { |
| 450 | paths = FHDRFieldPathsNested |
| 451 | } |
| 452 | |
| 453 | for name, subs := range _processPaths(append(paths[:0:0], paths...)) { |
| 454 | _ = subs |
| 455 | switch name { |
| 456 | case "dev_addr": |
| 457 | |
| 458 | if len(m.GetDevAddr()) > 0 { |
| 459 | |
| 460 | if len(m.GetDevAddr()) != 4 { |
| 461 | return FHDRValidationError{ |
| 462 | field: "dev_addr", |
| 463 | reason: "value length must be 4 bytes", |
| 464 | } |
| 465 | } |
| 466 | |
| 467 | } |
| 468 | |
| 469 | case "f_ctrl": |
| 470 | |
| 471 | if m.GetFCtrl() == nil { |
| 472 | return FHDRValidationError{ |
| 473 | field: "f_ctrl", |
| 474 | reason: "value is required", |
| 475 | } |
| 476 | } |
| 477 | |
| 478 | if v, ok := interface{}(m.GetFCtrl()).(interface{ ValidateFields(...string) error }); ok { |
| 479 | if err := v.ValidateFields(subs...); err != nil { |
| 480 | return FHDRValidationError{ |
| 481 | field: "f_ctrl", |
| 482 | reason: "embedded message failed validation", |
| 483 | cause: err, |
| 484 | } |
| 485 | } |
| 486 | } |
| 487 | |
| 488 | case "f_cnt": |
| 489 | |
| 490 | if m.GetFCnt() > 65535 { |
| 491 | return FHDRValidationError{ |
| 492 | field: "f_cnt", |
| 493 | reason: "value must be less than or equal to 65535", |
| 494 | } |
| 495 | } |
| 496 | |
| 497 | case "f_opts": |
| 498 | |
| 499 | if len(m.GetFOpts()) > 15 { |
| 500 | return FHDRValidationError{ |
| 501 | field: "f_opts", |
nothing calls this directly
no test coverage detected