protovalidator

package
v0.0.0-...-c713541 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 28, 2023 License: MIT Imports: 13 Imported by: 9

Documentation

Index

Constants

View Source
const (
	TagFloatEq    = "float.eq"
	TagFloatNe    = "float.ne"
	TagFloatGt    = "float.gt"
	TagFloatLt    = "float.lt"
	TagFloatGte   = "float.gte"
	TagFloatLte   = "float.lte"
	TagFloatIn    = "float.in"
	TagFloatNotIn = "float.not_in"
)

tag const for float.

View Source
const (
	TagIntEq    = "int.eq"
	TagIntNe    = "int.ne"
	TagIntGt    = "int.gt"
	TagIntLt    = "int.lt"
	TagIntGte   = "int.gte"
	TagIntLte   = "int.lte"
	TagIntIn    = "int.in"
	TagIntNotIn = "int.not_in"
)

tag const for int.

View Source
const (
	TagUintEq    = "uint.eq"
	TagUintNe    = "uint.ne"
	TagUintGt    = "uint.gt"
	TagUintLt    = "uint.lt"
	TagUintGte   = "uint.gte"
	TagUintLte   = "uint.lte"
	TagUintIn    = "uint.in"
	TagUintNotIn = "uint.not_in"
)

tag const for uint.

View Source
const (
	TagStringEq    = "string.eq"
	TagStringNe    = "string.ne"
	TagStringGt    = "string.gt"
	TagStringLt    = "string.lt"
	TagStringGte   = "string.gte"
	TagStringLte   = "string.lte"
	TagStringIn    = "string.in"
	TagStringNotIn = "string.not_in"

	TagStringCharLenEq  = "string.char_len_eq"
	TagStringCharLenNe  = "string.char_len_ne"
	TagStringCharLenGt  = "string.char_len_gt"
	TagStringCharLenLt  = "string.char_len_lt"
	TagStringCharLenGte = "string.char_len_gte"
	TagStringCharLenLte = "string.char_len_lte"

	TagStringByteLenEq  = "string.byte_len_eq"
	TagStringByteLenNe  = "string.byte_len_ne"
	TagStringByteLenGt  = "string.byte_len_gt"
	TagStringByteLenLt  = "string.byte_len_lt"
	TagStringByteLenGte = "string.byte_len_gte"
	TagStringByteLenLte = "string.byte_len_lte"

	TagStringRegex = "string.regex"

	TagStringPrefix         = "string.prefix"
	TagStringNoPrefix       = "string.no_prefix"
	TagStringSuffix         = "string.suffix"
	TagStringNoSuffix       = "string.no_suffix"
	TagStringContains       = "string.contains"
	TagStringNotContains    = "string.not_contains"
	TagStringContainsAny    = "string.contains_any"
	TagStringNotContainsAny = "string.not_contains_any"

	TagStringUTF8 = "string.utf8"

	TagStringAscii       = "string.ascii"
	TagStringPrintAscii  = "string.print_ascii"
	TagStringBoolean     = "string.boolean"
	TagStringLowercase   = "string.lowercase"
	TagStringUppercase   = "string.uppercase"
	TagStringAlpha       = "string.alpha"
	TagStringNumber      = "string.number"
	TagStringAlphaNumber = "string.alpha_number"

	TagStringIp              = "string.ip"
	TagStringIpv4            = "string.ipv4"
	TagStringIpv6            = "string.ipv6"
	TagStringIpAddr          = "string.ip_addr"
	TagStringIp4Addr         = "string.ip4_addr"
	TagStringIp6Addr         = "string.ip6_addr"
	TagStringCidr            = "string.cidr"
	TagStringCidrv4          = "string.cidrv4"
	TagStringCidrv6          = "string.cidrv6"
	TagStringMac             = "string.mac"
	TagStringTcpAddr         = "string.tcp_addr"
	TagStringTcp4Addr        = "string.tcp4_addr"
	TagStringTcp6Addr        = "string.tcp6_addr"
	TagStringUdpAddr         = "string.udp_addr"
	TagStringUdp4Addr        = "string.udp4_addr"
	TagStringUdp6Addr        = "string.udp6_addr"
	TagStringUnixAddr        = "string.unix_addr"
	TagStringHostname        = "string.hostname"
	TagStringHostnameRfc1123 = "string.hostname_rfc1123"
	TagStringHostnamePort    = "string.hostname_port"
	TagStringDataURI         = "string.data_uri"
	TagStringFQDN            = "string.fqdn"
	TagStringURI             = "string.uri"
	TagStringURL             = "string.url"
	TagStringURLEncoded      = "string.url_encoded"

	TagStringUnixCron    = "string.unix_cron"
	TagStringEmail       = "string.email"
	TagStringJSON        = "string.json"
	TagStringJWT         = "string.jwt"
	TagStringHTML        = "string.html"
	TagStringHTMLEncoded = "string.html_encoded"
	TagStringBase64      = "string.base64"
	TagStringBase64URL   = "string.base64_url"
	TagStringHexadecimal = "string.hexadecimal"
	TagStringDatetime    = "string.datetime"
	TagStringTimezone    = "string.timezone"
	TagStringUUID        = "string.uuid"
	TagStringUUID1       = "string.uuid1"
	TagStringUUID3       = "string.uuid3"
	TagStringUUID4       = "string.uuid4"
	TagStringUUID5       = "string.uuid5"
)

