Documentation
¶
Index ¶
- func Abort[T any](value T, opts ...Validate[T]) error
- func Collect[T any](value T, opts ...Validate[T]) []error
- func Join[T any](value T, opts ...Validate[T]) error
- func JoinFunc[T any](value T, join func(...error) error, opts ...Validate[T]) error
- type Validate
- func Between[T cmp.Ordered](x, y T) Validate[T]
- func Email() Validate[string]
- func Empty[T comparable]() Validate[T]
- func Equal[T comparable](target T) Validate[T]
- func Max[T cmp.Ordered](maximal T) Validate[T]
- func Min[T cmp.Ordered](minimal T) Validate[T]
- func NotBetween[T cmp.Ordered](x, y T) Validate[T]
- func NotEmpty[T comparable]() Validate[T]
- func NotEqual[T comparable](target T) Validate[T]
- func NotOneIn[T comparable](enum map[T]bool) Validate[T]
- func NotOneOf[T comparable](enum ...T) Validate[T]
- func Nothing[T any]() Validate[T]
- func OneIn[T comparable](enum map[T]bool) Validate[T]
- func OneOf[T comparable](enum ...T) Validate[T]
- func SliceContain[S ~[]E, E comparable](value E) Validate[S]
- func SliceEach[S ~[]E, E any](opts ...Validate[E]) Validate[S]
- func SliceLen[S ~[]E, E any](n int) Validate[S]
- func SliceLenBetween[S ~[]E, E any](x, y int) Validate[S]
- func SliceLenNotBetween[S ~[]E, E any](x, y int) Validate[S]
- func SliceMaxLen[S ~[]E, E any](n int) Validate[S]
- func SliceMinLen[S ~[]E, E any](n int) Validate[S]
- func SliceNotContain[S ~[]E, E comparable](value E) Validate[S]
- func StringAllow(charset string) Validate[string]
- func StringAlpha() Validate[string]
- func StringAlphaNumeric() Validate[string]
- func StringContains(substr string) Validate[string]
- func StringContainsAny(charset string) Validate[string]
- func StringHasPrefix(prefix string) Validate[string]
- func StringHasSuffix(suffix string) Validate[string]
- func StringLen(n int) Validate[string]
- func StringLenBetween(x, y int) Validate[string]
- func StringLenNotBetween(x, y int) Validate[string]
- func StringMaxLen(n int) Validate[string]
- func StringMaxRuneCount(n int) Validate[string]
- func StringMaxUniqueRuneCount(n int) Validate[string]
- func StringMinLen(n int) Validate[string]
- func StringMinRuneCount(n int) Validate[string]
- func StringMinUniqueRuneCount(n int) Validate[string]
- func StringNotAllow(charset string) Validate[string]
- func StringNotContains(substr string) Validate[string]
- func StringNotHasPrefix(prefix string) Validate[string]
- func StringNotHasSuffix(suffix string) Validate[string]
- func StringNumeric() Validate[string]
- func StringPrintableASCII() Validate[string]
- func StringRuneCount(n int) Validate[string]
- func StringRuneCountBetween(x, y int) Validate[string]
- func StringRuneCountNotBetween(x, y int) Validate[string]
- func StringUTF8() Validate[string]
- func StringUnicodeDigits() Validate[string]
- func StringUnicodeLetters() Validate[string]
- func StringUniqueRuneCount(n int) Validate[string]
- func StringUniqueRuneCountBetween(x, y int) Validate[string]
- func StringUniqueRuneCountNotBetween(x, y int) Validate[string]
- func UUID() Validate[string]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Abort ¶
Abort returns the first error when executing the validation functions and aborts the execution.
Types ¶
type Validate ¶
Validate is a generic type for validation functions.
func Between ¶
Between returns a validation function that checks whether the value is between the minimal and maximal values.
func Email ¶ added in v0.0.3
Email returns a validation function that checks whether the string is a valid email address.
func Empty ¶
func Empty[T comparable]() Validate[T]
Empty returns a validation function that checks whether the value is empty.
func Equal ¶
func Equal[T comparable](target T) Validate[T]
Equal returns a validation function that checks whether the value is equal to the target.
func Max ¶
Max returns a validation function that checks whether the value is less or equal than the maximal value.
func Min ¶
Min returns a validation function that checks whether the value is greater or equal than the minimal value.
func NotBetween ¶
NotBetween returns a validation function that checks whether the value is not between the minimal and maximal values.
func NotEmpty ¶
func NotEmpty[T comparable]() Validate[T]
NotEmpty returns a validation function that checks whether the value is not empty.
func NotEqual ¶
func NotEqual[T comparable](target T) Validate[T]
NotEqual returns a validation function that checks whether the value is not equal to the target.
func NotOneIn ¶
func NotOneIn[T comparable](enum map[T]bool) Validate[T]
NotOneIn returns a validation function that checks whether the value does not exist in the enum map keys.
func NotOneOf ¶
func NotOneOf[T comparable](enum ...T) Validate[T]
NotOneOf returns a validation function that checks whether the value does not exist in the enum slice.
func OneIn ¶
func OneIn[T comparable](enum map[T]bool) Validate[T]
OneIn returns a validation function that checks whether the value exists in the enum map keys.
func OneOf ¶
func OneOf[T comparable](enum ...T) Validate[T]
OneOf returns a validation function that checks whether the value exists in the enum slice.
func SliceContain ¶ added in v0.0.3
func SliceContain[S ~[]E, E comparable](value E) Validate[S]
SliceContain returns a validation function that checks whether the slice contains the specified value.
func SliceEach ¶ added in v0.0.3
SliceEach returns a validation function that checks whether each element in the slice satisfies the specified validation functions.
func SliceLen ¶ added in v0.0.3
SliceLen returns a validation function that checks whether the length of the slice is equal to the specified number.
func SliceLenBetween ¶ added in v0.0.3
SliceLenBetween returns a validation function that checks whether the length of the slice is between the specified numbers.
func SliceLenNotBetween ¶ added in v0.0.3
SliceLenNotBetween returns a validation function that checks whether the length of the slice is not between the specified numbers.
func SliceMaxLen ¶ added in v0.0.3
SliceMaxLen returns a validation function that checks whether the length of the slice is at most the specified number.
func SliceMinLen ¶ added in v0.0.3
SliceMinLen returns a validation function that checks whether the length of the slice is at least the specified number.
func SliceNotContain ¶ added in v0.0.3
func SliceNotContain[S ~[]E, E comparable](value E) Validate[S]
SliceNotContain returns a validation function that checks whether the slice does not contain the specified value.
func StringAllow ¶ added in v0.0.3
StringAllow returns a validation function that checks whether the string contains only allowed characters.
func StringAlpha ¶ added in v0.0.3
StringAlpha returns a validation function that checks whether the string contains only alphabet characters.
func StringAlphaNumeric ¶ added in v0.0.3
StringAlphaNumeric returns a validation function that checks whether the string contains only alphanumeric characters.
func StringContains ¶ added in v0.0.3
StringContains returns a validation function that checks whether the string contains the specified substring.
func StringContainsAny ¶ added in v0.0.3
func StringHasPrefix ¶ added in v0.0.3
StringHasPrefix returns a validation function that checks whether the string begins with prefix.
func StringHasSuffix ¶ added in v0.0.3
StringHasSuffix returns a validation function that checks whether the string ends with suffix.
func StringLen ¶ added in v0.0.3
StringLen returns a validation function that checks whether the length of the string is equal to the specified number.
func StringLenBetween ¶ added in v0.0.3
StringLenBetween returns a validation function that checks whether the length of the string is between the specified number.
func StringLenNotBetween ¶ added in v0.0.3
StringLenNotBetween returns a validation function that checks whether the length of the string is not between the specified number.
func StringMaxLen ¶ added in v0.0.3
StringMaxLen returns a validation function that checks whether the length of the string is at most the specified number.
func StringMaxRuneCount ¶ added in v0.0.3
StringMaxRuneCount returns a validation function that checks whether the number of runes in the string is at most the specified number.
func StringMaxUniqueRuneCount ¶ added in v0.0.3
StringMaxUniqueRuneCount returns a validation function that checks whether the number of unique runes in the string is at most the specified number.
func StringMinLen ¶ added in v0.0.3
StringMinLen returns a validation function that checks whether the length of the string is at least the specified number.
func StringMinRuneCount ¶ added in v0.0.3
StringMinRuneCount returns a validation function that checks whether the number of runes in the string is at least the specified number.
func StringMinUniqueRuneCount ¶ added in v0.0.3
StringMinUniqueRuneCount returns a validation function that checks whether the number of unique runes in the string is at least the specified number.
func StringNotAllow ¶ added in v0.0.3
StringNotAllow returns a validation function that checks whether the string does not contain disallowed characters.
func StringNotContains ¶ added in v0.0.3
StringNotContains returns a validation function that checks whether the string does not contain the specified substring.
func StringNotHasPrefix ¶ added in v0.0.3
StringNotHasPrefix returns a validation function that checks whether the string does not begin with prefix.
func StringNotHasSuffix ¶ added in v0.0.3
StringNotHasSuffix returns a validation function that checks whether the string does not end with suffix.
func StringNumeric ¶ added in v0.0.3
StringNumeric returns a validation function that checks whether the string contains only numeric characters.
func StringPrintableASCII ¶ added in v0.0.5
StringASCII returns a validation function that checks whether the string contains only ASCII printable characters.
func StringRuneCount ¶ added in v0.0.3
StringRuneCount returns a validation function that checks whether the number of runes in the string is exactly equal to the specified number.
func StringRuneCountBetween ¶ added in v0.0.3
StringRuneCountBetween returns a validation function that checks whether the number of runes in the string is between the specified numbers.
func StringRuneCountNotBetween ¶ added in v0.0.3
StringRuneCountNotBetween returns a validation function that checks whether the number of runes in the string is not between the specified numbers.
func StringUTF8 ¶ added in v0.0.3
StringUTF8 returns a validation function that checks whether the string is a valid UTF-8 string.
func StringUnicodeDigits ¶ added in v0.0.3
StringUnicodeDigits returns a validation function that checks whether the string contains only unicode digits.
func StringUnicodeLetters ¶ added in v0.0.3
StringUnicodeLetters returns a validation function that checks whether the string contains only unicode letters.
func StringUniqueRuneCount ¶ added in v0.0.3
StringUniqueRuneCount returns a validation function that checks whether the number of unique runes in the string is exactly equal to the specified number.
func StringUniqueRuneCountBetween ¶ added in v0.0.3
StringUniqueRuneCountBetween returns a validation function that checks whether the number of unique runes in the string is between the specified numbers.
func StringUniqueRuneCountNotBetween ¶ added in v0.0.3
StringUniqueRuneCountNotBetween returns a validation function that checks whether the number of unique runes in the string is not between the specified numbers.