Documentation ¶
Index ¶
- Variables
- func GetBundle() *i18n.Bundle
- func GetLocalizer() *i18n.Localizer
- func SetLang(tag language.Tag, langs ...string)
- func Validate(values ...Value) error
- type AnyValue
- type Option
- type OrderedValue
- func (c *OrderedValue[T]) Between(a, b T) *OrderedValue[T]
- func (c *OrderedValue[T]) Customize(messageId string, f func(T) bool) *OrderedValue[T]
- func (c *OrderedValue[T]) Err() error
- func (c *OrderedValue[T]) Gt(v T) *OrderedValue[T]
- func (c *OrderedValue[T]) Gte(v T) *OrderedValue[T]
- func (c *OrderedValue[T]) In(args ...T) *OrderedValue[T]
- func (c *OrderedValue[T]) Lt(v T) *OrderedValue[T]
- func (c *OrderedValue[T]) Lte(v T) *OrderedValue[T]
- func (c *OrderedValue[T]) Required() *OrderedValue[T]
- type PointerValue
- type SliceValue
- func (c *SliceValue[T]) Contains(v T) *SliceValue[T]
- func (c *SliceValue[T]) Customize(messageId string, f func([]T) bool) *SliceValue[T]
- func (c *SliceValue[T]) Eq(v int) *SliceValue[T]
- func (c *SliceValue[T]) Err() error
- func (c *SliceValue[T]) Gt(v int) *SliceValue[T]
- func (c *SliceValue[T]) Gte(v int) *SliceValue[T]
- func (c *SliceValue[T]) Lt(v int) *SliceValue[T]
- func (c *SliceValue[T]) Lte(v int) *SliceValue[T]
- func (c *SliceValue[T]) Required() *SliceValue[T]
- type StringValue
- func (c *StringValue[T]) Alphabet() *StringValue[T]
- func (c *StringValue[T]) AlphabetNumeric() *StringValue[T]
- func (c *StringValue[T]) Base64() *StringValue[T]
- func (c *StringValue[T]) Between(a, b T) *StringValue[T]
- func (c *StringValue[T]) Customize(messageId string, f func(T) bool) *StringValue[T]
- func (c *StringValue[T]) Email() *StringValue[T]
- func (c *StringValue[T]) Eq(v int) *StringValue[T]
- func (c *StringValue[T]) Err() error
- func (c *StringValue[T]) Gt(v int) *StringValue[T]
- func (c *StringValue[T]) Gte(v int) *StringValue[T]
- func (c *StringValue[T]) Hex() *StringValue[T]
- func (c *StringValue[T]) IPv4() *StringValue[T]
- func (c *StringValue[T]) IPv6() *StringValue[T]
- func (c *StringValue[T]) In(args ...T) *StringValue[T]
- func (c *StringValue[T]) Lowercase() *StringValue[T]
- func (c *StringValue[T]) Lt(v int) *StringValue[T]
- func (c *StringValue[T]) Lte(v int) *StringValue[T]
- func (c *StringValue[T]) MatchRegexp(re *regexp.Regexp) *StringValue[T]
- func (c *StringValue[T]) MatchString(re string) *StringValue[T]
- func (c *StringValue[T]) Numeric() *StringValue[T]
- func (c *StringValue[T]) Required() *StringValue[T]
- func (c *StringValue[T]) URL() *StringValue[T]
- func (c *StringValue[T]) Uppercase() *StringValue[T]
- type Validator
- type Value
Constants ¶
This section is empty.
Variables ¶
var ( Chinese = language.Make("zh-CN") English = language.Make("en-US") )
Functions ¶
func GetLocalizer ¶
Types ¶
type AnyValue ¶
type AnyValue[T any] struct { // contains filtered or unexported fields }
type Option ¶ added in v0.0.3
type Option func(c *config)
func WithAutoTranslate ¶ added in v0.0.3
WithAutoTranslate automatic translation of key names
type OrderedValue ¶
func (*OrderedValue[T]) Between ¶ added in v0.0.3
func (c *OrderedValue[T]) Between(a, b T) *OrderedValue[T]
Between check that the range of values of the ordered value satisfies a <= x <b
func (*OrderedValue[T]) Customize ¶
func (c *OrderedValue[T]) Customize(messageId string, f func(T) bool) *OrderedValue[T]
Customize customized data validation @layout error message @f check function
func (*OrderedValue[T]) Gt ¶
func (c *OrderedValue[T]) Gt(v T) *OrderedValue[T]
Gt check the ordered value is greater than v
func (*OrderedValue[T]) Gte ¶
func (c *OrderedValue[T]) Gte(v T) *OrderedValue[T]
Gte check the ordered value is greater or equal than v
func (*OrderedValue[T]) In ¶
func (c *OrderedValue[T]) In(args ...T) *OrderedValue[T]
In check if args contains the ordered value.
func (*OrderedValue[T]) Lt ¶
func (c *OrderedValue[T]) Lt(v T) *OrderedValue[T]
Lt check the ordered value is less than v
func (*OrderedValue[T]) Lte ¶
func (c *OrderedValue[T]) Lte(v T) *OrderedValue[T]
Lte check the ordered value is less or equal than v
func (*OrderedValue[T]) Required ¶
func (c *OrderedValue[T]) Required() *OrderedValue[T]
Required the ordered value cannot be empty
type PointerValue ¶
type PointerValue[T any] struct { // contains filtered or unexported fields }
func Pointer ¶
func Pointer[T any](k string, v *T) *PointerValue[T]
func (*PointerValue[T]) Customize ¶
func (c *PointerValue[T]) Customize(messageId string, f func(*T) bool) *PointerValue[T]
func (*PointerValue[T]) Err ¶
func (c *PointerValue[T]) Err() error
func (*PointerValue[T]) Required ¶
func (c *PointerValue[T]) Required() *PointerValue[T]
type SliceValue ¶
func (*SliceValue[T]) Contains ¶
func (c *SliceValue[T]) Contains(v T) *SliceValue[T]
Contains checks whether the slice contains v
func (*SliceValue[T]) Customize ¶
func (c *SliceValue[T]) Customize(messageId string, f func([]T) bool) *SliceValue[T]
func (*SliceValue[T]) Eq ¶
func (c *SliceValue[T]) Eq(v int) *SliceValue[T]
Eq check the slice length is equal to v
func (*SliceValue[T]) Gt ¶
func (c *SliceValue[T]) Gt(v int) *SliceValue[T]
Gt check the slice length is greater than v
func (*SliceValue[T]) Gte ¶
func (c *SliceValue[T]) Gte(v int) *SliceValue[T]
Gte check the slice length is greater or equal than v
func (*SliceValue[T]) Lt ¶
func (c *SliceValue[T]) Lt(v int) *SliceValue[T]
Lt check the slice length is less than v
func (*SliceValue[T]) Lte ¶
func (c *SliceValue[T]) Lte(v int) *SliceValue[T]
Lte check the slice length is less or equal than v
func (*SliceValue[T]) Required ¶
func (c *SliceValue[T]) Required() *SliceValue[T]
Required the slice cannot be empty
type StringValue ¶
type StringValue[T ~string] struct { // contains filtered or unexported fields }
func String ¶
func String[T ~string](k string, v T) *StringValue[T]
func (*StringValue[T]) Alphabet ¶
func (c *StringValue[T]) Alphabet() *StringValue[T]
Alphabet Check if the string consists of letters
func (*StringValue[T]) AlphabetNumeric ¶
func (c *StringValue[T]) AlphabetNumeric() *StringValue[T]
AlphabetNumeric Check the string consists of letters and numbers.
func (*StringValue[T]) Base64 ¶
func (c *StringValue[T]) Base64() *StringValue[T]
Base64 verify that the string is formatted for base64.
func (*StringValue[T]) Between ¶ added in v0.0.3
func (c *StringValue[T]) Between(a, b T) *StringValue[T]
Between check that the range of values of the ordered value satisfies a <= x <b
func (*StringValue[T]) Customize ¶
func (c *StringValue[T]) Customize(messageId string, f func(T) bool) *StringValue[T]
Customize customized data validation @layout error message @f check function
func (*StringValue[T]) Email ¶
func (c *StringValue[T]) Email() *StringValue[T]
Email verify that the string is formatted for email.
func (*StringValue[T]) Eq ¶
func (c *StringValue[T]) Eq(v int) *StringValue[T]
Eq check that the string length is equal to v
func (*StringValue[T]) Gt ¶
func (c *StringValue[T]) Gt(v int) *StringValue[T]
Gt check that the string length is greater than v
func (*StringValue[T]) Gte ¶
func (c *StringValue[T]) Gte(v int) *StringValue[T]
Gte check that the string length is greater or equal than v
func (*StringValue[T]) Hex ¶
func (c *StringValue[T]) Hex() *StringValue[T]
Hex verify that the string is formatted for hex.
func (*StringValue[T]) IPv4 ¶
func (c *StringValue[T]) IPv4() *StringValue[T]
IPv4 verify that the string is formatted for IPv4.
func (*StringValue[T]) IPv6 ¶
func (c *StringValue[T]) IPv6() *StringValue[T]
IPv6 verify that the string is formatted for IPv6.
func (*StringValue[T]) In ¶
func (c *StringValue[T]) In(args ...T) *StringValue[T]
In check if args contains the string.
func (*StringValue[T]) Lowercase ¶
func (c *StringValue[T]) Lowercase() *StringValue[T]
Lowercase verify the string consists of lowercase letters.
func (*StringValue[T]) Lt ¶
func (c *StringValue[T]) Lt(v int) *StringValue[T]
Lt check that the string length is less than v
func (*StringValue[T]) Lte ¶
func (c *StringValue[T]) Lte(v int) *StringValue[T]
Lte check that the string length is less or equal than v
func (*StringValue[T]) MatchRegexp ¶
func (c *StringValue[T]) MatchRegexp(re *regexp.Regexp) *StringValue[T]
MatchRegexp verify that the string matches the regular expression re
func (*StringValue[T]) MatchString ¶
func (c *StringValue[T]) MatchString(re string) *StringValue[T]
MatchString verify that the string matches the regular expression re
func (*StringValue[T]) Numeric ¶
func (c *StringValue[T]) Numeric() *StringValue[T]
Numeric Check if the string consists of numbers
func (*StringValue[T]) Required ¶
func (c *StringValue[T]) Required() *StringValue[T]
Required the string cannot be empty
func (*StringValue[T]) URL ¶
func (c *StringValue[T]) URL() *StringValue[T]
URL verify that the string is formatted for URL.
func (*StringValue[T]) Uppercase ¶
func (c *StringValue[T]) Uppercase() *StringValue[T]
Uppercase verify the string consists of uppercase letters.
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}