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

Method ValidateFields

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

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

1073// in the proto definition for this message. If any rules are violated, an
1074// error is returned.
1075func (m *DLSettings) ValidateFields(paths ...string) error {
1076 if m == nil {
1077 return nil
1078 }
1079
1080 if len(paths) == 0 {
1081 paths = DLSettingsFieldPathsNested
1082 }
1083
1084 for name, subs := range _processPaths(append(paths[:0:0], paths...)) {
1085 _ = subs
1086 switch name {
1087 case "rx1_dr_offset":
1088
1089 if _, ok := DataRateOffset_name[int32(m.GetRx1DrOffset())]; !ok {
1090 return DLSettingsValidationError{
1091 field: "rx1_dr_offset",
1092 reason: "value must be one of the defined enum values",
1093 }
1094 }
1095
1096 case "rx2_dr":
1097
1098 if _, ok := DataRateIndex_name[int32(m.GetRx2Dr())]; !ok {
1099 return DLSettingsValidationError{
1100 field: "rx2_dr",
1101 reason: "value must be one of the defined enum values",
1102 }
1103 }
1104
1105 case "opt_neg":
1106 // no validation rules for OptNeg
1107 default:
1108 return DLSettingsValidationError{
1109 field: name,
1110 reason: "invalid field path",
1111 }
1112 }
1113 }
1114 return nil
1115}
1116
1117// DLSettingsValidationError is the validation error returned by
1118// DLSettings.ValidateFields if the designated constraints aren't met.

Callers

nothing calls this directly

Calls 3

GetRx1DrOffsetMethod · 0.95
GetRx2DrMethod · 0.95
_processPathsFunction · 0.85

Tested by

no test coverage detected