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

Method ValidateFields

pkg/ttnpb/user.pb.validate.go:662–699  ·  view source on GitHub ↗

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

660// the proto definition for this message. If any rules are violated, an error
661// is returned.
662func (m *Users) ValidateFields(paths ...string) error {
663 if m == nil {
664 return nil
665 }
666
667 if len(paths) == 0 {
668 paths = UsersFieldPathsNested
669 }
670
671 for name, subs := range _processPaths(append(paths[:0:0], paths...)) {
672 _ = subs
673 switch name {
674 case "users":
675
676 for idx, item := range m.GetUsers() {
677 _, _ = idx, item
678
679 if v, ok := interface{}(item).(interface{ ValidateFields(...string) error }); ok {
680 if err := v.ValidateFields(subs...); err != nil {
681 return UsersValidationError{
682 field: fmt.Sprintf("users[%v]", idx),
683 reason: "embedded message failed validation",
684 cause: err,
685 }
686 }
687 }
688
689 }
690
691 default:
692 return UsersValidationError{
693 field: name,
694 reason: "invalid field path",
695 }
696 }
697 }
698 return nil
699}
700
701// UsersValidationError is the validation error returned by
702// Users.ValidateFields if the designated constraints aren't met.

Callers

nothing calls this directly

Calls 3

GetUsersMethod · 0.95
_processPathsFunction · 0.85
ValidateFieldsMethod · 0.45

Tested by

no test coverage detected