tag const for string.

View Source
const (
	TagBytesLenEq  = "bytes.len_eq"
	TagBytesLenNe  = "bytes.len_ne"
	TagBytesLenGt  = "bytes.len_gt"
	TagBytesLenLt  = "bytes.len_lt"
	TagBytesLenGte = "bytes.len_gte"
	TagBytesLenLte = "bytes.len_lte"
)

tag const for bytes.

View Source
const (
	TagEnumEq      = "enum.eq"
	TagEnumNe      = "enum.ne"
	TagEnumGt      = "enum.gt"
	TagEnumLt      = "enum.lt"
	TagEnumGte     = "enum.gte"
	TagEnumLte     = "enum.lte"
	TagEnumIn      = "enum.in"
	TagEnumNotIn   = "enum.not_in"
	TagEnumInEnums = "enum.in_enums"
)

tag const for enum.

View Source
const (
	TagMessageNotNull = "message.not_null"
	TagMessageSkip    = "message.skip"
)

tag const for message.

View Source
const (
	TagRepeatedNotNull = "repeated.not_null"
	TagRepeatedLenEq   = "repeated.len_eq"
	TagRepeatedLenNe   = "repeated.len_ne"
	TagRepeatedLenGt   = "repeated.len_gt"
	TagRepeatedLenLt   = "repeated.len_lt"
	TagRepeatedLenGte  = "repeated.len_gte"
	TagRepeatedLenLte  = "repeated.len_lte"
	TagRepeatedUnique  = "repeated.unique"
	TagRepeatedItem    = "repeated.item"
)

tag const for repeated.

View Source
const (
	TagMapNotNull = "map.not_null"
	TagMapLenEq   = "map.len_eq"
	TagMapLenNe   = "map.len_ne"
	TagMapLenGt   = "map.len_gt"
	TagMapLenLt   = "map.len_lt"
	TagMapLenGte  = "map.len_gte"
	TagMapLenLte  = "map.len_lte"
	TagMapKey     = "map.key"
	TagMapValue   = "map.value"
)

tag const for map.

View Source
const (
	TagBoolEq = "bool.eq"
)

tag const for bool.

View Source
const (
	TagOneOfNotNull = "oneof.not_null"
)

tag const for oneof

Variables

This section is empty.

Functions

func BoolPointerToString

func BoolPointerToString(v *bool) string

func BoolToString

func BoolToString(v bool) string

func BuildErrorReason

func BuildErrorReason(tagInfo *TagInfo, fieldDesc string) string

func EnumPointerToString

func EnumPointerToString(v interface{}) string

func FieldError1

func FieldError1(structName string, reason string, value string) error

func FieldError2

