func (e PacketBrokerMetadataValidationError) Error() string {
	cause := ""
	if e.cause != nil {
		cause = fmt.Sprintf(" | caused by: %v", e.cause)
	}
	key := ""
	if e.key {
		key = "key for "
	}
	return fmt.Sprintf(
		"invalid %sPacketBrokerMetadata.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}
Error satisfies the builtin error interface
package ttnpb
import (
	"bytes"
	"errors"
	"fmt"
	"net"
	"net/mail"
	"net/url"
	"regexp"
	"strings"
	"time"
	"unicode/utf8"
	"github.com/gogo/protobuf/types"
)
var (
	_ = bytes.MinRead
	_ = errors.New("")
	_ = fmt.Print
	_ = utf8.UTFMax
	_ = (*regexp.Regexp)(nil)
	_ = (*strings.Reader)(nil)
	_ = net.IPv4len
	_ = time.Duration(0)
	_ = (*url.URL)(nil)
	_ = (*mail.Address)(nil)
	_ = types.DynamicAny{}
)
var _metadata_uuidPattern = regexp.MustCompile("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$")
func (m *RxMetadata) ValidateFields(paths ...string) error {
	if m == nil {
		return nil
	}
	if len(paths) == 0 {
		paths = RxMetadataFieldPathsNested
	}
	for name, subs := range _processPaths(append(paths[:0:0], paths...)) {
		_ = subs
		switch name {
		case "gateway_ids":
			if v, ok := interface{}(&m.GatewayIdentifiers).(interface{ ValidateFields(...string) error }); ok {
				if err := v.ValidateFields(subs...); err != nil {
					return RxMetadataValidationError{
						field:  "gateway_ids",
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		case "packet_broker":
			if v, ok := interface{}(m.GetPacketBroker()).(interface{ ValidateFields(...string) error }); ok {
				if err := v.ValidateFields(subs...); err != nil {
					return RxMetadataValidationError{
						field:  "packet_broker",
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		case "antenna_index":
		case "time":
			if v, ok := interface{}(m.GetTime()).(interface{ ValidateFields(...string) error }); ok {
				if err := v.ValidateFields(subs...); err != nil {
					return RxMetadataValidationError{
						field:  "time",
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		case "timestamp":
		case "fine_timestamp":
		case "encrypted_fine_timestamp":
		case "encrypted_fine_timestamp_key_id":
		case "rssi":
		case "signal_rssi":
			if v, ok := interface{}(m.GetSignalRssi()).(interface{ ValidateFields(...string) error }); ok {
				if err := v.ValidateFields(subs...); err != nil {
					return RxMetadataValidationError{
						field:  "signal_rssi",
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		case "channel_rssi":
		case "rssi_standard_deviation":
		case "snr":
		case "frequency_offset":
		case "location":
			if v, ok := interface{}(m.GetLocation()).(interface{ ValidateFields(...string) error }); ok {
				if err := v.ValidateFields(subs...); err != nil {
					return RxMetadataValidationError{
						field:  "location",
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		case "downlink_path_constraint":
			if _, ok := DownlinkPathConstraint_name[int32(m.GetDownlinkPathConstraint())]; !ok {
				return RxMetadataValidationError{
					field:  "downlink_path_constraint",
					reason: "value must be one of the defined enum values",
				}
			}
		case "uplink_token":
		case "channel_index":
			if m.GetChannelIndex() > 255 {
				return RxMetadataValidationError{
					field:  "channel_index",
					reason: "value must be less than or equal to 255",
				}
			}
		case "hopping_width":
		case "frequency_drift":
		case "advanced":
			if v, ok := interface{}(m.GetAdvanced()).(interface{ ValidateFields(...string) error }); ok {
				if err := v.ValidateFields(subs...); err != nil {
					return RxMetadataValidationError{
						field:  "advanced",
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		default:
			return RxMetadataValidationError{
				field:  name,
				reason: "invalid field path",
			}
		}
	}
	return nil
}
type RxMetadataValidationError struct {
	field  string
	reason string
	cause  error
	key    bool
}
func (e RxMetadataValidationError) Field() string { return e.field }
func (e RxMetadataValidationError) Reason() string { return e.reason }
func (e RxMetadataValidationError) Cause() error { return e.cause }
func (e RxMetadataValidationError) Key() bool { return e.key }
func (e RxMetadataValidationError) ErrorName() string { return "RxMetadataValidationError" }
func (e RxMetadataValidationError) Error() string {
	cause := ""
	if e.cause != nil {
		cause = fmt.Sprintf(" | caused by: %v", e.cause)
	}
	key := ""
	if e.key {
		key = "key for "
	}
	return fmt.Sprintf(
		"invalid %sRxMetadata.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}
var _ error = RxMetadataValidationError{}
var _ interface {
	Field() string
	Reason() string
	Key() bool
	Cause() error
	ErrorName() string
} = RxMetadataValidationError{}
func (m *Location) ValidateFields(paths ...string) error {
	if m == nil {
		return nil
	}
	if len(paths) == 0 {
		paths = LocationFieldPathsNested
	}
	for name, subs := range _processPaths(append(paths[:0:0], paths...)) {
		_ = subs
		switch name {
		case "latitude":
			if val := m.GetLatitude(); val < -90 || val > 90 {
				return LocationValidationError{
					field:  "latitude",
					reason: "value must be inside range [-90, 90]",
				}
			}
		case "longitude":
			if val := m.GetLongitude(); val < -180 || val > 180 {
				return LocationValidationError{
					field:  "longitude",
					reason: "value must be inside range [-180, 180]",
				}
			}
		case "altitude":
		case "accuracy":
		case "source":
			if _, ok := LocationSource_name[int32(m.GetSource())]; !ok {
				return LocationValidationError{
					field:  "source",
					reason: "value must be one of the defined enum values",
				}
			}
		default:
			return LocationValidationError{
				field:  name,
				reason: "invalid field path",
			}
		}
	}
	return nil
}
type LocationValidationError struct {
	field  string
	reason string
	cause  error
	key    bool
}
func (e LocationValidationError) Field() string { return e.field }
func (e LocationValidationError) Reason() string { return e.reason }
func (e LocationValidationError) Cause() error { return e.cause }
func (e LocationValidationError) Key() bool { return e.key }
func (e LocationValidationError) ErrorName() string { return "LocationValidationError" }
func (e LocationValidationError) Error() string {
	cause := ""
	if e.cause != nil {
		cause = fmt.Sprintf(" | caused by: %v", e.cause)
	}
	key := ""
	if e.key {
		key = "key for "
	}
	return fmt.Sprintf(
		"invalid %sLocation.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}
var _ error = LocationValidationError{}
var _ interface {
	Field() string
	Reason() string
	Key() bool
	Cause() error
	ErrorName() string
} = LocationValidationError{}
func (m *PacketBrokerMetadata) ValidateFields(paths ...string) error {
	if m == nil {
		return nil
	}
	if len(paths) == 0 {
		paths = PacketBrokerMetadataFieldPathsNested
	}
	for name, subs := range _processPaths(append(paths[:0:0], paths...)) {
		_ = subs
		switch name {
		case "message_id":
		case "forwarder_net_id":
		case "forwarder_tenant_id":
		case "forwarder_cluster_id":
		case "forwarder_gateway_eui":
		case "forwarder_gateway_id":
			if v, ok := interface{}(m.GetForwarderGatewayId()).(interface{ ValidateFields(...string) error }); ok {
				if err := v.ValidateFields(subs...); err != nil {
					return PacketBrokerMetadataValidationError{
						field:  "forwarder_gateway_id",
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		case "home_network_net_id":
		case "home_network_tenant_id":
		case "home_network_cluster_id":
		case "hops":
			for idx, item := range m.GetHops() {
				_, _ = idx, item
				if v, ok := interface{}(item).(interface{ ValidateFields(...string) error }); ok {
					if err := v.ValidateFields(subs...); err != nil {
						return PacketBrokerMetadataValidationError{
							field:  fmt.Sprintf("hops[%v]", idx),
							reason: "embedded message failed validation",
							cause:  err,
						}
					}
				}
			}
		default:
			return PacketBrokerMetadataValidationError{
				field:  name,
				reason: "invalid field path",
			}
		}
	}
	return nil
}
type PacketBrokerMetadataValidationError struct {
	field  string
	reason string
	cause  error
	key    bool
}
func (e PacketBrokerMetadataValidationError) Field() string { return e.field }
func (e PacketBrokerMetadataValidationError) Reason() string { return e.reason }
func (e PacketBrokerMetadataValidationError) Cause() error { return e.cause }
func (e PacketBrokerMetadataValidationError) Key() bool { return e.key }
func (e PacketBrokerMetadataValidationError) ErrorName() string {
	return "PacketBrokerMetadataValidationError"
}