ValidateFields checks the field values on JoinRequest with the rules defined in the proto definition for this message. If any rules are violated, an error is returned.
(paths ...string)
| 36 | // in the proto definition for this message. If any rules are violated, an |
| 37 | // error is returned. |
| 38 | func (m *JoinRequest) ValidateFields(paths ...string) error { |
| 39 | if m == nil { |
| 40 | return nil |
| 41 | } |
| 42 | |
| 43 | if len(paths) == 0 { |
| 44 | paths = JoinRequestFieldPathsNested |
| 45 | } |
| 46 | |
| 47 | for name, subs := range _processPaths(append(paths[:0:0], paths...)) { |
| 48 | _ = subs |
| 49 | switch name { |
| 50 | case "raw_payload": |
| 51 | |
| 52 | if len(m.GetRawPayload()) != 23 { |
| 53 | return JoinRequestValidationError{ |
| 54 | field: "raw_payload", |
| 55 | reason: "value length must be 23 bytes", |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | case "payload": |
| 60 | |
| 61 | if v, ok := interface{}(m.GetPayload()).(interface{ ValidateFields(...string) error }); ok { |
| 62 | if err := v.ValidateFields(subs...); err != nil { |
| 63 | return JoinRequestValidationError{ |
| 64 | field: "payload", |
| 65 | reason: "embedded message failed validation", |
| 66 | cause: err, |
| 67 | } |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | case "dev_addr": |
| 72 | |
| 73 | if len(m.GetDevAddr()) > 0 { |
| 74 | |
| 75 | if len(m.GetDevAddr()) != 4 { |
| 76 | return JoinRequestValidationError{ |
| 77 | field: "dev_addr", |
| 78 | reason: "value length must be 4 bytes", |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | } |
| 83 | |
| 84 | case "selected_mac_version": |
| 85 | // no validation rules for SelectedMacVersion |
| 86 | case "net_id": |
| 87 | |
| 88 | if len(m.GetNetId()) > 0 { |
| 89 | |
| 90 | if len(m.GetNetId()) != 3 { |
| 91 | return JoinRequestValidationError{ |
| 92 | field: "net_id", |
| 93 | reason: "value length must be 3 bytes", |
| 94 | } |
| 95 | } |
no test coverage detected