is

package module
v0.0.0-...-1fe7fd4 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2024 License: MIT Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBadType  = errors.New("bad value type")
	ErrBadRange = errors.New("bad value range")
)

Functions

func ASCII

func ASCII(str string) bool

ASCII is the validation function for validating if the field's value is a valid ASCII character.

func Alpha

func Alpha(str string) bool

Alpha is the validation function for validating if the current field's value is a valid alpha value.

func AlphaUnicode

func AlphaUnicode(str string) bool

AlphaUnicode is the validation function for validating if the current field's value is a valid alpha unicode value.

func Alphanumeric

func Alphanumeric(str string) bool

Alphanumeric is the validation function for validating if the current field's value is a valid alphanumeric value.

func AlphanumericUnicode

func AlphanumericUnicode(str string) bool

AlphanumericUnicode is the validation function for validating if the current field's value is a valid alphanumeric unicode value.

func Base64

func Base64(s string) bool

Base64 判断给出的字符串是否为base64数据

func Base64URL

func Base64URL(str string) bool

Base64URL 判断给出的字符串是否为有效且安全的 base64URL

func Between

func Between(val, min, max any) bool

func Boolean

func Boolean[T any](t T) bool

Boolean is the validation function for validating if the current field's value can be safely converted to a boolean.

func Color

func Color(str string) bool

Color 判断给出的字符串是不是一个颜色值

func Compare

func Compare(srcVal, dstVal any, op string) bool

Compare intX,floatX value by given op. returns `srcVal op(=,!=,<,<=,>,>=) dstVal`

Usage:

compare(2, 3, ">") // false
compare(2, 1.3, ">") // true
compare(2.2, 1.3, ">") // true
compare(2.1, 2, ">") // true

func Datetime

func Datetime(str, layout string) bool

func Default

func Default(val any) bool

Default is the opposite of required aka HasValue

func Dir

func Dir(val any) bool

Dir is the validation function for validating if the current field's value is a valid directory.

func E164

func E164(str string) bool

E164 判断给出的字符串是否符合 e.164 规范的手机号码

func Email

func Email(str string) bool

Email 验证给出的字符串是不是有效的邮箱地址

func Empty

func Empty[T any](t T) bool

Empty checks if a value is empty or not. A value is considered empty if - integer, float: zero - bool: false - string, array: len() == 0 - slice, map: nil or len() == 0 - interface, pointer: nil or the referenced value is empty

func Equal

func Equal(a, b any) bool

Equal is the validation function for validating if the current field's value is equal to the param's value.

func File

func File(val any) bool

File is the validation function for validating if the current field's value is a valid file path.

func GreaterEqualThan

func GreaterEqualThan(a, b any) bool

GreaterEqualThan is the validation function for validating if the current field's value is greater than or equal to the param's value.

func GreaterThan

func GreaterThan(a, b any) bool

GreaterThan is the validation function for validating if the current field's value is greater than the param's value.

func HEXColor

func HEXColor(str string) bool

HEXColor is the validation function for validating if the current field's value is a valid HEX color.

func HSL

func HSL(str string) bool

HSL is the validation function for validating if the current field's value is a valid HSL color.

func HSLA

func HSLA(str string) bool

HSLA is the validation function for validating if the current field's value is a valid HSLA color.

func HTML

func HTML(str string) bool

func HTMLEncoded

func HTMLEncoded(str string) bool

func HasValue

func HasValue(val any) bool

HasValue is the validation function for validating if the current field's value is not the default static value.

func Hexadecimal

func Hexadecimal(str string) bool

Hexadecimal is the validation function for validating if the current field's value is a valid hexadecimal.

func IP

func IP(str string) bool

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

func IPv4

func IPv4(str string) bool

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

func IPv6

func IPv6(str string) bool

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

func JSON

func JSON[T any](t T) bool

JSON is the validation function for validating if the current field's value is a valid json string.

func JWT

func JWT(str string) bool

JWT is the validation function for validating if the current field's value is a valid JWT string.

func Label

func Label(s string) bool

Label 判断给出的字符串是否符合变量命名规范

func Latitude

func Latitude[T any](t T) bool

Latitude is the validation function for validating if the field's value is a valid latitude coordinate.

func Length

func Length(val any, length int, op string) bool

func LengthBetween

func LengthBetween(val any, min, max int) bool

func LessEqualThan

func LessEqualThan(a, b any) bool

LessEqualThan is the validation function for validating if the current field's value is less than or equal to the param's value.

func LessThan

func LessThan(a, b any) bool

LessThan is the validation function for validating if the current field's value is less than the param's value.

func Longitude

func Longitude[T any](t T) bool

Longitude is the validation function for validating if the field's value is a valid longitude coordinate.

func Lowercase

func Lowercase(str string) bool

Lowercase is the validation function for validating if the current field's value is a lowercase string.

func MAC

func MAC(str string) bool

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

func MD4

func MD4(str string) bool

MD4 is the validation function for validating if the field's value is a valid MD4.

func MD5

func MD5(str string) bool

MD5 is the validation function for validating if the field's value is a valid MD5.

func NotBetween

func NotBetween(val, min, max any) bool

func NotEmpty

func NotEmpty[T any](t T) bool

func NotEqual

func NotEqual(a, b any) bool

func Number

func Number[T any](t T) bool

Number is the validation function for validating if the current field's value is a valid number.

func Numeric

func Numeric[T any](t T) bool

Numeric is the validation function for validating if the current field's value is a valid numeric value.

func OneOf

func OneOf(val any, vals []any) bool

func PhoneNumber

func PhoneNumber(s string) bool

PhoneNumber 判断给出的字符串是否符合中国大陆规范的手机号码

func RGB

func RGB(str string) bool

RGB is the validation function for validating if the current field's value is a valid RGB color.

func RGBA

func RGBA(str string) bool

RGBA is the validation function for validating if the current field's value is a valid RGBA color.

func SHA256

func SHA256(str string) bool

SHA256 is the validation function for validating if the field's value is a valid SHA256.

func SHA384

func SHA384(str string) bool

SHA384 is the validation function for validating if the field's value is a valid SHA384.

func SHA512

func SHA512(str string) bool

SHA512 is the validation function for validating if the field's value is a valid SHA512.

func Semver

func Semver(s string) bool

Semver 判断给出的字符串是否符合语义化版本号规范

func Timezone

func Timezone(str string) bool

Timezone is the validation function for validating if the current field's value is a valid time zone string.

func ULID

func ULID(str string) bool

ULID is the validation function for validating if the field's value is a valid ULID.

func URL

func URL(s string) bool

URL 判断给出的字符串是否为有效的URL

func URLEncoded

func URLEncoded(str string) bool

func UUID

func UUID(str string) bool

UUID is the validation function for validating if the field's value is a valid UUID of any version.

func UUID3

func UUID3(str string) bool

UUID3 is the validation function for validating if the field's value is a valid v3 UUID.

func UUID4

func UUID4(str string) bool

UUID4 is the validation function for validating if the field's value is a valid v4 UUID.

func UUID5

func UUID5(str string) bool

UUID5 is the validation function for validating if the field's value is a valid v5 UUID.

func Uppercase

func Uppercase(str string) bool

Uppercase is the validation function for validating if the current field's value is an uppercase string.

Types

This section is empty.

Jump to

Keyboard shortcuts

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