func (e SearchUsersRequestValidationError) ErrorName() string {
	return "SearchUsersRequestValidationError"
}
ErrorName returns error name.
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 _search_services_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 *SearchApplicationsRequest) ValidateFields(paths ...string) error {
	if m == nil {
		return nil
	}
	if len(paths) == 0 {
		paths = SearchApplicationsRequestFieldPathsNested
	}
	for name, subs := range _processPaths(append(paths[:0:0], paths...)) {
		_ = subs
		switch name {
		case "id_contains":
			if utf8.RuneCountInString(m.GetIdContains()) > 50 {
				return SearchApplicationsRequestValidationError{
					field:  "id_contains",
					reason: "value length must be at most 50 runes",
				}
			}
		case "name_contains":
			if utf8.RuneCountInString(m.GetNameContains()) > 50 {
				return SearchApplicationsRequestValidationError{
					field:  "name_contains",
					reason: "value length must be at most 50 runes",
				}
			}
		case "description_contains":
			if utf8.RuneCountInString(m.GetDescriptionContains()) > 50 {
				return SearchApplicationsRequestValidationError{
					field:  "description_contains",
					reason: "value length must be at most 50 runes",
				}
			}
		case "attributes_contain":
			if len(m.GetAttributesContain()) > 10 {
				return SearchApplicationsRequestValidationError{
					field:  "attributes_contain",
					reason: "value must contain no more than 10 pair(s)",
				}
			}
			for key, val := range m.GetAttributesContain() {
				_ = val
				if utf8.RuneCountInString(key) > 36 {
					return SearchApplicationsRequestValidationError{
						field:  fmt.Sprintf("attributes_contain[%v]", key),
						reason: "value length must be at most 36 runes",
					}
				}
				if !_SearchApplicationsRequest_AttributesContain_Pattern.MatchString(key) {
					return SearchApplicationsRequestValidationError{
						field:  fmt.Sprintf("attributes_contain[%v]", key),
						reason: "value does not match regex pattern \"^[a-z0-9](?:[-]?[a-z0-9]){2,}$\"",
					}
				}
				if utf8.RuneCountInString(val) > 50 {
					return SearchApplicationsRequestValidationError{
						field:  fmt.Sprintf("attributes_contain[%v]", key),
						reason: "value length must be at most 50 runes",
					}
				}
			}
		case "field_mask":
			if v, ok := interface{}(m.GetFieldMask()).(interface{ ValidateFields(...string) error }); ok {
				if err := v.ValidateFields(subs...); err != nil {
					return SearchApplicationsRequestValidationError{
						field:  "field_mask",
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		case "order":
			if _, ok := _SearchApplicationsRequest_Order_InLookup[m.GetOrder()]; !ok {
				return SearchApplicationsRequestValidationError{
					field:  "order",
					reason: "value must be in list [ application_id -application_id name -name created_at -created_at]",
				}
			}
		case "limit":
			if m.GetLimit() > 1000 {
				return SearchApplicationsRequestValidationError{
					field:  "limit",
					reason: "value must be less than or equal to 1000",
				}
			}
		case "page":
		case "deleted":
		default:
			return SearchApplicationsRequestValidationError{
				field:  name,
				reason: "invalid field path",
			}
		}
	}
	return nil
}
type SearchApplicationsRequestValidationError struct {
	field  string
	reason string
	cause  error
	key    bool
}
func (e SearchApplicationsRequestValidationError) Field() string { return e.field }
func (e SearchApplicationsRequestValidationError) Reason() string { return e.reason }
func (e SearchApplicationsRequestValidationError) Cause() error { return e.cause }
func (e SearchApplicationsRequestValidationError) Key() bool { return e.key }
func (e SearchApplicationsRequestValidationError) ErrorName() string {
	return "SearchApplicationsRequestValidationError"
}
func (e SearchApplicationsRequestValidationError) 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 %sSearchApplicationsRequest.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}
var _ error = SearchApplicationsRequestValidationError{}
var _ interface {
	Field() string
	Reason() string
	Key() bool
	Cause() error
	ErrorName() string
} = SearchApplicationsRequestValidationError{}
var _SearchApplicationsRequest_AttributesContain_Pattern = regexp.MustCompile("^[a-z0-9](?:[-]?[a-z0-9]){2,}$")
var _SearchApplicationsRequest_Order_InLookup = map[string]struct{}{
	"":                {},
	"application_id":  {},
	"-application_id": {},
	"name":            {},
	"-name":           {},
	"created_at":      {},
	"-created_at":     {},
}
func (m *SearchClientsRequest) ValidateFields(paths ...string) error {
	if m == nil {
		return nil
	}
	if len(paths) == 0 {
		paths = SearchClientsRequestFieldPathsNested
	}
	for name, subs := range _processPaths(append(paths[:0:0], paths...)) {
		_ = subs
		switch name {
		case "id_contains":
			if utf8.RuneCountInString(m.GetIdContains()) > 50 {
				return SearchClientsRequestValidationError{
					field:  "id_contains",
					reason: "value length must be at most 50 runes",
				}
			}
		case "name_contains":
			if utf8.RuneCountInString(m.GetNameContains()) > 50 {
				return SearchClientsRequestValidationError{
					field:  "name_contains",
					reason: "value length must be at most 50 runes",
				}
			}
		case "description_contains":
			if utf8.RuneCountInString(m.GetDescriptionContains()) > 50 {
				return SearchClientsRequestValidationError{
					field:  "description_contains",
					reason: "value length must be at most 50 runes",
				}
			}
		case "attributes_contain":
			if len(m.GetAttributesContain()) > 10 {
				return SearchClientsRequestValidationError{
					field:  "attributes_contain",
					reason: "value must contain no more than 10 pair(s)",
				}
			}
			for key, val := range m.GetAttributesContain() {
				_ = val
				if utf8.RuneCountInString(key) > 36 {
					return SearchClientsRequestValidationError{
						field:  fmt.Sprintf("attributes_contain[%v]", key),
						reason: "value length must be at most 36 runes",
					}
				}
				if !_SearchClientsRequest_AttributesContain_Pattern.MatchString(key) {
					return SearchClientsRequestValidationError{
						field:  fmt.Sprintf("attributes_contain[%v]", key),
						reason: "value does not match regex pattern \"^[a-z0-9](?:[-]?[a-z0-9]){2,}$\"",
					}
				}
				if utf8.RuneCountInString(val) > 50 {
					return SearchClientsRequestValidationError{
						field:  fmt.Sprintf("attributes_contain[%v]", key),
						reason: "value length must be at most 50 runes",
					}
				}
			}
		case "state":
			_SearchClientsRequest_State_Unique := make(map[State]struct{}, len(m.GetState()))
			for idx, item := range m.GetState() {
				_, _ = idx, item
				if _, exists := _SearchClientsRequest_State_Unique[item]; exists {
					return SearchClientsRequestValidationError{
						field:  fmt.Sprintf("state[%v]", idx),
						reason: "repeated value must contain unique items",
					}
				} else {
					_SearchClientsRequest_State_Unique[item] = struct{}{}
				}
				if _, ok := State_name[int32(item)]; !ok {
					return SearchClientsRequestValidationError{
						field:  fmt.Sprintf("state[%v]", idx),
						reason: "value must be one of the defined enum values",
					}
				}
			}
		case "field_mask":
			if v, ok := interface{}(m.GetFieldMask()).(interface{ ValidateFields(...string) error }); ok {
				if err := v.ValidateFields(subs...); err != nil {
					return SearchClientsRequestValidationError{
						field:  "field_mask",
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		case "order":
			if _, ok := _SearchClientsRequest_Order_InLookup[m.GetOrder()]; !ok {
				return SearchClientsRequestValidationError{
					field:  "order",
					reason: "value must be in list [ client_id -client_id name -name created_at -created_at]",
				}
			}
		case "limit":
			if m.GetLimit() > 1000 {
				return SearchClientsRequestValidationError{
					field:  "limit",
					reason: "value must be less than or equal to 1000",
				}
			}
		case "page":
		case "deleted":
		default:
			return SearchClientsRequestValidationError{
				field:  name,
				reason: "invalid field path",
			}
		}
	}
	return nil
}
type SearchClientsRequestValidationError struct {
	field  string
	reason string
	cause  error
	key    bool
}
func (e SearchClientsRequestValidationError) Field() string { return e.field }
func (e SearchClientsRequestValidationError) Reason() string { return e.reason }
func (e SearchClientsRequestValidationError) Cause() error { return e.cause }
func (e SearchClientsRequestValidationError) Key() bool { return e.key }
func (e SearchClientsRequestValidationError) ErrorName() string {
	return "SearchClientsRequestValidationError"
}
func (e SearchClientsRequestValidationError) 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 %sSearchClientsRequest.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}
var _ error = SearchClientsRequestValidationError{}
var _ interface {
	Field() string
	Reason() string
	Key() bool
	Cause() error
	ErrorName() string
} = SearchClientsRequestValidationError{}
var _SearchClientsRequest_AttributesContain_Pattern = regexp.MustCompile("^[a-z0-9](?:[-]?[a-z0-9]){2,}$")
var _SearchClientsRequest_Order_InLookup = map[string]struct{}{
	"":            {},
	"client_id":   {},
	"-client_id":  {},
	"name":        {},
	"-name":       {},
	"created_at":  {},
	"-created_at": {},
}
func (m *SearchGatewaysRequest) ValidateFields(paths ...string) error {
	if m == nil {
		return nil
	}
	if len(paths) == 0 {
		paths = SearchGatewaysRequestFieldPathsNested
	}
	for name, subs := range _processPaths(append(paths[:0:0], paths...)) {
		_ = subs
		switch name {
		case "id_contains":
			if utf8.RuneCountInString(m.GetIdContains()) > 50 {
				return SearchGatewaysRequestValidationError{
					field:  "id_contains",
					reason: "value length must be at most 50 runes",
				}
			}
		case "name_contains":
			if utf8.RuneCountInString(m.GetNameContains()) > 50 {
				return SearchGatewaysRequestValidationError{
					field:  "name_contains",
					reason: "value length must be at most 50 runes",
				}
			}
		case "description_contains":
			if utf8.RuneCountInString(m.GetDescriptionContains()) > 50 {
				return SearchGatewaysRequestValidationError{
					field:  "description_contains",
					reason: "value length must be at most 50 runes",
				}
			}
		case "attributes_contain":
			if len(m.GetAttributesContain()) > 10 {
				return SearchGatewaysRequestValidationError{
					field:  "attributes_contain",
					reason: "value must contain no more than 10 pair(s)",
				}
			}
			for key, val := range m.GetAttributesContain() {
				_ = val
				if utf8.RuneCountInString(key) > 36 {
					return SearchGatewaysRequestValidationError{
						field:  fmt.Sprintf("attributes_contain[%v]", key),
						reason: "value length must be at most 36 runes",
					}
				}
				if !_SearchGatewaysRequest_AttributesContain_Pattern.MatchString(key) {
					return SearchGatewaysRequestValidationError{
						field:  fmt.Sprintf("attributes_contain[%v]", key),
						reason: "value does not match regex pattern \"^[a-z0-9](?:[-]?[a-z0-9]){2,}$\"",
					}
				}
				if utf8.RuneCountInString(val) > 50 {
					return SearchGatewaysRequestValidationError{
						field:  fmt.Sprintf("attributes_contain[%v]", key),
						reason: "value length must be at most 50 runes",
					}
				}
			}
		case "eui_contains":
			if utf8.RuneCountInString(m.GetEuiContains()) > 16 {
				return SearchGatewaysRequestValidationError{
					field:  "eui_contains",
					reason: "value length must be at most 16 runes",
				}
			}
		case "field_mask":
			if v, ok := interface{}(m.GetFieldMask()).(interface{ ValidateFields(...string) error }); ok {
				if err := v.ValidateFields(subs...); err != nil {
					return SearchGatewaysRequestValidationError{
						field:  "field_mask",
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		case "order":
			if _, ok := _SearchGatewaysRequest_Order_InLookup[m.GetOrder()]; !ok {
				return SearchGatewaysRequestValidationError{
					field:  "order",
					reason: "value must be in list [ gateway_id -gateway_id gateway_eui -gateway_eui name -name created_at -created_at]",
				}
			}
		case "limit":
			if m.GetLimit() > 1000 {
				return SearchGatewaysRequestValidationError{
					field:  "limit",
					reason: "value must be less than or equal to 1000",
				}
			}
		case "page":
		case "deleted":
		default:
			return SearchGatewaysRequestValidationError{
				field:  name,
				reason: "invalid field path",
			}
		}
	}
	return nil
}
type SearchGatewaysRequestValidationError struct {
	field  string
	reason string
	cause  error
	key    bool
}
func (e SearchGatewaysRequestValidationError) Field() string { return e.field }
func (e SearchGatewaysRequestValidationError) Reason() string { return e.reason }
func (e SearchGatewaysRequestValidationError) Cause() error { return e.cause }
func (e SearchGatewaysRequestValidationError) Key() bool { return e.key }
func (e SearchGatewaysRequestValidationError) ErrorName() string {
	return "SearchGatewaysRequestValidationError"
}
func (e SearchGatewaysRequestValidationError) 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 %sSearchGatewaysRequest.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}
var _ error = SearchGatewaysRequestValidationError{}
var _ interface {
	Field() string
	Reason() string
	Key() bool
	Cause() error
	ErrorName() string
} = SearchGatewaysRequestValidationError{}
var _SearchGatewaysRequest_AttributesContain_Pattern = regexp.MustCompile("^[a-z0-9](?:[-]?[a-z0-9]){2,}$")
var _SearchGatewaysRequest_Order_InLookup = map[string]struct{}{
	"":             {},
	"gateway_id":   {},
	"-gateway_id":  {},
	"gateway_eui":  {},
	"-gateway_eui": {},
	"name":         {},
	"-name":        {},
	"created_at":   {},
	"-created_at":  {},
}
func (m *SearchOrganizationsRequest) ValidateFields(paths ...string) error {
	if m == nil {
		return nil
	}
	if len(paths) == 0 {
		paths = SearchOrganizationsRequestFieldPathsNested
	}
	for name, subs := range _processPaths(append(paths[:0:0], paths...)) {
		_ = subs
		switch name {
		case "id_contains":
			if utf8.RuneCountInString(m.GetIdContains()) > 50 {
				return SearchOrganizationsRequestValidationError{
					field:  "id_contains",
					reason: "value length must be at most 50 runes",
				}
			}
		case "name_contains":
			if utf8.RuneCountInString(m.GetNameContains()) > 50 {
				return SearchOrganizationsRequestValidationError{
					field:  "name_contains",
					reason: "value length must be at most 50 runes",
				}
			}
		case "description_contains":
			if utf8.RuneCountInString(m.GetDescriptionContains()) > 50 {
				return SearchOrganizationsRequestValidationError{
					field:  "description_contains",
					reason: "value length must be at most 50 runes",
				}
			}
		case "attributes_contain":
			if len(m.GetAttributesContain()) > 10 {
				return SearchOrganizationsRequestValidationError{
					field:  "attributes_contain",
					reason: "value must contain no more than 10 pair(s)",
				}
			}
			for key, val := range m.GetAttributesContain() {
				_ = val
				if utf8.RuneCountInString(key) > 36 {
					return SearchOrganizationsRequestValidationError{
						field:  fmt.Sprintf("attributes_contain[%v]", key),
						reason: "value length must be at most 36 runes",
					}
				}
				if !_SearchOrganizationsRequest_AttributesContain_Pattern.MatchString(key) {
					return SearchOrganizationsRequestValidationError{
						field:  fmt.Sprintf("attributes_contain[%v]", key),
						reason: "value does not match regex pattern \"^[a-z0-9](?:[-]?[a-z0-9]){2,}$\"",
					}
				}
				if utf8.RuneCountInString(val) > 50 {
					return SearchOrganizationsRequestValidationError{
						field:  fmt.Sprintf("attributes_contain[%v]", key),
						reason: "value length must be at most 50 runes",
					}
				}
			}
		case "field_mask":
			if v, ok := interface{}(m.GetFieldMask()).(interface{ ValidateFields(...string) error }); ok {
				if err := v.ValidateFields(subs...); err != nil {
					return SearchOrganizationsRequestValidationError{
						field:  "field_mask",
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		case "order":
			if _, ok := _SearchOrganizationsRequest_Order_InLookup[m.GetOrder()]; !ok {
				return SearchOrganizationsRequestValidationError{
					field:  "order",
					reason: "value must be in list [ organization_id -organization_id name -name created_at -created_at]",
				}
			}
		case "limit":
			if m.GetLimit() > 1000 {
				return SearchOrganizationsRequestValidationError{
					field:  "limit",
					reason: "value must be less than or equal to 1000",
				}
			}
		case "page":
		case "deleted":
		default:
			return SearchOrganizationsRequestValidationError{
				field:  name,
				reason: "invalid field path",
			}
		}
	}
	return nil
}
type SearchOrganizationsRequestValidationError struct {
	field  string
	reason string
	cause  error
	key    bool
}
func (e SearchOrganizationsRequestValidationError) Field() string { return e.field }
func (e SearchOrganizationsRequestValidationError) Reason() string { return e.reason }
func (e SearchOrganizationsRequestValidationError) Cause() error { return e.cause }
func (e SearchOrganizationsRequestValidationError) Key() bool { return e.key }
func (e SearchOrganizationsRequestValidationError) ErrorName() string {
	return "SearchOrganizationsRequestValidationError"
}
func (e SearchOrganizationsRequestValidationError) 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 %sSearchOrganizationsRequest.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}
var _ error = SearchOrganizationsRequestValidationError{}
var _ interface {
	Field() string
	Reason() string
	Key() bool
	Cause() error
	ErrorName() string
} = SearchOrganizationsRequestValidationError{}
var _SearchOrganizationsRequest_AttributesContain_Pattern = regexp.MustCompile("^[a-z0-9](?:[-]?[a-z0-9]){2,}$")
var _SearchOrganizationsRequest_Order_InLookup = map[string]struct{}{
	"":                 {},
	"organization_id":  {},
	"-organization_id": {},
	"name":             {},
	"-name":            {},
	"created_at":       {},
	"-created_at":      {},
}
func (m *SearchUsersRequest) ValidateFields(paths ...string) error {
	if m == nil {
		return nil
	}
	if len(paths) == 0 {
		paths = SearchUsersRequestFieldPathsNested
	}
	for name, subs := range _processPaths(append(paths[:0:0], paths...)) {
		_ = subs
		switch name {
		case "id_contains":
			if utf8.RuneCountInString(m.GetIdContains()) > 50 {
				return SearchUsersRequestValidationError{
					field:  "id_contains",
					reason: "value length must be at most 50 runes",
				}
			}
		case "name_contains":
			if utf8.RuneCountInString(m.GetNameContains()) > 50 {
				return SearchUsersRequestValidationError{
					field:  "name_contains",
					reason: "value length must be at most 50 runes",
				}
			}
		case "description_contains":
			if utf8.RuneCountInString(m.GetDescriptionContains()) > 50 {
				return SearchUsersRequestValidationError{
					field:  "description_contains",
					reason: "value length must be at most 50 runes",
				}
			}
		case "attributes_contain":
			if len(m.GetAttributesContain()) > 10 {
				return SearchUsersRequestValidationError{
					field:  "attributes_contain",
					reason: "value must contain no more than 10 pair(s)",
				}
			}
			for key, val := range m.GetAttributesContain() {
				_ = val
				if utf8.RuneCountInString(key) > 36 {
					return SearchUsersRequestValidationError{
						field:  fmt.Sprintf("attributes_contain[%v]", key),
						reason: "value length must be at most 36 runes",
					}
				}
				if !_SearchUsersRequest_AttributesContain_Pattern.MatchString(key) {
					return SearchUsersRequestValidationError{
						field:  fmt.Sprintf("attributes_contain[%v]", key),
						reason: "value does not match regex pattern \"^[a-z0-9](?:[-]?[a-z0-9]){2,}$\"",
					}
				}
				if utf8.RuneCountInString(val) > 50 {
					return SearchUsersRequestValidationError{
						field:  fmt.Sprintf("attributes_contain[%v]", key),
						reason: "value length must be at most 50 runes",
					}
				}
			}
		case "state":
			_SearchUsersRequest_State_Unique := make(map[State]struct{}, len(m.GetState()))
			for idx, item := range m.GetState() {
				_, _ = idx, item
				if _, exists := _SearchUsersRequest_State_Unique[item]; exists {
					return SearchUsersRequestValidationError{
						field:  fmt.Sprintf("state[%v]", idx),
						reason: "repeated value must contain unique items",
					}
				} else {
					_SearchUsersRequest_State_Unique[item] = struct{}{}
				}
				if _, ok := State_name[int32(item)]; !ok {
					return SearchUsersRequestValidationError{
						field:  fmt.Sprintf("state[%v]", idx),
						reason: "value must be one of the defined enum values",
					}
				}
			}
		case "field_mask":
			if v, ok := interface{}(m.GetFieldMask()).(interface{ ValidateFields(...string) error }); ok {
				if err := v.ValidateFields(subs...); err != nil {
					return SearchUsersRequestValidationError{
						field:  "field_mask",
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		case "order":
			if _, ok := _SearchUsersRequest_Order_InLookup[m.GetOrder()]; !ok {
				return SearchUsersRequestValidationError{
					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 SearchUsersRequestValidationError{
					field:  "limit",
					reason: "value must be less than or equal to 1000",
				}
			}
		case "page":
		case "deleted":
		default:
			return SearchUsersRequestValidationError{
				field:  name,
				reason: "invalid field path",
			}
		}
	}
	return nil
}
type SearchUsersRequestValidationError struct {
	field  string
	reason string
	cause  error
	key    bool
}
func (e SearchUsersRequestValidationError) Field() string { return e.field }
func (e SearchUsersRequestValidationError) Reason() string { return e.reason }
func (e SearchUsersRequestValidationError) Cause() error { return e.cause }
func (e SearchUsersRequestValidationError) Key() bool { return e.key }