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

Method ValidateFields

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

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

2842// in the proto definition for this message. If any rules are violated, an
2843// error is returned.
2844func (m *UserSession) ValidateFields(paths ...string) error {
2845 if m == nil {
2846 return nil
2847 }
2848
2849 if len(paths) == 0 {
2850 paths = UserSessionFieldPathsNested
2851 }
2852
2853 for name, subs := range _processPaths(append(paths[:0:0], paths...)) {
2854 _ = subs
2855 switch name {
2856 case "user_ids":
2857
2858 if m.GetUserIds() == nil {
2859 return UserSessionValidationError{
2860 field: "user_ids",
2861 reason: "value is required",
2862 }
2863 }
2864
2865 if v, ok := interface{}(m.GetUserIds()).(interface{ ValidateFields(...string) error }); ok {
2866 if err := v.ValidateFields(subs...); err != nil {
2867 return UserSessionValidationError{
2868 field: "user_ids",
2869 reason: "embedded message failed validation",
2870 cause: err,
2871 }
2872 }
2873 }
2874
2875 case "session_id":
2876
2877 if utf8.RuneCountInString(m.GetSessionId()) > 64 {
2878 return UserSessionValidationError{
2879 field: "session_id",
2880 reason: "value length must be at most 64 runes",
2881 }
2882 }
2883
2884 case "created_at":
2885
2886 if v, ok := interface{}(m.GetCreatedAt()).(interface{ ValidateFields(...string) error }); ok {
2887 if err := v.ValidateFields(subs...); err != nil {
2888 return UserSessionValidationError{
2889 field: "created_at",
2890 reason: "embedded message failed validation",
2891 cause: err,
2892 }
2893 }
2894 }
2895
2896 case "updated_at":
2897
2898 if v, ok := interface{}(m.GetUpdatedAt()).(interface{ ValidateFields(...string) error }); ok {
2899 if err := v.ValidateFields(subs...); err != nil {
2900 return UserSessionValidationError{
2901 field: "updated_at",

Callers

nothing calls this directly

Calls 7

GetUserIdsMethod · 0.95
GetSessionIdMethod · 0.95
GetCreatedAtMethod · 0.95
GetUpdatedAtMethod · 0.95
GetExpiresAtMethod · 0.95
_processPathsFunction · 0.85
ValidateFieldsMethod · 0.45

Tested by

no test coverage detected