func FieldError2(structName string, reason string) error

func Float32PointerToString

func Float32PointerToString(v *float32) string

func Float32ToString

func Float32ToString(v float32) string

func Float64PointerToString

func Float64PointerToString(v *float64) string

func Float64ToString

func Float64ToString(v float64) string

func Int32PointerToString

func Int32PointerToString(v *int32) string

func Int32ToString

func Int32ToString(v int32) string

func Int64PointerToString

func Int64PointerToString(v *int64) string

func Int64ToString

func Int64ToString(v int64) string

func InvokeValidatorIfExists

func InvokeValidatorIfExists(candidate interface{}) error

InvokeValidatorIfExists for invoke the Validate method if a interface is a Validator.

func SliceIsUniqueBool

func SliceIsUniqueBool(a []bool) bool

func SliceIsUniqueBytes

func SliceIsUniqueBytes(a [][]byte) bool

func SliceIsUniqueEnum

func SliceIsUniqueEnum(a interface{}) bool

func SliceIsUniqueFloat32

func SliceIsUniqueFloat32(a []float32) bool

func SliceIsUniqueFloat64

func SliceIsUniqueFloat64(a []float64) bool

func SliceIsUniqueInt32

func SliceIsUniqueInt32(a []int32) bool

func SliceIsUniqueInt64

func SliceIsUniqueInt64(a []int64) bool

func SliceIsUniqueMessage

func SliceIsUniqueMessage(a interface{}) bool

func SliceIsUniqueString

func SliceIsUniqueString(a []string) bool

func SliceIsUniqueUint32

func SliceIsUniqueUint32(a []uint32) bool

func SliceIsUniqueUint64

func SliceIsUniqueUint64(a []uint64) bool

func StringByteLenToString

func StringByteLenToString(s string) string

func StringCharsetLenToString

func StringCharsetLenToString(s string) string

func StringIsAlpha

func StringIsAlpha(s string) bool

StringIsAlpha allowed a ~ z and A ~ Z

func StringIsAlphaNumber

func StringIsAlphaNumber(s string) bool

func StringIsAscii

func StringIsAscii(s string) bool

StringIsAscii check whether the string is ascii charset.

func StringIsBase64

func StringIsBase64(s string) bool

func StringIsBase64URL

func StringIsBase64URL(s string) bool

func StringIsBoolean

func StringIsBoolean(s string) bool

func StringIsCIDR

func StringIsCIDR(s string) bool

StringIsCIDR is the validation function for validating if the field's value is a valid v4 or v6 CIDR address.

func StringIsCIDRv4

func StringIsCIDRv4(s string) bool

StringIsCIDRv4 is the validation function for validating if the field's value is a valid v4 CIDR address.

func StringIsCIDRv6

func StringIsCIDRv6(s string) bool

StringIsCIDRv6 is the validation function for validating if the field's value is a valid v6 CIDR address.

func StringIsDataURI

func StringIsDataURI(s string) bool

StringIsDataURI is the validation function for validating if the field's value is a valid data URI.

func StringIsDatetime

func StringIsDatetime(s string, layout string) bool

func StringIsEmail

func StringIsEmail(s string) bool

func StringIsFQDN

func StringIsFQDN(s string) bool

func StringIsHTML

func StringIsHTML(s string) bool

func StringIsHTMLEncoded

func StringIsHTMLEncoded(s string) bool

func StringIsHexadecimal

func StringIsHexadecimal(s string) bool

func StringIsHostname

func StringIsHostname(s string) bool

func StringIsHostnamePort

func StringIsHostnamePort(s string) bool

func StringIsHostnameRFC1123

func StringIsHostnameRFC1123(s string) bool

func StringIsIP

func StringIsIP(s string) bool

StringIsIP is the validation function for validating if the field's value is a valid v4 or v6 IP address.

func StringIsIP4Addr

func StringIsIP4Addr(s string) bool

StringIsIP4Addr is the validation function for validating if the field's value is a resolvable ip4 address.

func StringIsIP6Addr

func StringIsIP6Addr(s string) bool

