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

Method ValidateFields

pkg/ttnpb/lorawan.pb.validate.go:225–263  ·  view source on GitHub ↗

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

223// ValidateFields checks the field values on MHDR with the rules defined in the
224// proto definition for this message. If any rules are violated, an error is returned.
225func (m *MHDR) ValidateFields(paths ...string) error {
226 if m == nil {
227 return nil
228 }
229
230 if len(paths) == 0 {
231 paths = MHDRFieldPathsNested
232 }
233
234 for name, subs := range _processPaths(append(paths[:0:0], paths...)) {
235 _ = subs
236 switch name {
237 case "m_type":
238
239 if _, ok := MType_name[int32(m.GetMType())]; !ok {
240 return MHDRValidationError{
241 field: "m_type",
242 reason: "value must be one of the defined enum values",
243 }
244 }
245
246 case "major":
247
248 if _, ok := Major_name[int32(m.GetMajor())]; !ok {
249 return MHDRValidationError{
250 field: "major",
251 reason: "value must be one of the defined enum values",
252 }
253 }
254
255 default:
256 return MHDRValidationError{
257 field: name,
258 reason: "invalid field path",
259 }
260 }
261 }
262 return nil
263}
264
265// MHDRValidationError is the validation error returned by MHDR.ValidateFields
266// if the designated constraints aren't met.

Callers 15

toUplinkMessageMethod · 0.95
toUplinkMessageMethod · 0.95
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
ValidateFieldsMethod · 0.45

Calls 3

GetMTypeMethod · 0.95
GetMajorMethod · 0.95
_processPathsFunction · 0.85

Tested by

no test coverage detected