MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / ValidateFields

Method ValidateFields

pkg/ttnpb/join.pb.validate.go:38–173  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

36// in the proto definition for this message. If any rules are violated, an
37// error is returned.
38func (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 }

Callers 2

JoinRequestMethod · 0.95
ValidateFieldsMethod · 0.45

Calls 10

GetRawPayloadMethod · 0.95
GetPayloadMethod · 0.95
GetDevAddrMethod · 0.95
GetNetIdMethod · 0.95
GetDownlinkSettingsMethod · 0.95
GetRxDelayMethod · 0.95
GetCfListMethod · 0.95
GetCorrelationIdsMethod · 0.95
GetConsumedAirtimeMethod · 0.95
_processPathsFunction · 0.85

Tested by

no test coverage detected