func (e UpdateUserRequestValidationError) 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 %sUpdateUserRequest.%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 _user_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 *User) ValidateFields(paths ...string) error {
	if m == nil {
		return nil
	}
	if len(paths) == 0 {
		paths = UserFieldPathsNested
	}
	for name, subs := range _processPaths(append(paths[:0:0], paths...)) {
		_ = subs
		switch name {
		case "ids":
			if m.GetIds() == nil {
				return UserValidationError{
					field:  "ids",
					reason: "value is required",
				}
			}
			if v, ok := interface{}(m.GetIds()).(interface{ ValidateFields(...string) error }); ok {
				if err := v.ValidateFields(subs...); err != nil {
					return UserValidationError{
						field:  "ids",
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		case "created_at":
			if v, ok := interface{}(&m.CreatedAt).(interface{ ValidateFields(...string) error }); ok {
				if err := v.ValidateFields(subs...); err != nil {
					return UserValidationError{
						field:  "created_at",
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		case "updated_at":
			if v, ok := interface{}(&m.UpdatedAt).(interface{ ValidateFields(...string) error }); ok {
				if err := v.ValidateFields(subs...); err != nil {
					return UserValidationError{
						field:  "updated_at",
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		case "deleted_at":
			if v, ok := interface{}(m.GetDeletedAt()).(interface{ ValidateFields(...string) error }); ok {
				if err := v.ValidateFields(subs...); err != nil {
					return UserValidationError{
						field:  "deleted_at",
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		case "name":
			if utf8.RuneCountInString(m.GetName()) > 50 {
				return UserValidationError{
					field:  "name",
					reason: "value length must be at most 50 runes",
				}
			}
		case "description":
			if utf8.RuneCountInString(m.GetDescription()) > 2000 {
				return UserValidationError{
					field:  "description",
					reason: "value length must be at most 2000 runes",
				}
			}
		case "attributes":
			if len(m.GetAttributes()) > 10 {
				return UserValidationError{
					field:  "attributes",
					reason: "value must contain no more than 10 pair(s)",
				}
			}
			for key, val := range m.GetAttributes() {
				_ = val
				if utf8.RuneCountInString(key) > 36 {
					return UserValidationError{
						field:  fmt.Sprintf("attributes[%v]", key),
						reason: "value length must be at most 36 runes",
					}
				}
				if !_User_Attributes_Pattern.MatchString(key) {
					return UserValidationError{
						field:  fmt.Sprintf("attributes[%v]", key),
						reason: "value does not match regex pattern \"^[a-z0-9](?:[-]?[a-z0-9]){2,}$\"",
					}
				}
				if utf8.RuneCountInString(val) > 200 {
					return UserValidationError{
						field:  fmt.Sprintf("attributes[%v]", key),
						reason: "value length must be at most 200 runes",
					}
				}
			}
		case "contact_info":
			if len(m.GetContactInfo()) > 10 {
				return UserValidationError{
					field:  "contact_info",
					reason: "value must contain no more than 10 item(s)",
				}
			}
			for idx, item := range m.GetContactInfo() {
				_, _ = idx, item
				if v, ok := interface{}(item).(interface{ ValidateFields(...string) error }); ok {
					if err := v.ValidateFields(subs...); err != nil {
						return UserValidationError{
							field:  fmt.Sprintf("contact_info[%v]", idx),
							reason: "embedded message failed validation",
							cause:  err,
						}
					}
				}
			}
		case "primary_email_address":
			if err := m._validateEmail(m.GetPrimaryEmailAddress()); err != nil {
				return UserValidationError{
					field:  "primary_email_address",
					reason: "value must be a valid email address",
					cause:  err,
				}
			}
		case "primary_email_address_validated_at":
			if v, ok := interface{}(m.GetPrimaryEmailAddressValidatedAt()).(interface{ ValidateFields(...string) error }); ok {
				if err := v.ValidateFields(subs...); err != nil {
					return UserValidationError{
						field:  "primary_email_address_validated_at",
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		case "password":
			if utf8.RuneCountInString(m.GetPassword()) > 1000 {
				return UserValidationError{
					field:  "password",
					reason: "value length must be at most 1000 runes",
				}
			}
		case "password_updated_at":
			if v, ok := interface{}(m.GetPasswordUpdatedAt()).(interface{ ValidateFields(...string) error }); ok {
				if err := v.ValidateFields(subs...); err != nil {
					return UserValidationError{
						field:  "password_updated_at",
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		case "require_password_update":
		case "state":
			if _, ok := State_name[int32(m.GetState())]; !ok {
				return UserValidationError{
					field:  "state",
					reason: "value must be one of the defined enum values",
				}
			}
		case "state_description":
			if utf8.RuneCountInString(m.GetStateDescription()) > 128 {
				return UserValidationError{
					field:  "state_description",
					reason: "value length must be at most 128 runes",
				}
			}
		case "admin":
		case "temporary_password":
			if utf8.RuneCountInString(m.GetTemporaryPassword()) > 1000 {
				return UserValidationError{
					field:  "temporary_password",
					reason: "value length must be at most 1000 runes",
				}
			}
		case "temporary_password_created_at":
			if v, ok := interface{}(m.GetTemporaryPasswordCreatedAt()).(interface{ ValidateFields(...string) error }); ok {
				if err := v.ValidateFields(subs...); err != nil {
					return UserValidationError{
						field:  "temporary_password_created_at",
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		case "temporary_password_expires_at":
			if v, ok := interface{}(m.GetTemporaryPasswordExpiresAt()).(interface{ ValidateFields(...string) error }); ok {
				if err := v.ValidateFields(subs...); err != nil {
					return UserValidationError{
						field:  "temporary_password_expires_at",
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		case "profile_picture":
			if v, ok := interface{}(m.GetProfilePicture()).(interface{ ValidateFields(...string) error }); ok {
				if err := v.ValidateFields(subs...); err != nil {
					return UserValidationError{
						field:  "profile_picture",
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		default:
			return UserValidationError{
				field:  name,
				reason: "invalid field path",
			}
		}
	}
	return nil
}
func (m *User) _validateHostname(host string) error {
	s := strings.ToLower(strings.TrimSuffix(host, "."))
	if len(host) > 253 {
		return errors.New("hostname cannot exceed 253 characters")
	}
	for _, part := range strings.Split(s, ".") {
		if l := len(part); l == 0 || l > 63 {
			return errors.New("hostname part must be non-empty and cannot exceed 63 characters")
		}
		if part[0] == '-' {
			return errors.New("hostname parts cannot begin with hyphens")
		}
		if part[len(part)-1] == '-' {
			return errors.New("hostname parts cannot end with hyphens")
		}
		for _, r := range part {
			if (r < 'a' || r > 'z') && (r < '0' || r > '9') && r != '-' {
				return fmt.Errorf("hostname parts can only contain alphanumeric characters or hyphens, got %q", string(r))
			}
		}
	}
	return nil
}
func (m *User) _validateEmail(addr string) error {
	a, err := mail.ParseAddress(addr)
	if err != nil {
		return err
	}
	addr = a.Address
	if len(addr) > 254 {
		return errors.New("email addresses cannot exceed 254 characters")
	}
	parts := strings.SplitN(addr, "@", 2)
	if len(parts[0]) > 64 {
		return errors.New("email address local phrase cannot exceed 64 characters")
	}
	return m._validateHostname(parts[1])
}
type UserValidationError struct {
	field  string
	reason string
	cause  error
	key    bool
}
func (e UserValidationError) Field() string { return e.field }
func (e UserValidationError) Reason() string { return e.reason }
func (e UserValidationError) Cause() error { return e.cause }
func (e UserValidationError) Key() bool { return e.key }
func (e UserValidationError) ErrorName() string { return "UserValidationError" }
func (e UserValidationError) 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 %sUser.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}
var _ error = UserValidationError{}
var _ interface {
	Field() string
	Reason() string
	Key() bool
	Cause() error
	ErrorName() string
} = UserValidationError{}
var _User_Attributes_Pattern = regexp.MustCompile("^[a-z0-9](?:[-]?[a-z0-9]){2,}$")
func (m *Users) ValidateFields(paths ...string) error {
	if m == nil {
		return nil
	}
	if len(paths) == 0 {
		paths = UsersFieldPathsNested
	}
	for name, subs := range _processPaths(append(paths[:0:0], paths...)) {
		_ = subs
		switch name {
		case "users":
			for idx, item := range m.GetUsers() {
				_, _ = idx, item
				if v, ok := interface{}(item).(interface{ ValidateFields(...string) error }); ok {
					if err := v.ValidateFields(subs...); err != nil {
						return UsersValidationError{
							field:  fmt.Sprintf("users[%v]", idx),
							reason: "embedded message failed validation",
							cause:  err,
						}
					}
				}
			}
		default:
			return UsersValidationError{
				field:  name,
				reason: "invalid field path",
			}
		}
	}
	return nil
}
type UsersValidationError struct {
	field  string
	reason string
	cause  error
	key    bool
}
func (e UsersValidationError) Field() string { return e.field }
func (e UsersValidationError) Reason() string { return e.reason }
func (e UsersValidationError) Cause() error { return e.cause }
func (e UsersValidationError) Key() bool { return e.key }
func (e UsersValidationError) ErrorName() string { return "UsersValidationError" }
func (e UsersValidationError) 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 %sUsers.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}
var _ error = UsersValidationError{}
var _ interface {
	Field() string
	Reason() string
	Key() bool
	Cause() error
	ErrorName() string
} = UsersValidationError{}
func (m *GetUserRequest) ValidateFields(paths ...string) error {
	if m == nil {
		return nil
	}
	if len(paths) == 0 {
		paths = GetUserRequestFieldPathsNested
	}
	for name, subs := range _processPaths(append(paths[:0:0], paths...)) {
		_ = subs
		switch name {
		case "user_ids":
			if m.GetUserIds() == nil {
				return GetUserRequestValidationError{
					field:  "user_ids",
					reason: "value is required",
				}
			}
			if v, ok := interface{}(m.GetUserIds()).(interface{ ValidateFields(...string) error }); ok {
				if err := v.ValidateFields(subs...); err != nil {
					return GetUserRequestValidationError{
						field:  "user_ids",
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		case "field_mask":
			if v, ok := interface{}(m.GetFieldMask()).(interface{ ValidateFields(...string) error }); ok {
				if err := v.ValidateFields(subs...); err != nil {
					return GetUserRequestValidationError{
						field:  "field_mask",
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		default:
			return GetUserRequestValidationError{
				field:  name,
				reason: "invalid field path",
			}
		}
	}
	return nil
}
type GetUserRequestValidationError struct {
	field  string
	reason string
	cause  error
	key    bool
}
func (e GetUserRequestValidationError) Field() string { return e.field }
func (e GetUserRequestValidationError) Reason() string { return e.reason }
func (e GetUserRequestValidationError) Cause() error { return e.cause }
func (e GetUserRequestValidationError) Key() bool { return e.key }
func (e GetUserRequestValidationError) ErrorName() string { return "GetUserRequestValidationError" }
func (e GetUserRequestValidationError) 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 %sGetUserRequest.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}
var _ error = GetUserRequestValidationError{}
var _ interface {
	Field() string
	Reason() string
	Key() bool
	Cause() error
	ErrorName() string
} = GetUserRequestValidationError{}
func (m *ListUsersRequest) ValidateFields(paths ...string) error {
	if m == nil {
		return nil
	}
	if len(paths) == 0 {
		paths = ListUsersRequestFieldPathsNested
	}
	for name, subs := range _processPaths(append(paths[:0:0], paths...)) {
		_ = subs
		switch name {
		case "field_mask":
			if v, ok := interface{}(m.GetFieldMask()).(interface{ ValidateFields(...string) error }); ok {
				if err := v.ValidateFields(subs...); err != nil {
					return ListUsersRequestValidationError{
						field:  "field_mask",
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		case "order":
			if _, ok := _ListUsersRequest_Order_InLookup[m.GetOrder()]; !ok {
				return ListUsersRequestValidationError{
					field:  "order",
					reason: "value must be in list [ user_id -user_id name -name primary_email_address -primary_email_address state -state admin -admin created_at -created_at]",
				}
			}
		case "limit":
			if m.GetLimit() > 1000 {
				return ListUsersRequestValidationError{
					field:  "limit",
					reason: "value must be less than or equal to 1000",
				}
			}
		case "page":
		case "deleted":
		default:
			return ListUsersRequestValidationError{
				field:  name,
				reason: "invalid field path",
			}
		}
	}
	return nil
}
type ListUsersRequestValidationError struct {
	field  string
	reason string
	cause  error
	key    bool
}
func (e ListUsersRequestValidationError) Field() string { return e.field }
func (e ListUsersRequestValidationError) Reason() string { return e.reason }
func (e ListUsersRequestValidationError) Cause() error { return e.cause }
func (e ListUsersRequestValidationError) Key() bool { return e.key }
func (e ListUsersRequestValidationError) ErrorName() string { return "ListUsersRequestValidationError" }
func (e ListUsersRequestValidationError) 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 %sListUsersRequest.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}
var _ error = ListUsersRequestValidationError{}
var _ interface {
	Field() string
	Reason() string
	Key() bool
	Cause() error
	ErrorName() string
} = ListUsersRequestValidationError{}
var _ListUsersRequest_Order_InLookup = map[string]struct{}{
	"":                       {},
	"user_id":                {},
	"-user_id":               {},
	"name":                   {},
	"-name":                  {},
	"primary_email_address":  {},
	"-primary_email_address": {},
	"state":                  {},
	"-state":                 {},
	"admin":                  {},
	"-admin":                 {},
	"created_at":             {},
	"-created_at":            {},
}
func (m *CreateUserRequest) ValidateFields(paths ...string) error {
	if m == nil {
		return nil
	}
	if len(paths) == 0 {
		paths = CreateUserRequestFieldPathsNested
	}
	for name, subs := range _processPaths(append(paths[:0:0], paths...)) {
		_ = subs
		switch name {
		case "user":
			if m.GetUser() == nil {
				return CreateUserRequestValidationError{
					field:  "user",
					reason: "value is required",
				}
			}
			if v, ok := interface{}(m.GetUser()).(interface{ ValidateFields(...string) error }); ok {
				if err := v.ValidateFields(subs...); err != nil {
					return CreateUserRequestValidationError{
						field:  "user",
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		case "invitation_token":
		default:
			return CreateUserRequestValidationError{
				field:  name,
				reason: "invalid field path",
			}
		}
	}
	return nil
}
type CreateUserRequestValidationError struct {
	field  string
	reason string
	cause  error
	key    bool
}
func (e CreateUserRequestValidationError) Field() string { return e.field }
func (e CreateUserRequestValidationError) Reason() string { return e.reason }
func (e CreateUserRequestValidationError) Cause() error { return e.cause }
func (e CreateUserRequestValidationError) Key() bool { return e.key }
func (e CreateUserRequestValidationError) ErrorName() string {
	return "CreateUserRequestValidationError"
}
func (e CreateUserRequestValidationError) 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 %sCreateUserRequest.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}
var _ error = CreateUserRequestValidationError{}
var _ interface {
	Field() string
	Reason() string
	Key() bool
	Cause() error
	ErrorName() string
} = CreateUserRequestValidationError{}
func (m *UpdateUserRequest) ValidateFields(paths ...string) error {
	if m == nil {
		return nil
	}
	if len(paths) == 0 {
		paths = UpdateUserRequestFieldPathsNested
	}
	for name, subs := range _processPaths(append(paths[:0:0], paths...)) {
		_ = subs
		switch name {
		case "user":
			if m.GetUser() == nil {
				return UpdateUserRequestValidationError{
					field:  "user",
					reason: "value is required",
				}
			}
			if v, ok := interface{}(m.GetUser()).(interface{ ValidateFields(...string) error }); ok {
				if err := v.ValidateFields(subs...); err != nil {
					return UpdateUserRequestValidationError{
						field:  "user",
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		case "field_mask":
			if v, ok := interface{}(m.GetFieldMask()).(interface{ ValidateFields(...string) error }); ok {
				if err := v.ValidateFields(subs...); err != nil {
					return UpdateUserRequestValidationError{
						field:  "field_mask",
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		default:
			return UpdateUserRequestValidationError{
				field:  name,
				reason: "invalid field path",
			}
		}
	}
	return nil
}
type UpdateUserRequestValidationError struct {
	field  string
	reason string
	cause  error
	key    bool
}
func (e UpdateUserRequestValidationError) Field() string { return e.field }
func (e UpdateUserRequestValidationError) Reason() string { return e.reason }
func (e UpdateUserRequestValidationError) Cause() error { return e.cause }
func (e UpdateUserRequestValidationError) Key() bool { return e.key }
func (e UpdateUserRequestValidationError) ErrorName() string {
	return "UpdateUserRequestValidationError"
}