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

Method ValidateFields

pkg/ttnpb/client.pb.validate.go:376–413  ·  view source on GitHub ↗

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

374// the proto definition for this message. If any rules are violated, an error
375// is returned.
376func (m *Clients) ValidateFields(paths ...string) error {
377 if m == nil {
378 return nil
379 }
380
381 if len(paths) == 0 {
382 paths = ClientsFieldPathsNested
383 }
384
385 for name, subs := range _processPaths(append(paths[:0:0], paths...)) {
386 _ = subs
387 switch name {
388 case "clients":
389
390 for idx, item := range m.GetClients() {
391 _, _ = idx, item
392
393 if v, ok := interface{}(item).(interface{ ValidateFields(...string) error }); ok {
394 if err := v.ValidateFields(subs...); err != nil {
395 return ClientsValidationError{
396 field: fmt.Sprintf("clients[%v]", idx),
397 reason: "embedded message failed validation",
398 cause: err,
399 }
400 }
401 }
402
403 }
404
405 default:
406 return ClientsValidationError{
407 field: name,
408 reason: "invalid field path",
409 }
410 }
411 }
412 return nil
413}
414
415// ClientsValidationError is the validation error returned by
416// Clients.ValidateFields if the designated constraints aren't met.

Callers

nothing calls this directly

Calls 3

GetClientsMethod · 0.95
_processPathsFunction · 0.85
ValidateFieldsMethod · 0.45

Tested by

no test coverage detected