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

Method ValidateFields

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

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

756// defined in the proto definition for this message. If any rules are
757// violated, an error is returned.
758func (m *GetUserRequest) ValidateFields(paths ...string) error {
759 if m == nil {
760 return nil
761 }
762
763 if len(paths) == 0 {
764 paths = GetUserRequestFieldPathsNested
765 }
766
767 for name, subs := range _processPaths(append(paths[:0:0], paths...)) {
768 _ = subs
769 switch name {
770 case "user_ids":
771
772 if m.GetUserIds() == nil {
773 return GetUserRequestValidationError{
774 field: "user_ids",
775 reason: "value is required",
776 }
777 }
778
779 if v, ok := interface{}(m.GetUserIds()).(interface{ ValidateFields(...string) error }); ok {
780 if err := v.ValidateFields(subs...); err != nil {
781 return GetUserRequestValidationError{
782 field: "user_ids",
783 reason: "embedded message failed validation",
784 cause: err,
785 }
786 }
787 }
788
789 case "field_mask":
790
791 if v, ok := interface{}(m.GetFieldMask()).(interface{ ValidateFields(...string) error }); ok {
792 if err := v.ValidateFields(subs...); err != nil {
793 return GetUserRequestValidationError{
794 field: "field_mask",
795 reason: "embedded message failed validation",
796 cause: err,
797 }
798 }
799 }
800
801 default:
802 return GetUserRequestValidationError{
803 field: name,
804 reason: "invalid field path",
805 }
806 }
807 }
808 return nil
809}
810
811// GetUserRequestValidationError is the validation error returned by
812// GetUserRequest.ValidateFields if the designated constraints aren't met.

Callers 1

ValidateContextMethod · 0.95

Calls 4

GetUserIdsMethod · 0.95
GetFieldMaskMethod · 0.95
_processPathsFunction · 0.85
ValidateFieldsMethod · 0.45

Tested by

no test coverage detected