func (m *CUPSRedirection) ValidateFields(paths ...string) error {
	if m == nil {
		return nil
	}
	if len(paths) == 0 {
		paths = CUPSRedirectionFieldPathsNested
	}
	for name, subs := range _processPaths(append(paths[:0:0], paths...)) {
		_ = subs
		switch name {
		case "target_cups_uri":
			if utf8.RuneCountInString(m.GetTargetCupsUri()) > 256 {
				return CUPSRedirectionValidationError{
					field:  "target_cups_uri",
					reason: "value length must be at most 256 runes",
				}
			}
			if uri, err := url.Parse(m.GetTargetCupsUri()); err != nil {
				return CUPSRedirectionValidationError{
					field:  "target_cups_uri",
					reason: "value must be a valid URI",
					cause:  err,
				}
			} else if !uri.IsAbs() {
				return CUPSRedirectionValidationError{
					field:  "target_cups_uri",
					reason: "value must be absolute",
				}
			}
			if !_CUPSRedirection_TargetCupsUri_Pattern.MatchString(m.GetTargetCupsUri()) {
				return CUPSRedirectionValidationError{
					field:  "target_cups_uri",
					reason: "value does not match regex pattern \"^https\"",
				}
			}
		case "current_gateway_key":
			if utf8.RuneCountInString(m.GetCurrentGatewayKey()) > 2048 {
				return CUPSRedirectionValidationError{
					field:  "current_gateway_key",
					reason: "value length must be at most 2048 runes",
				}
			}
		case "target_cups_trust":
		case "gateway_credentials":
			if len(subs) == 0 {
				subs = []string{
					"client_tls", "auth_token",
				}
			}
			for name, subs := range _processPaths(subs) {
				_ = subs
				switch name {
				case "client_tls":
					w, ok := m.GatewayCredentials.(*CUPSRedirection_ClientTls)
					if !ok || w == nil {
						continue
					}
					if v, ok := interface{}(m.GetClientTls()).(interface{ ValidateFields(...string) error }); ok {
						if err := v.ValidateFields(subs...); err != nil {
							return CUPSRedirectionValidationError{
								field:  "client_tls",
								reason: "embedded message failed validation",
								cause:  err,
							}
						}
					}
				case "auth_token":
					w, ok := m.GatewayCredentials.(*CUPSRedirection_AuthToken)
					if !ok || w == nil {
						continue
					}
					if utf8.RuneCountInString(m.GetAuthToken()) > 2048 {
						return CUPSRedirectionValidationError{
							field:  "auth_token",
							reason: "value length must be at most 2048 runes",
						}
					}
				}
			}
		default:
			return CUPSRedirectionValidationError{
				field:  name,
				reason: "invalid field path",
			}
		}
	}
	return nil
}
ValidateFields checks the field values on CUPSRedirection with the rules
defined in the proto definition for this message. If any rules are
violated, an error is returned.
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 _deviceclaimingserver_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 *ClaimEndDeviceRequest) ValidateFields(paths ...string) error {
	if m == nil {
		return nil
	}
	if len(paths) == 0 {
		paths = ClaimEndDeviceRequestFieldPathsNested
	}
	for name, subs := range _processPaths(append(paths[:0:0], paths...)) {
		_ = subs
		switch name {
		case "target_application_ids":
			if m.GetTargetApplicationIds() == nil {
				return ClaimEndDeviceRequestValidationError{
					field:  "target_application_ids",
					reason: "value is required",
				}
			}
			if v, ok := interface{}(m.GetTargetApplicationIds()).(interface{ ValidateFields(...string) error }); ok {
				if err := v.ValidateFields(subs...); err != nil {
					return ClaimEndDeviceRequestValidationError{
						field:  "target_application_ids",
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		case "target_device_id":
			if utf8.RuneCountInString(m.GetTargetDeviceId()) > 36 {
				return ClaimEndDeviceRequestValidationError{
					field:  "target_device_id",
					reason: "value length must be at most 36 runes",
				}
			}
			if !_ClaimEndDeviceRequest_TargetDeviceId_Pattern.MatchString(m.GetTargetDeviceId()) {
				return ClaimEndDeviceRequestValidationError{
					field:  "target_device_id",
					reason: "value does not match regex pattern \"^[a-z0-9](?:[-]?[a-z0-9]){2,}$|^$\"",
				}
			}
		case "target_network_server_address":
			if !_ClaimEndDeviceRequest_TargetNetworkServerAddress_Pattern.MatchString(m.GetTargetNetworkServerAddress()) {
				return ClaimEndDeviceRequestValidationError{
					field:  "target_network_server_address",
					reason: "value does not match regex pattern \"^(?:(?:[a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\\\-]*[a-zA-Z0-9])\\\\.)*(?:[A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\\\\-]*[A-Za-z0-9])(?::[0-9]{1,5})?$|^$\"",
				}
			}
		case "target_network_server_kek_label":
			if utf8.RuneCountInString(m.GetTargetNetworkServerKekLabel()) > 2048 {
				return ClaimEndDeviceRequestValidationError{
					field:  "target_network_server_kek_label",
					reason: "value length must be at most 2048 runes",
				}
			}
		case "target_application_server_address":
			if !_ClaimEndDeviceRequest_TargetApplicationServerAddress_Pattern.MatchString(m.GetTargetApplicationServerAddress()) {
				return ClaimEndDeviceRequestValidationError{
					field:  "target_application_server_address",
					reason: "value does not match regex pattern \"^(?:(?:[a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\\\-]*[a-zA-Z0-9])\\\\.)*(?:[A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\\\\-]*[A-Za-z0-9])(?::[0-9]{1,5})?$|^$\"",
				}
			}
		case "target_application_server_kek_label":
			if utf8.RuneCountInString(m.GetTargetApplicationServerKekLabel()) > 2048 {
				return ClaimEndDeviceRequestValidationError{
					field:  "target_application_server_kek_label",
					reason: "value length must be at most 2048 runes",
				}
			}
		case "target_application_server_id":
			if utf8.RuneCountInString(m.GetTargetApplicationServerId()) > 100 {
				return ClaimEndDeviceRequestValidationError{
					field:  "target_application_server_id",
					reason: "value length must be at most 100 runes",
				}
			}
		case "target_net_id":
		case "invalidate_authentication_code":
		case "source_device":
			if m.SourceDevice == nil {
				return ClaimEndDeviceRequestValidationError{
					field:  "source_device",
					reason: "value is required",
				}
			}
			if len(subs) == 0 {
				subs = []string{
					"authenticated_identifiers", "qr_code",
				}
			}
			for name, subs := range _processPaths(subs) {
				_ = subs
				switch name {
				case "authenticated_identifiers":
					w, ok := m.SourceDevice.(*ClaimEndDeviceRequest_AuthenticatedIdentifiers_)
					if !ok || w == nil {
						continue
					}
					if v, ok := interface{}(m.GetAuthenticatedIdentifiers()).(interface{ ValidateFields(...string) error }); ok {
						if err := v.ValidateFields(subs...); err != nil {
							return ClaimEndDeviceRequestValidationError{
								field:  "authenticated_identifiers",
								reason: "embedded message failed validation",
								cause:  err,
							}
						}
					}
				case "qr_code":
					w, ok := m.SourceDevice.(*ClaimEndDeviceRequest_QrCode)
					if !ok || w == nil {
						continue
					}
					if l := len(m.GetQrCode()); l < 0 || l > 1024 {
						return ClaimEndDeviceRequestValidationError{
							field:  "qr_code",
							reason: "value length must be between 0 and 1024 bytes, inclusive",
						}
					}
				}
			}
		default:
			return ClaimEndDeviceRequestValidationError{
				field:  name,
				reason: "invalid field path",
			}
		}
	}
	return nil
}
type ClaimEndDeviceRequestValidationError struct {
	field  string
	reason string
	cause  error
	key    bool
}
func (e ClaimEndDeviceRequestValidationError) Field() string { return e.field }
func (e ClaimEndDeviceRequestValidationError) Reason() string { return e.reason }
func (e ClaimEndDeviceRequestValidationError) Cause() error { return e.cause }
func (e ClaimEndDeviceRequestValidationError) Key() bool { return e.key }
func (e ClaimEndDeviceRequestValidationError) ErrorName() string {
	return "ClaimEndDeviceRequestValidationError"
}
func (e ClaimEndDeviceRequestValidationError) 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 %sClaimEndDeviceRequest.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}
var _ error = ClaimEndDeviceRequestValidationError{}
var _ interface {
	Field() string
	Reason() string
	Key() bool
	Cause() error
	ErrorName() string
} = ClaimEndDeviceRequestValidationError{}
var _ClaimEndDeviceRequest_TargetDeviceId_Pattern = regexp.MustCompile("^[a-z0-9](?:[-]?[a-z0-9]){2,}$|^$")
var _ClaimEndDeviceRequest_TargetNetworkServerAddress_Pattern = regexp.MustCompile("^(?:(?:[a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]*[a-zA-Z0-9])\\.)*(?:[A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\\-]*[A-Za-z0-9])(?::[0-9]{1,5})?$|^$")
var _ClaimEndDeviceRequest_TargetApplicationServerAddress_Pattern = regexp.MustCompile("^(?:(?:[a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]*[a-zA-Z0-9])\\.)*(?:[A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\\-]*[A-Za-z0-9])(?::[0-9]{1,5})?$|^$")
func (m *AuthorizeApplicationRequest) ValidateFields(paths ...string) error {
	if m == nil {
		return nil
	}
	if len(paths) == 0 {
		paths = AuthorizeApplicationRequestFieldPathsNested
	}
	for name, subs := range _processPaths(append(paths[:0:0], paths...)) {
		_ = subs
		switch name {
		case "application_ids":
			if m.GetApplicationIds() == nil {
				return AuthorizeApplicationRequestValidationError{
					field:  "application_ids",
					reason: "value is required",
				}
			}
			if v, ok := interface{}(m.GetApplicationIds()).(interface{ ValidateFields(...string) error }); ok {
				if err := v.ValidateFields(subs...); err != nil {
					return AuthorizeApplicationRequestValidationError{
						field:  "application_ids",
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		case "api_key":
			if l := utf8.RuneCountInString(m.GetApiKey()); l < 1 || l > 128 {
				return AuthorizeApplicationRequestValidationError{
					field:  "api_key",
					reason: "value length must be between 1 and 128 runes, inclusive",
				}
			}
		default:
			return AuthorizeApplicationRequestValidationError{
				field:  name,
				reason: "invalid field path",
			}
		}
	}
	return nil
}
type AuthorizeApplicationRequestValidationError struct {
	field  string
	reason string
	cause  error
	key    bool
}
func (e AuthorizeApplicationRequestValidationError) Field() string { return e.field }
func (e AuthorizeApplicationRequestValidationError) Reason() string { return e.reason }
func (e AuthorizeApplicationRequestValidationError) Cause() error { return e.cause }
func (e AuthorizeApplicationRequestValidationError) Key() bool { return e.key }
func (e AuthorizeApplicationRequestValidationError) ErrorName() string {
	return "AuthorizeApplicationRequestValidationError"
}
func (e AuthorizeApplicationRequestValidationError) 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 %sAuthorizeApplicationRequest.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}
var _ error = AuthorizeApplicationRequestValidationError{}
var _ interface {
	Field() string
	Reason() string
	Key() bool
	Cause() error
	ErrorName() string
} = AuthorizeApplicationRequestValidationError{}