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

Method ValidateFields

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

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

2004// in the proto definition for this message. If any rules are violated, an
2005// error is returned.
2006func (m *UplinkToken) ValidateFields(paths ...string) error {
2007 if m == nil {
2008 return nil
2009 }
2010
2011 if len(paths) == 0 {
2012 paths = UplinkTokenFieldPathsNested
2013 }
2014
2015 for name, subs := range _processPaths(append(paths[:0:0], paths...)) {
2016 _ = subs
2017 switch name {
2018 case "ids":
2019
2020 if m.GetIds() == nil {
2021 return UplinkTokenValidationError{
2022 field: "ids",
2023 reason: "value is required",
2024 }
2025 }
2026
2027 if v, ok := interface{}(m.GetIds()).(interface{ ValidateFields(...string) error }); ok {
2028 if err := v.ValidateFields(subs...); err != nil {
2029 return UplinkTokenValidationError{
2030 field: "ids",
2031 reason: "embedded message failed validation",
2032 cause: err,
2033 }
2034 }
2035 }
2036
2037 case "timestamp":
2038 // no validation rules for Timestamp
2039 case "server_time":
2040
2041 if v, ok := interface{}(m.GetServerTime()).(interface{ ValidateFields(...string) error }); ok {
2042 if err := v.ValidateFields(subs...); err != nil {
2043 return UplinkTokenValidationError{
2044 field: "server_time",
2045 reason: "embedded message failed validation",
2046 cause: err,
2047 }
2048 }
2049 }
2050
2051 case "concentrator_time":
2052 // no validation rules for ConcentratorTime
2053 case "gateway_time":
2054
2055 if v, ok := interface{}(m.GetGatewayTime()).(interface{ ValidateFields(...string) error }); ok {
2056 if err := v.ValidateFields(subs...); err != nil {
2057 return UplinkTokenValidationError{
2058 field: "gateway_time",
2059 reason: "embedded message failed validation",
2060 cause: err,
2061 }
2062 }
2063 }

Callers 1

ParseUplinkTokenFunction · 0.95

Calls 5

GetIdsMethod · 0.95
GetServerTimeMethod · 0.95
GetGatewayTimeMethod · 0.95
_processPathsFunction · 0.85
ValidateFieldsMethod · 0.45

Tested by

no test coverage detected