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

Method ValidateFields

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

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

36// the proto definition for this message. If any rules are violated, an error
37// is returned.
38func (m *Client) ValidateFields(paths ...string) error {
39 if m == nil {
40 return nil
41 }
42
43 if len(paths) == 0 {
44 paths = ClientFieldPathsNested
45 }
46
47 for name, subs := range _processPaths(append(paths[:0:0], paths...)) {
48 _ = subs
49 switch name {
50 case "ids":
51
52 if m.GetIds() == nil {
53 return ClientValidationError{
54 field: "ids",
55 reason: "value is required",
56 }
57 }
58
59 if v, ok := interface{}(m.GetIds()).(interface{ ValidateFields(...string) error }); ok {
60 if err := v.ValidateFields(subs...); err != nil {
61 return ClientValidationError{
62 field: "ids",
63 reason: "embedded message failed validation",
64 cause: err,
65 }
66 }
67 }
68
69 case "created_at":
70
71 if v, ok := interface{}(m.GetCreatedAt()).(interface{ ValidateFields(...string) error }); ok {
72 if err := v.ValidateFields(subs...); err != nil {
73 return ClientValidationError{
74 field: "created_at",
75 reason: "embedded message failed validation",
76 cause: err,
77 }
78 }
79 }
80
81 case "updated_at":
82
83 if v, ok := interface{}(m.GetUpdatedAt()).(interface{ ValidateFields(...string) error }); ok {
84 if err := v.ValidateFields(subs...); err != nil {
85 return ClientValidationError{
86 field: "updated_at",
87 reason: "embedded message failed validation",
88 cause: err,
89 }
90 }
91 }
92
93 case "deleted_at":
94
95 if v, ok := interface{}(m.GetDeletedAt()).(interface{ ValidateFields(...string) error }); ok {

Callers 9

ValidateFieldsMethod · 0.45
ValidateFieldsMethod · 0.45
ValidateFieldsMethod · 0.45
ValidateFieldsMethod · 0.45
ValidateFieldsMethod · 0.45
ValidateFieldsMethod · 0.45
ValidateFieldsMethod · 0.45
ValidateFieldsMethod · 0.45
ValidateFieldsMethod · 0.45

Calls 15

GetIdsMethod · 0.95
GetCreatedAtMethod · 0.95
GetUpdatedAtMethod · 0.95
GetDeletedAtMethod · 0.95
GetNameMethod · 0.95
GetDescriptionMethod · 0.95
GetAttributesMethod · 0.95
GetContactInfoMethod · 0.95
GetTechnicalContactMethod · 0.95
GetSecretMethod · 0.95
GetRedirectUrisMethod · 0.95

Tested by

no test coverage detected