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

Method ValidateFields

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

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

1515// the proto definition for this message. If any rules are violated, an error
1516// is returned.
1517func (m *DataRate) ValidateFields(paths ...string) error {
1518 if m == nil {
1519 return nil
1520 }
1521
1522 if len(paths) == 0 {
1523 paths = DataRateFieldPathsNested
1524 }
1525
1526 for name, subs := range _processPaths(append(paths[:0:0], paths...)) {
1527 _ = subs
1528 switch name {
1529 case "modulation":
1530 if m.Modulation == nil {
1531 return DataRateValidationError{
1532 field: "modulation",
1533 reason: "value is required",
1534 }
1535 }
1536 if len(subs) == 0 {
1537 subs = []string{
1538 "lora", "fsk", "lrfhss",
1539 }
1540 }
1541 for name, subs := range _processPaths(subs) {
1542 _ = subs
1543 switch name {
1544 case "lora":
1545 w, ok := m.Modulation.(*DataRate_Lora)
1546 if !ok || w == nil {
1547 continue
1548 }
1549
1550 if v, ok := interface{}(m.GetLora()).(interface{ ValidateFields(...string) error }); ok {
1551 if err := v.ValidateFields(subs...); err != nil {
1552 return DataRateValidationError{
1553 field: "lora",
1554 reason: "embedded message failed validation",
1555 cause: err,
1556 }
1557 }
1558 }
1559
1560 case "fsk":
1561 w, ok := m.Modulation.(*DataRate_Fsk)
1562 if !ok || w == nil {
1563 continue
1564 }
1565
1566 if v, ok := interface{}(m.GetFsk()).(interface{ ValidateFields(...string) error }); ok {
1567 if err := v.ValidateFields(subs...); err != nil {
1568 return DataRateValidationError{
1569 field: "fsk",
1570 reason: "embedded message failed validation",
1571 cause: err,
1572 }
1573 }
1574 }

Callers

nothing calls this directly

Calls 5

GetLoraMethod · 0.95
GetFskMethod · 0.95
GetLrfhssMethod · 0.95
_processPathsFunction · 0.85
ValidateFieldsMethod · 0.45

Tested by

no test coverage detected