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

Method ValidateFields

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

ValidateFields checks the field values on JoinResponse 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

230// defined in the proto definition for this message. If any rules are
231// violated, an error is returned.
232func (m *JoinResponse) ValidateFields(paths ...string) error {
233 if m == nil {
234 return nil
235 }
236
237 if len(paths) == 0 {
238 paths = JoinResponseFieldPathsNested
239 }
240
241 for name, subs := range _processPaths(append(paths[:0:0], paths...)) {
242 _ = subs
243 switch name {
244 case "raw_payload":
245
246 if l := len(m.GetRawPayload()); l < 17 || l > 33 {
247 return JoinResponseValidationError{
248 field: "raw_payload",
249 reason: "value length must be between 17 and 33 bytes, inclusive",
250 }
251 }
252
253 case "session_keys":
254
255 if m.GetSessionKeys() == nil {
256 return JoinResponseValidationError{
257 field: "session_keys",
258 reason: "value is required",
259 }
260 }
261
262 if v, ok := interface{}(m.GetSessionKeys()).(interface{ ValidateFields(...string) error }); ok {
263 if err := v.ValidateFields(subs...); err != nil {
264 return JoinResponseValidationError{
265 field: "session_keys",
266 reason: "embedded message failed validation",
267 cause: err,
268 }
269 }
270 }
271
272 case "lifetime":
273
274 if v, ok := interface{}(m.GetLifetime()).(interface{ ValidateFields(...string) error }); ok {
275 if err := v.ValidateFields(subs...); err != nil {
276 return JoinResponseValidationError{
277 field: "lifetime",
278 reason: "embedded message failed validation",
279 cause: err,
280 }
281 }
282 }
283
284 case "correlation_ids":
285
286 for idx, item := range m.GetCorrelationIds() {
287 _, _ = idx, item
288
289 if utf8.RuneCountInString(item) > 100 {

Callers

nothing calls this directly

Calls 6

GetRawPayloadMethod · 0.95
GetSessionKeysMethod · 0.95
GetLifetimeMethod · 0.95
GetCorrelationIdsMethod · 0.95
_processPathsFunction · 0.85
ValidateFieldsMethod · 0.45

Tested by

no test coverage detected