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

Method ValidateFields

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

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

1659// in the proto definition for this message. If any rules are violated, an
1660// error is returned.
1661func (m *TxSettings) ValidateFields(paths ...string) error {
1662 if m == nil {
1663 return nil
1664 }
1665
1666 if len(paths) == 0 {
1667 paths = TxSettingsFieldPathsNested
1668 }
1669
1670 for name, subs := range _processPaths(append(paths[:0:0], paths...)) {
1671 _ = subs
1672 switch name {
1673 case "data_rate":
1674
1675 if m.GetDataRate() == nil {
1676 return TxSettingsValidationError{
1677 field: "data_rate",
1678 reason: "value is required",
1679 }
1680 }
1681
1682 if v, ok := interface{}(m.GetDataRate()).(interface{ ValidateFields(...string) error }); ok {
1683 if err := v.ValidateFields(subs...); err != nil {
1684 return TxSettingsValidationError{
1685 field: "data_rate",
1686 reason: "embedded message failed validation",
1687 cause: err,
1688 }
1689 }
1690 }
1691
1692 case "frequency":
1693
1694 if m.GetFrequency() < 100000 {
1695 return TxSettingsValidationError{
1696 field: "frequency",
1697 reason: "value must be greater than or equal to 100000",
1698 }
1699 }
1700
1701 case "enable_crc":
1702 // no validation rules for EnableCrc
1703 case "timestamp":
1704 // no validation rules for Timestamp
1705 case "time":
1706
1707 if v, ok := interface{}(m.GetTime()).(interface{ ValidateFields(...string) error }); ok {
1708 if err := v.ValidateFields(subs...); err != nil {
1709 return TxSettingsValidationError{
1710 field: "time",
1711 reason: "embedded message failed validation",
1712 cause: err,
1713 }
1714 }
1715 }
1716
1717 case "downlink":
1718

Callers

nothing calls this directly

Calls 6

GetDataRateMethod · 0.95
GetFrequencyMethod · 0.95
GetTimeMethod · 0.95
GetDownlinkMethod · 0.95
_processPathsFunction · 0.85
ValidateFieldsMethod · 0.45

Tested by

no test coverage detected