validation

package
v0.0.0-...-4f9d474 Latest Latest
Warning

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

Go to latest
Published: May 29, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const DNS1123LabelMaxLength int = 63

DNS1123LabelMaxLength 是 DNS(RFC 1123)中标签的最大长度.

View Source
const DNS1123SubdomainMaxLength int = 253

DNS1123SubdomainMaxLength 是 DNS(RFC 1123)中子域的最大长度.

View Source
const LabelValueMaxLength int = 63

LabelValueMaxLength 是一个标签的最大长度.

Variables

This section is empty.

Functions

func EmptyError

func EmptyError() string

EmptyError 空值错误.

func InclusiveRangeError

func InclusiveRangeError(lo, hi int) string

InclusiveRangeError 范围错误.

func IsDNS1123Label

func IsDNS1123Label(value string) []string

IsDNS1123Label 检查 value 是否是符合 DNS(RFC 1123)中标签定义的字符串.

func IsDNS1123Subdomain

func IsDNS1123Subdomain(value string) []string

IsDNS1123Subdomain 检查 value 是否是符合 DNS(RFC 1123)中子域定义的字符串.

func IsInRange

func IsInRange(value int, min int, max int) []string

IsInRange 检查 value 是否在指定范围内.

func IsQualifiedName

func IsQualifiedName(value string) []string

IsQualifiedName 检查 value 是否是一个合法的名字.

func IsValidIP

func IsValidIP(value string) []string

IsValidIP 检查 value 是否是可用 IP 地址.

func IsValidLabelValue

func IsValidLabelValue(value string) []string

IsValidLabelValue 检查 value 是否是一个合法的标签.

func IsValidPassword

func IsValidPassword(password string) error

IsValidPassword 检查 password 是否是一个合法密码.

func IsValidPercent

func IsValidPercent(percent string) []string

IsValidPercent 检查字符串是否是百分比形式.

func IsValidPortNum

func IsValidPortNum(port int) []string

IsValidPortNum 检查 value 是否是非 0 端口号.

func MaxLenError

func MaxLenError(length int) string

MaxLenError 字符串过长错误.

func RegexError

func RegexError(msg string, fmt string, examples ...string) string

RegexError 正则不匹配错误.

Types

type Validator

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

Validator is a custom validator for configs.

func NewValidator

func NewValidator(data interface{}) *Validator

NewValidator creates a new Validator.

func (*Validator) Validate

func (v *Validator) Validate() field.ErrorList

Validate validates config for errors and returns an error (it can be casted to ValidationErrors, containing a list of errors inside). When error is printed as string, it will automatically contains the full list of validation errors.

Directories

Path Synopsis
Package field implements field path functions when do validation.
Package field implements field path functions when do validation.

Jump to

Keyboard shortcuts

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