StringIsIP6Addr is the validation function for validating if the field's value is a resolvable ip6 address.

func StringIsIPAddr

func StringIsIPAddr(s string) bool

StringIsIPAddr is the validation function for validating if the field's value is a resolvable ip address.

func StringIsIPv4

func StringIsIPv4(s string) bool

StringIsIPv4 is the validation function for validating if a value is a valid v4 IP address.

func StringIsIPv6

func StringIsIPv6(s string) bool

StringIsIPv6 is the validation function for validating if the field's value is a valid v6 IP address.

func StringIsJSON

func StringIsJSON(s string) bool

func StringIsJWT

func StringIsJWT(s string) bool

func StringIsLowercase

func StringIsLowercase(s string) bool

func StringIsMAC

func StringIsMAC(s string) bool

StringIsMAC is the validation function for validating if the field's value is a valid MAC address.

func StringIsNumber

func StringIsNumber(s string) bool

func StringIsPrintAscii

func StringIsPrintAscii(s string) bool

func StringIsTCP4Addr

func StringIsTCP4Addr(s string) bool

StringIsTCP4Addr is the validation function for validating if the field's value is a resolvable tcp4 address.

func StringIsTCP6Addr

func StringIsTCP6Addr(s string) bool

StringIsTCP6Addr is the validation function for validating if the field's value is a resolvable tcp6 address.

func StringIsTCPAddr

func StringIsTCPAddr(s string) bool

StringIsTCPAddr is the validation function for validating if the field's value is a resolvable tcp address.

func StringIsTimezone

func StringIsTimezone(s string) bool

func StringIsUDP4Addr

func StringIsUDP4Addr(s string) bool

StringIsUDP4Addr is the validation function for validating if the field's value is a resolvable udp4 address.

func StringIsUDP6Addr

func StringIsUDP6Addr(s string) bool

StringIsUDP6Addr is the validation function for validating if the field's value is a resolvable udp6 address.

func StringIsUDPAddr

func StringIsUDPAddr(s string) bool

StringIsUDPAddr is the validation function for validating if the field's value is a resolvable udp address.

func StringIsURI

func StringIsURI(s string) bool

StringIsURI is the validation function for validating if the current field's value is a valid URI.

func StringIsURL

func StringIsURL(s string) bool

StringIsURL is the validation function for validating if the current field's value is a valid URL.

func StringIsURLEncoded

func StringIsURLEncoded(s string) bool

func StringIsUUID

func StringIsUUID(s string) bool

func StringIsUUID1

func StringIsUUID1(s string) bool

func StringIsUUID3

func StringIsUUID3(s string) bool

func StringIsUUID4

func StringIsUUID4(s string) bool

func StringIsUUID5

func StringIsUUID5(s string) bool

func StringIsUnixAddr

func StringIsUnixAddr(s string) bool

StringIsUnixAddr is the validation function for validating if the field's value is a resolvable unix address.

func StringIsUnixCron

func StringIsUnixCron(s string) bool

func StringIsUppercase

func StringIsUppercase(s string) bool

func StringPointerByteLenToString

func StringPointerByteLenToString(s *string) string

func StringPointerCharsetLenToString

func StringPointerCharsetLenToString(s *string) string

func StringPointerToString

func StringPointerToString(v *string) string

func Uint32PointerToString

func Uint32PointerToString(v *uint32) string

func Uint32ToString

func Uint32ToString(v uint32) string

func Uint64PointerToString

func Uint64PointerToString(v *uint64) string

func Uint64ToString

func Uint64ToString(v uint64) string

Types

type TagInfo

type TagInfo struct {
	Cond       string      // The if condition.
	Tag        string      // The tag name.
	Value      interface{} // The tag value that user expected.
	FieldValue string      // The variable name of field value.
}

type ValidateError

type ValidateError struct {
	// contains filtered or unexported fields
}

func (*ValidateError) Error

func (e *ValidateError) Error() string

type Validator

type Validator interface {
	Validate() error
}

Validator is a general interface that allows a message to be validated.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL