Documentation
¶
Index ¶
- Variables
- func CmpNotEqCheck[T comparable](v T, ne T, customErrMsg ...string) error
- func CmpNotEqMust[T comparable](v T, ne T, customErrMsg ...string)
- func CmpNotEqMustGet[T comparable](v T, ne T, customErrMsg ...string) T
- func FalseCheck(v bool, customErrMsg ...string) error
- func FalseMust(v bool, customErrMsg ...string)
- func NotNilDeepCheck(v any, customErrMsg ...string) error
- func NotNilDeepMust(v any, customErrMsg ...string)
- func NotNilDeepMustGet[T any](v T, customErrMsg ...string) T
- func NotZeroCheck(v any, customErrMsg ...string) error
- func NotZeroMust(v any, customErrMsg ...string)
- func NotZeroMustGet[T any](v T, customErrMsg ...string) T
- func StrNotEmptyCheck(v string, customErrMsg ...string) error
- func StrNotEmptyMust(v string, customErrMsg ...string)
- func StrNotEmptyMustGet(v string, customErrMsg ...string) string
- func TrueCheck(v bool, customErrMsg ...string) error
- func TrueMust(v bool, customErrMsg ...string)
- type AAny
- func (a AAny) Check(v T, customErrMsg ...string) error
- func (a AAny) CheckAll(v T) []error
- func (m AAny) Custom(check func(v T) error) A
- func (a AAny) Must(v T, customErrMsg ...string)
- func (a AAny) MustAll(v T)
- func (a AAny) MustAllGet(v T) T
- func (a AAny) MustGet(v T, customErrMsg ...string) T
- func (a *AAny[T]) NotNilDeep(customErrMsg ...string) *AAny[T]
- func (a *AAny[T]) NotZero(customErrMsg ...string) *AAny[T]
- type ABool
- func (a ABool) Check(v T, customErrMsg ...string) error
- func (a ABool) CheckAll(v T) []error
- func (m ABool) Custom(check func(v T) error) A
- func (m ABool) Eq(eq T, customErrMsg ...string) A
- func (a *ABool) False(customErrMsg ...string) *ABool
- func (m ABool) In(slice []T, customErrMsg ...string) A
- func (a ABool) Must(v T, customErrMsg ...string)
- func (a ABool) MustAll(v T)
- func (a ABool) MustAllGet(v T) T
- func (a ABool) MustGet(v T, customErrMsg ...string) T
- func (m ABool) NotEq(notEq T, customErrMsg ...string) A
- func (m ABool) NotIn(slice []T, customErrMsg ...string) A
- func (a *ABool) True(customErrMsg ...string) *ABool
- type AComparable
- func (a AComparable) Check(v T, customErrMsg ...string) error
- func (a AComparable) CheckAll(v T) []error
- func (m AComparable) Custom(check func(v T) error) A
- func (m AComparable) Eq(eq T, customErrMsg ...string) A
- func (m AComparable) In(slice []T, customErrMsg ...string) A
- func (a AComparable) Must(v T, customErrMsg ...string)
- func (a AComparable) MustAll(v T)
- func (a AComparable) MustAllGet(v T) T
- func (a AComparable) MustGet(v T, customErrMsg ...string) T
- func (m AComparable) NotEq(notEq T, customErrMsg ...string) A
- func (m AComparable) NotIn(slice []T, customErrMsg ...string) A
- type ANumeric
- func (a ANumeric) Check(v T, customErrMsg ...string) error
- func (a ANumeric) CheckAll(v T) []error
- func (m ANumeric) Custom(check func(v T) error) A
- func (m ANumeric) Eq(eq T, customErrMsg ...string) A
- func (m ANumeric) Greater(than T, customErrMsg ...string) A
- func (m ANumeric) GreaterAny(elems []T, customErrMsg ...string) A
- func (m ANumeric) GreaterEach(elems []T, customErrMsg ...string) A
- func (m ANumeric) GreaterEq(than T, customErrMsg ...string) A
- func (m ANumeric) GreaterEqAny(elems []T, customErrMsg ...string) A
- func (m ANumeric) GreaterEqEach(elems []T, customErrMsg ...string) A
- func (m ANumeric) In(slice []T, customErrMsg ...string) A
- func (m ANumeric) InRange(min T, max T, customErrMsg ...string) A
- func (m ANumeric) Less(than T, customErrMsg ...string) A
- func (m ANumeric) LessAny(elems []T, customErrMsg ...string) A
- func (m ANumeric) LessEach(elems []T, customErrMsg ...string) A
- func (m ANumeric) LessEq(than T, customErrMsg ...string) A
- func (m ANumeric) LessEqAny(elems []T, customErrMsg ...string) A
- func (m ANumeric) LessEqEach(elems []T, customErrMsg ...string) A
- func (a ANumeric) Must(v T, customErrMsg ...string)
- func (a ANumeric) MustAll(v T)
- func (a ANumeric) MustAllGet(v T) T
- func (a ANumeric) MustGet(v T, customErrMsg ...string) T
- func (a *ANumeric[T]) Negative(customErrMsg ...string) *ANumeric[T]
- func (m ANumeric) NotEq(notEq T, customErrMsg ...string) A
- func (m ANumeric) NotIn(slice []T, customErrMsg ...string) A
- func (m ANumeric) NotInRange(min T, max T, customErrMsg ...string) A
- func (a *ANumeric[T]) NotZero(customErrMsg ...string) *ANumeric[T]
- func (a *ANumeric[T]) Positive(customErrMsg ...string) *ANumeric[T]
- func (a *ANumeric[T]) Zero(customErrMsg ...string) *ANumeric[T]
- type ASliceAny
- func (a ASliceAny) Check(v T, customErrMsg ...string) error
- func (a ASliceAny) CheckAll(v T) []error
- func (m ASliceAny) Custom(check func(v T) error) A
- func (m ASliceAny) CustomElementAny(conditionName string, conditionFn func(e E) bool, customErrMsg ...string) A
- func (m ASliceAny) CustomElementEach(conditionName string, conditionFn func(e E) bool, customErrMsg ...string) A
- func (m ASliceAny) CustomElementNone(conditionName string, conditionFn func(e E) bool, customErrMsg ...string) A
- func (m ASliceAny) Empty(customErrMsg ...string) A
- func (a ASliceAny) Must(v T, customErrMsg ...string)
- func (a ASliceAny) MustAll(v T)
- func (a ASliceAny) MustAllGet(v T) T
- func (a ASliceAny) MustGet(v T, customErrMsg ...string) T
- func (m ASliceAny) NotEmpty(customErrMsg ...string) A
- type ASliceCmp
- func (a ASliceCmp) Check(v T, customErrMsg ...string) error
- func (a ASliceCmp) CheckAll(v T) []error
- func (m ASliceCmp) Contains(e E, customErrMsg ...string) A
- func (m ASliceCmp) ContainsAny(s S, customErrMsg ...string) A
- func (m ASliceCmp) ContainsEach(s S, customErrMsg ...string) A
- func (m ASliceCmp) ContainsNone(s S, customErrMsg ...string) A
- func (m ASliceCmp) Custom(check func(v T) error) A
- func (a ASliceCmp) Must(v T, customErrMsg ...string)
- func (a ASliceCmp) MustAll(v T)
- func (a ASliceCmp) MustAllGet(v T) T
- func (a ASliceCmp) MustGet(v T, customErrMsg ...string) T
- func (m ASliceCmp) NotContains(e E, customErrMsg ...string) A
- func (m ASliceCmp) Uniques(customErrMsg ...string) A
- func (m ASliceCmp) UniquesLenEq(eq int, customErrMsg ...string) A
- func (m ASliceCmp) UniquesLenInRange(min, max int, customErrMsg ...string) A
- func (m ASliceCmp) UniquesLenMax(max int, customErrMsg ...string) A
- func (m ASliceCmp) UniquesLenMin(min int, customErrMsg ...string) A
- func (m ASliceCmp) UniquesLenNotEq(notEq int, customErrMsg ...string) A
- func (m ASliceCmp) UniquesLenNotInRange(min, max int, customErrMsg ...string) A
- type AString
- func Str() *AString
- func String() *AStringdeprecated
- func (a AString) Check(v T, customErrMsg ...string) error
- func (a AString) CheckAll(v T) []error
- func (a *AString) ContainsStr(s string, customErrMsg ...string) *AString
- func (a *AString) ContainsStrAny(ss []string, customErrMsg ...string) *AString
- func (a *AString) ContainsStrEach(ss []string, customErrMsg ...string) *AString
- func (a *AString) ContainsStrNone(ss []string, customErrMsg ...string) *AString
- func (m AString) Custom(check func(v T) error) A
- func (a *AString) Empty(customErrMsg ...string) *AString
- func (m AString) Eq(eq T, customErrMsg ...string) A
- func (m AString) In(slice []T, customErrMsg ...string) A
- func (m AString) LenEq(eq int, customErrMsg ...string) A
- func (m AString) LenInRange(min, max int, customErrMsg ...string) A
- func (m AString) LenMax(max int, customErrMsg ...string) A
- func (m AString) LenMin(min int, customErrMsg ...string) A
- func (m AString) LenNotEq(notEq int, customErrMsg ...string) A
- func (m AString) LenNotInRange(min, max int, customErrMsg ...string) A
- func (a AString) Must(v T, customErrMsg ...string)
- func (a AString) MustAll(v T)
- func (a AString) MustAllGet(v T) T
- func (a AString) MustGet(v T, customErrMsg ...string) T
- func (a *AString) NotContainsStr(s string, customErrMsg ...string) *AString
- func (a *AString) NotEmpty(customErrMsg ...string) *AString
- func (m AString) NotEq(notEq T, customErrMsg ...string) A
- func (m AString) NotIn(slice []T, customErrMsg ...string) A
- func (a *AString) Numeric(customErrMsg ...string) *AString
- func (a *AString) PrefixEq(eq string, customErrMsg ...string) *AString
- func (a *AString) PrefixIn(in []string, customErrMsg ...string) *AString
- func (a *AString) PrefixNotEq(notEq string, customErrMsg ...string) *AString
- func (a *AString) PrefixNotIn(notIn []string, customErrMsg ...string) *AString
- func (a *AString) Regexp(r *regexp.Regexp, customErrMsg ...string) *AString
- func (a *AString) RunesEq(eq int, customErrMsg ...string) *AString
- func (a *AString) RunesInRange(min, max int, customErrMsg ...string) *AString
- func (a *AString) RunesMax(max int, customErrMsg ...string) *AString
- func (a *AString) RunesMin(min int, customErrMsg ...string) *AString
- func (a *AString) RunesNotEq(notEq int, customErrMsg ...string) *AString
- func (a *AString) RunesNotInRange(min, max int, customErrMsg ...string) *AString
- func (a *AString) SuffixEq(eq string, customErrMsg ...string) *AString
- func (a *AString) SuffixIn(in []string, customErrMsg ...string) *AString
- func (a *AString) SuffixNotEq(notEq string, customErrMsg ...string) *AString
- func (a *AString) SuffixNotIn(notIn []string, customErrMsg ...string) *AString
- func (a *AString) Word(customErrMsg ...string) *AString
- func (a *AString) Words(customErrMsg ...string) *AString
- type ATime
- func (a ATime) Check(v T, customErrMsg ...string) error
- func (a ATime) CheckAll(v T) []error
- func (m ATime) Custom(check func(v T) error) A
- func (m ATime) Eq(eq T, customErrMsg ...string) A
- func (m ATime) Greater(than T, customErrMsg ...string) A
- func (m ATime) GreaterAny(elems []T, customErrMsg ...string) A
- func (m ATime) GreaterEach(elems []T, customErrMsg ...string) A
- func (m ATime) GreaterEq(than T, customErrMsg ...string) A
- func (m ATime) GreaterEqAny(elems []T, customErrMsg ...string) A
- func (m ATime) GreaterEqEach(elems []T, customErrMsg ...string) A
- func (m ATime) In(slice []T, customErrMsg ...string) A
- func (m ATime) InRange(min T, max T, customErrMsg ...string) A
- func (m ATime) Less(than T, customErrMsg ...string) A
- func (m ATime) LessAny(elems []T, customErrMsg ...string) A
- func (m ATime) LessEach(elems []T, customErrMsg ...string) A
- func (m ATime) LessEq(than T, customErrMsg ...string) A
- func (m ATime) LessEqAny(elems []T, customErrMsg ...string) A
- func (m ATime) LessEqEach(elems []T, customErrMsg ...string) A
- func (a ATime) Must(v T, customErrMsg ...string)
- func (a ATime) MustAll(v T)
- func (a ATime) MustAllGet(v T) T
- func (a ATime) MustGet(v T, customErrMsg ...string) T
- func (m ATime) NotEq(notEq T, customErrMsg ...string) A
- func (m ATime) NotIn(slice []T, customErrMsg ...string) A
- func (m ATime) NotInRange(min T, max T, customErrMsg ...string) A
- func (a *ATime) NotZero(customErrMsg ...string) *ATime
- func (a *ATime) Zero(customErrMsg ...string) *ATime
- type ATimeDuration
- func (a ATimeDuration) Check(v T, customErrMsg ...string) error
- func (a ATimeDuration) CheckAll(v T) []error
- func (m ATimeDuration) Custom(check func(v T) error) A
- func (m ATimeDuration) Eq(eq T, customErrMsg ...string) A
- func (m ATimeDuration) Greater(than T, customErrMsg ...string) A
- func (m ATimeDuration) GreaterAny(elems []T, customErrMsg ...string) A
- func (m ATimeDuration) GreaterEach(elems []T, customErrMsg ...string) A
- func (m ATimeDuration) GreaterEq(than T, customErrMsg ...string) A
- func (m ATimeDuration) GreaterEqAny(elems []T, customErrMsg ...string) A
- func (m ATimeDuration) GreaterEqEach(elems []T, customErrMsg ...string) A
- func (m ATimeDuration) In(slice []T, customErrMsg ...string) A
- func (m ATimeDuration) InRange(min T, max T, customErrMsg ...string) A
- func (m ATimeDuration) Less(than T, customErrMsg ...string) A
- func (m ATimeDuration) LessAny(elems []T, customErrMsg ...string) A
- func (m ATimeDuration) LessEach(elems []T, customErrMsg ...string) A
- func (m ATimeDuration) LessEq(than T, customErrMsg ...string) A
- func (m ATimeDuration) LessEqAny(elems []T, customErrMsg ...string) A
- func (m ATimeDuration) LessEqEach(elems []T, customErrMsg ...string) A
- func (a ATimeDuration) Must(v T, customErrMsg ...string)
- func (a ATimeDuration) MustAll(v T)
- func (a ATimeDuration) MustAllGet(v T) T
- func (a ATimeDuration) MustGet(v T, customErrMsg ...string) T
- func (m ATimeDuration) NotEq(notEq T, customErrMsg ...string) A
- func (m ATimeDuration) NotIn(slice []T, customErrMsg ...string) A
- func (m ATimeDuration) NotInRange(min T, max T, customErrMsg ...string) A
- func (a *ATimeDuration) NotZero(customErrMsg ...string) *ATimeDuration
- func (a *ATimeDuration) Zero(customErrMsg ...string) *ATimeDuration
- type Nilable
- type NumericTypes
- type Zeroable
Constants ¶
This section is empty.
Variables ¶
var StringRegexpNumeric = regexp.MustCompile("^-?\\d+(\\.\\d+)?$")
StringRegexpNumeric
Public variable to allow re-define globally.
var StringRegexpWord = regexp.MustCompile("^[A-Za-z](-?[A-Za-z]+)*$")
StringRegexpWord
Public variable to allow re-define globally.
var StringRegexpWords = regexp.MustCompile("^([A-Za-z](-?[A-Za-z]+)*)([ ]?([A-Za-z](-?[A-Za-z]+)*))+$")
StringRegexpWords
Public variable to allow re-define globally.
Functions ¶
func CmpNotEqCheck ¶ added in v0.4.0
func CmpNotEqCheck[T comparable](v T, ne T, customErrMsg ...string) error
CmpNotEqCheck -- see AComparable[T].NotEq()
func CmpNotEqMust ¶ added in v0.4.0
func CmpNotEqMust[T comparable](v T, ne T, customErrMsg ...string)
CmpNotEqMust -- see AComparable[T].NotEq()
func CmpNotEqMustGet ¶ added in v0.4.0
func CmpNotEqMustGet[T comparable](v T, ne T, customErrMsg ...string) T
CmpNotEqMustGet -- see AComparable[T].NotEq()
func FalseCheck ¶ added in v0.3.0
FalseCheck -- see ABool.False()
func NotNilDeepCheck ¶ added in v0.3.0
NotNilDeepCheck -- see AAny.NotNilDeep()
func NotNilDeepMust ¶ added in v0.3.0
NotNilDeepMust -- see AAny.NotNilDeep()
func NotNilDeepMustGet ¶ added in v0.3.0
NotNilDeepMustGet -- see AAny.NotNilDeep()
func NotZeroCheck ¶ added in v0.3.0
NotZeroCheck -- see AAny.NotZero()
func NotZeroMust ¶ added in v0.3.0
NotZeroMust -- see AAny.NotZero()
func NotZeroMustGet ¶ added in v0.3.0
NotZeroMustGet -- see AAny.NotZero()
func StrNotEmptyCheck ¶ added in v0.4.0
StrNotEmptyCheck -- see AString.NotEmpty()
func StrNotEmptyMust ¶ added in v0.4.0
StrNotEmptyMust -- see AString.NotEmpty()
func StrNotEmptyMustGet ¶ added in v0.4.0
StrNotEmptyMustGet -- see AString.NotEmpty()
Types ¶
type AAny ¶ added in v0.3.0
type AAny[T any] struct { // contains filtered or unexported fields }
func (AAny) Check ¶ added in v0.3.0
Check
Runs registered validation checks one by one against the given value and returns an error from a first failed check. Returns nil, if all checks pass.
func (AAny) CheckAll ¶ added in v0.3.0
func (a AAny) CheckAll(v T) []error
CheckAll
Runs registered validation checks one by one against the given value and returns errors from all failed checks. Returns empty slice, if all checks pass.
func (AAny) Must ¶ added in v0.3.0
func (a AAny) Must(v T, customErrMsg ...string)
Must
Calls Check and panics with the error if validation fails.
func (AAny) MustAll ¶ added in v0.3.0
func (a AAny) MustAll(v T)
MustAll
Calls CheckAll and panics with the error slice if validation fails.
func (AAny) MustAllGet ¶ added in v0.3.0
func (a AAny) MustAllGet(v T) T
MustAllGet
Works same as MustAll, but returns the value, if no panic occurred.
func (AAny) MustGet ¶ added in v0.3.0
func (a AAny) MustGet(v T, customErrMsg ...string) T
MustGet
Works same as Must, but returns the value, if no panic occurred.
func (*AAny[T]) NotNilDeep ¶ added in v0.3.0
NotNilDeep
ATTENTION! THIS IS NOT THE SAME AS `v != nil`.
For non-nil types, the check succeeds because values of these types are never `nil`.
For nil types except pointers and interfaces, the check is analogous to Go's default behavior `v != nil`.
For Nilable-types check fails, when Nilable.IsNil() returns `true`.
For pointers and interfaces, the check runs recursively -- for example, for `interface|(*int)(nil)` it fails.
type ABool ¶
type ABool struct {
// contains filtered or unexported fields
}
func (ABool) Check ¶
Check
Runs registered validation checks one by one against the given value and returns an error from a first failed check. Returns nil, if all checks pass.
func (ABool) CheckAll ¶
func (a ABool) CheckAll(v T) []error
CheckAll
Runs registered validation checks one by one against the given value and returns errors from all failed checks. Returns empty slice, if all checks pass.
func (ABool) Eq ¶
func (m ABool) Eq(eq T, customErrMsg ...string) A
Eq
Value expects to be equal to "eq".
func (ABool) In ¶
func (m ABool) In(slice []T, customErrMsg ...string) A
In
Value expects to be equal to any of the provided elements.
Fails check, if no elements provided.
func (ABool) Must ¶
func (a ABool) Must(v T, customErrMsg ...string)
Must
Calls Check and panics with the error if validation fails.
func (ABool) MustAll ¶
func (a ABool) MustAll(v T)
MustAll
Calls CheckAll and panics with the error slice if validation fails.
func (ABool) MustAllGet ¶ added in v0.3.0
func (a ABool) MustAllGet(v T) T
MustAllGet
Works same as MustAll, but returns the value, if no panic occurred.
func (ABool) MustGet ¶ added in v0.3.0
func (a ABool) MustGet(v T, customErrMsg ...string) T
MustGet
Works same as Must, but returns the value, if no panic occurred.
func (ABool) NotEq ¶
func (m ABool) NotEq(notEq T, customErrMsg ...string) A
NotEq
Value expects to be not equal to "notEq".
type AComparable ¶
type AComparable[T comparable] struct { // contains filtered or unexported fields }
func Cmp ¶ added in v0.3.0
func Cmp[T comparable]() *AComparable[T]
func Comparable
deprecated
func (AComparable) Check ¶
Check
Runs registered validation checks one by one against the given value and returns an error from a first failed check. Returns nil, if all checks pass.
func (AComparable) CheckAll ¶
func (a AComparable) CheckAll(v T) []error
CheckAll
Runs registered validation checks one by one against the given value and returns errors from all failed checks. Returns empty slice, if all checks pass.
func (AComparable) Eq ¶
func (m AComparable) Eq(eq T, customErrMsg ...string) A
Eq
Value expects to be equal to "eq".
func (AComparable) In ¶
func (m AComparable) In(slice []T, customErrMsg ...string) A
In
Value expects to be equal to any of the provided elements.
Fails check, if no elements provided.
func (AComparable) Must ¶
func (a AComparable) Must(v T, customErrMsg ...string)
Must
Calls Check and panics with the error if validation fails.
func (AComparable) MustAll ¶
func (a AComparable) MustAll(v T)
MustAll
Calls CheckAll and panics with the error slice if validation fails.
func (AComparable) MustAllGet ¶ added in v0.3.0
func (a AComparable) MustAllGet(v T) T
MustAllGet
Works same as MustAll, but returns the value, if no panic occurred.
func (AComparable) MustGet ¶ added in v0.3.0
func (a AComparable) MustGet(v T, customErrMsg ...string) T
MustGet
Works same as Must, but returns the value, if no panic occurred.
type ANumeric ¶
type ANumeric[T NumericTypes] struct { // contains filtered or unexported fields }
func Num ¶ added in v0.3.0
func Num[T NumericTypes]() *ANumeric[T]
func Numeric
deprecated
func (ANumeric) Check ¶
Check
Runs registered validation checks one by one against the given value and returns an error from a first failed check. Returns nil, if all checks pass.
func (ANumeric) CheckAll ¶
func (a ANumeric) CheckAll(v T) []error
CheckAll
Runs registered validation checks one by one against the given value and returns errors from all failed checks. Returns empty slice, if all checks pass.
func (ANumeric) Eq ¶
func (m ANumeric) Eq(eq T, customErrMsg ...string) A
Eq
Value expects to be equal to "eq".
func (ANumeric) Greater ¶
func (m ANumeric) Greater(than T, customErrMsg ...string) A
Greater
Value expects to be greater than "than".
func (ANumeric) GreaterAny ¶
func (m ANumeric) GreaterAny(elems []T, customErrMsg ...string) A
GreaterAny
Value expects to be greater than any of provided elements.
Passes check, if no elements provided.
func (ANumeric) GreaterEach ¶
func (m ANumeric) GreaterEach(elems []T, customErrMsg ...string) A
GreaterEach
Value expects to be greater than each of provided elements.
Passes check, if no elements provided.
func (ANumeric) GreaterEq ¶
func (m ANumeric) GreaterEq(than T, customErrMsg ...string) A
GreaterEq
Value expects to be greater or equal to "than".
func (ANumeric) GreaterEqAny ¶
func (m ANumeric) GreaterEqAny(elems []T, customErrMsg ...string) A
GreaterEqAny
Value expects to be greater or equal to any of provided elements.
Passes check, if no elements provided.
func (ANumeric) GreaterEqEach ¶
func (m ANumeric) GreaterEqEach(elems []T, customErrMsg ...string) A
GreaterEqEach
Value expects to be greater or equal to each of provided elements.
Passes check, if no elements provided.
func (ANumeric) In ¶
func (m ANumeric) In(slice []T, customErrMsg ...string) A
In
Value expects to be equal to any of the provided elements.
Fails check, if no elements provided.
func (ANumeric) InRange ¶
func (m ANumeric) InRange(min T, max T, customErrMsg ...string) A
InRange
Value expects to be in range [min, max].
Fails check, if min > max -- it works like empty range.
func (ANumeric) Less ¶
func (m ANumeric) Less(than T, customErrMsg ...string) A
Less
Value expects to be less than "than".
func (ANumeric) LessAny ¶
func (m ANumeric) LessAny(elems []T, customErrMsg ...string) A
LessAny
Value expects to be less than any of provided elements.
Passes check, if no elements provided.
func (ANumeric) LessEach ¶
func (m ANumeric) LessEach(elems []T, customErrMsg ...string) A
LessEach
Value expects to be less than each of provided elements.
Passes check, if no elements provided.
func (ANumeric) LessEq ¶
func (m ANumeric) LessEq(than T, customErrMsg ...string) A
LessEq
Value expects to be less or equal to "than".
func (ANumeric) LessEqAny ¶
func (m ANumeric) LessEqAny(elems []T, customErrMsg ...string) A
LessEqAny
Value expects to be less or equal to any of provided elements.
Passes check, if no elements provided.
func (ANumeric) LessEqEach ¶
func (m ANumeric) LessEqEach(elems []T, customErrMsg ...string) A
LessEqEach
Value expects to be less or equal to each of provided elements.
Passes check, if no elements provided.
func (ANumeric) Must ¶
func (a ANumeric) Must(v T, customErrMsg ...string)
Must
Calls Check and panics with the error if validation fails.
func (ANumeric) MustAll ¶
func (a ANumeric) MustAll(v T)
MustAll
Calls CheckAll and panics with the error slice if validation fails.
func (ANumeric) MustAllGet ¶ added in v0.3.0
func (a ANumeric) MustAllGet(v T) T
MustAllGet
Works same as MustAll, but returns the value, if no panic occurred.
func (ANumeric) MustGet ¶ added in v0.3.0
func (a ANumeric) MustGet(v T, customErrMsg ...string) T
MustGet
Works same as Must, but returns the value, if no panic occurred.
func (ANumeric) NotEq ¶
func (m ANumeric) NotEq(notEq T, customErrMsg ...string) A
NotEq
Value expects to be not equal to "notEq".
func (ANumeric) NotIn ¶
func (m ANumeric) NotIn(slice []T, customErrMsg ...string) A
NotIn
Value expects to be not equal to each of the provided elements.
Passes check, if no elements provided.
func (ANumeric) NotInRange ¶
func (m ANumeric) NotInRange(min T, max T, customErrMsg ...string) A
NotInRange
Value expects to be not in range [min, max] -- i.e. to be in ranges [PossibleMin, min) or (max, PossibleMax]
Passes check, if min > max -- it works like empty range.
type ASliceAny ¶ added in v0.2.0
type ASliceAny[S sliceType[E], E any] struct { // contains filtered or unexported fields }
func (ASliceAny) Check ¶ added in v0.2.0
Check
Runs registered validation checks one by one against the given value and returns an error from a first failed check. Returns nil, if all checks pass.
func (ASliceAny) CheckAll ¶ added in v0.2.0
func (a ASliceAny) CheckAll(v T) []error
CheckAll
Runs registered validation checks one by one against the given value and returns errors from all failed checks. Returns empty slice, if all checks pass.
func (ASliceAny) CustomElementAny ¶ added in v0.2.0
func (m ASliceAny) CustomElementAny( conditionName string, conditionFn func(e E) bool, customErrMsg ...string, ) A
CustomElementAny
Expects the slice with any element matched to custom condition.
Passes check, if the slice is empty. If it confuses, just add the NotEmpty() rule to the chain.
func (ASliceAny) CustomElementEach ¶ added in v0.2.0
func (m ASliceAny) CustomElementEach( conditionName string, conditionFn func(e E) bool, customErrMsg ...string, ) A
CustomElementEach
Expects the slice with each element matched to custom condition.
Passes check, if the slice is empty. If it confuses, just add the NotEmpty() rule to the chain.
func (ASliceAny) CustomElementNone ¶ added in v0.2.0
func (m ASliceAny) CustomElementNone( conditionName string, conditionFn func(e E) bool, customErrMsg ...string, ) A
CustomElementNone
Expects the slice with none element matched to custom condition.
Passes check, if the slice is empty. If it confuses, just add the NotEmpty() rule to the chain.
func (ASliceAny) Must ¶ added in v0.2.0
func (a ASliceAny) Must(v T, customErrMsg ...string)
Must
Calls Check and panics with the error if validation fails.
func (ASliceAny) MustAll ¶ added in v0.2.0
func (a ASliceAny) MustAll(v T)
MustAll
Calls CheckAll and panics with the error slice if validation fails.
func (ASliceAny) MustAllGet ¶ added in v0.3.0
func (a ASliceAny) MustAllGet(v T) T
MustAllGet
Works same as MustAll, but returns the value, if no panic occurred.
type ASliceCmp ¶ added in v0.2.0
type ASliceCmp[S sliceType[E], E comparable] struct { // contains filtered or unexported fields }
func SliceCmp ¶ added in v0.2.0
func SliceCmp[S sliceType[E], E comparable]() *ASliceCmp[S, E]
func (ASliceCmp) Check ¶ added in v0.2.0
Check
Runs registered validation checks one by one against the given value and returns an error from a first failed check. Returns nil, if all checks pass.
func (ASliceCmp) CheckAll ¶ added in v0.2.0
func (a ASliceCmp) CheckAll(v T) []error
CheckAll
Runs registered validation checks one by one against the given value and returns errors from all failed checks. Returns empty slice, if all checks pass.
func (ASliceCmp) Contains ¶ added in v0.2.0
func (m ASliceCmp) Contains(e E, customErrMsg ...string) A
func (ASliceCmp) ContainsAny ¶ added in v0.2.0
func (m ASliceCmp) ContainsAny(s S, customErrMsg ...string) A
func (ASliceCmp) ContainsEach ¶ added in v0.2.0
func (m ASliceCmp) ContainsEach(s S, customErrMsg ...string) A
func (ASliceCmp) ContainsNone ¶ added in v0.2.0
func (m ASliceCmp) ContainsNone(s S, customErrMsg ...string) A
func (ASliceCmp) Must ¶ added in v0.2.0
func (a ASliceCmp) Must(v T, customErrMsg ...string)
Must
Calls Check and panics with the error if validation fails.
func (ASliceCmp) MustAll ¶ added in v0.2.0
func (a ASliceCmp) MustAll(v T)
MustAll
Calls CheckAll and panics with the error slice if validation fails.
func (ASliceCmp) MustAllGet ¶ added in v0.3.0
func (a ASliceCmp) MustAllGet(v T) T
MustAllGet
Works same as MustAll, but returns the value, if no panic occurred.
func (ASliceCmp) MustGet ¶ added in v0.3.0
func (a ASliceCmp) MustGet(v T, customErrMsg ...string) T
MustGet
Works same as Must, but returns the value, if no panic occurred.
func (ASliceCmp) NotContains ¶ added in v0.2.0
func (m ASliceCmp) NotContains(e E, customErrMsg ...string) A
func (ASliceCmp) Uniques ¶ added in v0.2.0
func (m ASliceCmp) Uniques(customErrMsg ...string) A
Uniques
Expects the slice to have no duplicated elements -- i.e. expects that all elements of the slice are unique.
Passes check, if the slice is empty. If it confuses, just add the NotEmpty() rule to the chain.
func (ASliceCmp) UniquesLenEq ¶ added in v0.2.0
UniquesLenEq
Length of unique elements sub-slice expects to be equal to "eq".
Logically incorrect params (e.g. negative values, etc.) are processed as usual.
func (ASliceCmp) UniquesLenInRange ¶ added in v0.2.0
UniquesLenInRange
Length of unique elements sub-slice expects to be in range [min, max].
Fails check, if min > max -- it works like empty range. Logically incorrect params (e.g. negative values, etc.) are processed as usual.
func (ASliceCmp) UniquesLenMax ¶ added in v0.2.0
UniquesLenMax
Length of unique elements sub-slice expects to be less or equal to "max".
Logically incorrect params (e.g. negative values, etc.) are processed as usual.
func (ASliceCmp) UniquesLenMin ¶ added in v0.2.0
UniquesLenMin
Length of unique elements sub-slice expects to be greater or equal to "min".
Logically incorrect params (e.g. negative values, etc.) are processed as usual.
func (ASliceCmp) UniquesLenNotEq ¶ added in v0.2.0
UniquesLenNotEq
Length of unique elements sub-slice expects to be not equal to "notEq".
Logically incorrect params (e.g. negative values, etc.) are processed as usual.
func (ASliceCmp) UniquesLenNotInRange ¶ added in v0.2.0
UniquesLenNotInRange
Length of unique elements sub-slice expects to be not in range [min, max] -- i.e. to be in ranges [0, min) or (max, MaxInt].
Passes check, if min > max -- it works like empty range. Logically incorrect params (e.g. negative values, etc.) are processed as usual.
type AString ¶
type AString struct {
// contains filtered or unexported fields
}
func (AString) Check ¶
Check
Runs registered validation checks one by one against the given value and returns an error from a first failed check. Returns nil, if all checks pass.
func (AString) CheckAll ¶
func (a AString) CheckAll(v T) []error
CheckAll
Runs registered validation checks one by one against the given value and returns errors from all failed checks. Returns empty slice, if all checks pass.
func (*AString) ContainsStr ¶ added in v0.2.0
ContainsStr
Value expects to contain provided substring.
Passes check, if empty substring provided.
See strings.Contains.
func (*AString) ContainsStrAny ¶ added in v0.2.0
ContainsStrAny
Value expects to contain any of provided substrings.
Passes check, if provided set of substrings is empty.
See strings.Contains.
func (*AString) ContainsStrEach ¶ added in v0.2.0
ContainsStrEach
Value expects to contain each of provided substrings.
Passes check, if provided set of substrings is empty.
See strings.Contains.
func (*AString) ContainsStrNone ¶ added in v0.2.0
ContainsStrNone
Value expects to contain none of provided substrings.
Passes check, if provided set of substrings is empty.
See strings.Contains.
func (AString) Eq ¶
func (m AString) Eq(eq T, customErrMsg ...string) A
Eq
Value expects to be equal to "eq".
func (AString) In ¶
func (m AString) In(slice []T, customErrMsg ...string) A
In
Value expects to be equal to any of the provided elements.
Fails check, if no elements provided.
func (AString) LenEq ¶
LenEq
Length expects to be equal to "eq".
Logically incorrect params (e.g. negative values, etc.) are processed as usual.
func (AString) LenInRange ¶
LenInRange
Length expects to be in range [min, max].
Fails check, if min > max -- it works like empty range.
Logically incorrect params (e.g. negative values, etc.) are processed as usual.
func (AString) LenMax ¶
LenMax
Length expects to be less or equal to "max".
Logically incorrect params (e.g. negative values, etc.) are processed as usual.
func (AString) LenMin ¶
LenMin
Length expects to be greater or equal to "min".
Logically incorrect params (e.g. negative values, etc.) are processed as usual.
func (AString) LenNotEq ¶
LenNotEq
Length expects to be not equal to "notEq".
Logically incorrect params (e.g. negative values, etc.) are processed as usual.
func (AString) LenNotInRange ¶
LenNotInRange
Length expects to be not in range [min, max] -- i.e. to be in ranges [0, min) or (max, MaxInt].
Passes check, if min > max -- it works like empty range.
Logically incorrect params (e.g. negative values, etc.) are processed as usual.
func (AString) Must ¶
func (a AString) Must(v T, customErrMsg ...string)
Must
Calls Check and panics with the error if validation fails.
func (AString) MustAll ¶
func (a AString) MustAll(v T)
MustAll
Calls CheckAll and panics with the error slice if validation fails.
func (AString) MustAllGet ¶ added in v0.3.0
func (a AString) MustAllGet(v T) T
MustAllGet
Works same as MustAll, but returns the value, if no panic occurred.
func (AString) MustGet ¶ added in v0.3.0
func (a AString) MustGet(v T, customErrMsg ...string) T
MustGet
Works same as Must, but returns the value, if no panic occurred.
func (*AString) NotContainsStr ¶ added in v0.2.0
NotContainsStr
Value expects to not contain provided substring.
Fails check, if empty substring provided.
See strings.Contains.
func (AString) NotEq ¶
func (m AString) NotEq(notEq T, customErrMsg ...string) A
NotEq
Value expects to be not equal to "notEq".
func (AString) NotIn ¶
func (m AString) NotIn(slice []T, customErrMsg ...string) A
NotIn
Value expects to be not equal to each of the provided elements.
Passes check, if no elements provided.
func (*AString) PrefixEq ¶ added in v0.2.0
PrefixEq
Value expects to have prefix equal to "eq".
Passes check, if empty prefix provided.
See strings.HasPrefix.
func (*AString) PrefixIn ¶ added in v0.2.0
PrefixIn
Value expects to have any of provided prefixes.
Fails check, if no prefixes provided.
See strings.HasPrefix.
func (*AString) PrefixNotEq ¶ added in v0.2.0
PrefixNotEq
Value expects to have prefix not equal to "notEq".
Fails check, if empty prefix provided.
See strings.HasPrefix.
func (*AString) PrefixNotIn ¶ added in v0.2.0
PrefixNotIn
Value expects to have none of provided prefixes.
Passes check, if no prefixes provided.
See strings.HasPrefix.
func (*AString) RunesEq ¶ added in v0.2.0
RunesEq
Runes count of the value expects to be equal to "eq".
Logically incorrect params (e.g. negative values, etc.) are processed as usual.
func (*AString) RunesInRange ¶ added in v0.2.0
RunesInRange
Runes count of the value expects to be in range [min, max].
Fails check, if min > max -- it works like empty range.
Logically incorrect params (e.g. negative values, etc.) are processed as usual.
func (*AString) RunesMax ¶ added in v0.2.0
RunesMax
Runes count of the value expects to be less or equal to "max".
Logically incorrect params (e.g. negative values, etc.) are processed as usual.
func (*AString) RunesMin ¶ added in v0.2.0
RunesMin
Runes count of the value expects to be greater or equal to "min".
Logically incorrect params (e.g. negative values, etc.) are processed as usual.
func (*AString) RunesNotEq ¶ added in v0.2.0
RunesNotEq
Runes count of the value expects to be not equal to "notEq".
Logically incorrect params (e.g. negative values, etc.) are processed as usual.
func (*AString) RunesNotInRange ¶ added in v0.2.0
RunesNotInRange
Runes count of the value expects to be not in range [min, max] -- i.e. to be in ranges [0, min) or (max, MaxInt].
Passes check, if min > max -- it works like empty range.
Logically incorrect params (e.g. negative values, etc.) are processed as usual.
func (*AString) SuffixEq ¶ added in v0.2.0
SuffixEq
Value expects to have suffix equal to "eq".
Passes check, if empty suffix provided.
See strings.HasSuffix.
func (*AString) SuffixIn ¶ added in v0.2.0
SuffixIn
Value expects to have any of provided suffixes.
Fails check, if no suffixes provided.
See strings.HasSuffix.
func (*AString) SuffixNotEq ¶ added in v0.2.0
SuffixNotEq
Value expects to have suffix not equal to "notEq".
Fails check, if empty suffix provided.
See strings.HasSuffix.
func (*AString) SuffixNotIn ¶ added in v0.2.0
SuffixNotIn
Value expects to have none of provided suffixes.
Passes check, if no suffixes provided.
See strings.HasSuffix.
type ATime ¶
type ATime struct {
// contains filtered or unexported fields
}
func (ATime) Check ¶
Check
Runs registered validation checks one by one against the given value and returns an error from a first failed check. Returns nil, if all checks pass.
func (ATime) CheckAll ¶
func (a ATime) CheckAll(v T) []error
CheckAll
Runs registered validation checks one by one against the given value and returns errors from all failed checks. Returns empty slice, if all checks pass.
func (ATime) Eq ¶
func (m ATime) Eq(eq T, customErrMsg ...string) A
Eq
Value expects to be equal to "eq".
func (ATime) Greater ¶
func (m ATime) Greater(than T, customErrMsg ...string) A
Greater
Value expects to be greater than "than".
func (ATime) GreaterAny ¶
func (m ATime) GreaterAny(elems []T, customErrMsg ...string) A
GreaterAny
Value expects to be greater than any of provided elements.
Passes check, if no elements provided.
func (ATime) GreaterEach ¶
func (m ATime) GreaterEach(elems []T, customErrMsg ...string) A
GreaterEach
Value expects to be greater than each of provided elements.
Passes check, if no elements provided.
func (ATime) GreaterEq ¶
func (m ATime) GreaterEq(than T, customErrMsg ...string) A
GreaterEq
Value expects to be greater or equal to "than".
func (ATime) GreaterEqAny ¶
func (m ATime) GreaterEqAny(elems []T, customErrMsg ...string) A
GreaterEqAny
Value expects to be greater or equal to any of provided elements.
Passes check, if no elements provided.
func (ATime) GreaterEqEach ¶
func (m ATime) GreaterEqEach(elems []T, customErrMsg ...string) A
GreaterEqEach
Value expects to be greater or equal to each of provided elements.
Passes check, if no elements provided.
func (ATime) In ¶
func (m ATime) In(slice []T, customErrMsg ...string) A
In
Value expects to be equal to any of the provided elements.
Fails check, if no elements provided.
func (ATime) InRange ¶
func (m ATime) InRange(min T, max T, customErrMsg ...string) A
InRange
Value expects to be in range [min, max].
Fails check, if min > max -- it works like empty range.
func (ATime) Less ¶
func (m ATime) Less(than T, customErrMsg ...string) A
Less
Value expects to be less than "than".
func (ATime) LessAny ¶
func (m ATime) LessAny(elems []T, customErrMsg ...string) A
LessAny
Value expects to be less than any of provided elements.
Passes check, if no elements provided.
func (ATime) LessEach ¶
func (m ATime) LessEach(elems []T, customErrMsg ...string) A
LessEach
Value expects to be less than each of provided elements.
Passes check, if no elements provided.
func (ATime) LessEq ¶
func (m ATime) LessEq(than T, customErrMsg ...string) A
LessEq
Value expects to be less or equal to "than".
func (ATime) LessEqAny ¶
func (m ATime) LessEqAny(elems []T, customErrMsg ...string) A
LessEqAny
Value expects to be less or equal to any of provided elements.
Passes check, if no elements provided.
func (ATime) LessEqEach ¶
func (m ATime) LessEqEach(elems []T, customErrMsg ...string) A
LessEqEach
Value expects to be less or equal to each of provided elements.
Passes check, if no elements provided.
func (ATime) Must ¶
func (a ATime) Must(v T, customErrMsg ...string)
Must
Calls Check and panics with the error if validation fails.
func (ATime) MustAll ¶
func (a ATime) MustAll(v T)
MustAll
Calls CheckAll and panics with the error slice if validation fails.
func (ATime) MustAllGet ¶ added in v0.3.0
func (a ATime) MustAllGet(v T) T
MustAllGet
Works same as MustAll, but returns the value, if no panic occurred.
func (ATime) MustGet ¶ added in v0.3.0
func (a ATime) MustGet(v T, customErrMsg ...string) T
MustGet
Works same as Must, but returns the value, if no panic occurred.
func (ATime) NotEq ¶
func (m ATime) NotEq(notEq T, customErrMsg ...string) A
NotEq
Value expects to be not equal to "notEq".
func (ATime) NotIn ¶
func (m ATime) NotIn(slice []T, customErrMsg ...string) A
NotIn
Value expects to be not equal to each of the provided elements.
Passes check, if no elements provided.
func (ATime) NotInRange ¶
func (m ATime) NotInRange(min T, max T, customErrMsg ...string) A
NotInRange
Value expects to be not in range [min, max] -- i.e. to be in ranges [PossibleMin, min) or (max, PossibleMax]
Passes check, if min > max -- it works like empty range.
type ATimeDuration ¶
type ATimeDuration struct {
// contains filtered or unexported fields
}
func TimeDur ¶ added in v0.3.0
func TimeDur() *ATimeDuration
func TimeDuration
deprecated
func (ATimeDuration) Check ¶
Check
Runs registered validation checks one by one against the given value and returns an error from a first failed check. Returns nil, if all checks pass.
func (ATimeDuration) CheckAll ¶
func (a ATimeDuration) CheckAll(v T) []error
CheckAll
Runs registered validation checks one by one against the given value and returns errors from all failed checks. Returns empty slice, if all checks pass.
func (ATimeDuration) Eq ¶
func (m ATimeDuration) Eq(eq T, customErrMsg ...string) A
Eq
Value expects to be equal to "eq".
func (ATimeDuration) Greater ¶
func (m ATimeDuration) Greater(than T, customErrMsg ...string) A
Greater
Value expects to be greater than "than".
func (ATimeDuration) GreaterAny ¶
func (m ATimeDuration) GreaterAny(elems []T, customErrMsg ...string) A
GreaterAny
Value expects to be greater than any of provided elements.
Passes check, if no elements provided.
func (ATimeDuration) GreaterEach ¶
func (m ATimeDuration) GreaterEach(elems []T, customErrMsg ...string) A
GreaterEach
Value expects to be greater than each of provided elements.
Passes check, if no elements provided.
func (ATimeDuration) GreaterEq ¶
func (m ATimeDuration) GreaterEq(than T, customErrMsg ...string) A
GreaterEq
Value expects to be greater or equal to "than".
func (ATimeDuration) GreaterEqAny ¶
func (m ATimeDuration) GreaterEqAny(elems []T, customErrMsg ...string) A
GreaterEqAny
Value expects to be greater or equal to any of provided elements.
Passes check, if no elements provided.
func (ATimeDuration) GreaterEqEach ¶
func (m ATimeDuration) GreaterEqEach(elems []T, customErrMsg ...string) A
GreaterEqEach
Value expects to be greater or equal to each of provided elements.
Passes check, if no elements provided.
func (ATimeDuration) In ¶
func (m ATimeDuration) In(slice []T, customErrMsg ...string) A
In
Value expects to be equal to any of the provided elements.
Fails check, if no elements provided.
func (ATimeDuration) InRange ¶
func (m ATimeDuration) InRange(min T, max T, customErrMsg ...string) A
InRange
Value expects to be in range [min, max].
Fails check, if min > max -- it works like empty range.
func (ATimeDuration) Less ¶
func (m ATimeDuration) Less(than T, customErrMsg ...string) A
Less
Value expects to be less than "than".
func (ATimeDuration) LessAny ¶
func (m ATimeDuration) LessAny(elems []T, customErrMsg ...string) A
LessAny
Value expects to be less than any of provided elements.
Passes check, if no elements provided.
func (ATimeDuration) LessEach ¶
func (m ATimeDuration) LessEach(elems []T, customErrMsg ...string) A
LessEach
Value expects to be less than each of provided elements.
Passes check, if no elements provided.
func (ATimeDuration) LessEq ¶
func (m ATimeDuration) LessEq(than T, customErrMsg ...string) A
LessEq
Value expects to be less or equal to "than".
func (ATimeDuration) LessEqAny ¶
func (m ATimeDuration) LessEqAny(elems []T, customErrMsg ...string) A
LessEqAny
Value expects to be less or equal to any of provided elements.
Passes check, if no elements provided.
func (ATimeDuration) LessEqEach ¶
func (m ATimeDuration) LessEqEach(elems []T, customErrMsg ...string) A
LessEqEach
Value expects to be less or equal to each of provided elements.
Passes check, if no elements provided.
func (ATimeDuration) Must ¶
func (a ATimeDuration) Must(v T, customErrMsg ...string)
Must
Calls Check and panics with the error if validation fails.
func (ATimeDuration) MustAll ¶
func (a ATimeDuration) MustAll(v T)
MustAll
Calls CheckAll and panics with the error slice if validation fails.
func (ATimeDuration) MustAllGet ¶ added in v0.3.0
func (a ATimeDuration) MustAllGet(v T) T
MustAllGet
Works same as MustAll, but returns the value, if no panic occurred.
func (ATimeDuration) MustGet ¶ added in v0.3.0
func (a ATimeDuration) MustGet(v T, customErrMsg ...string) T
MustGet
Works same as Must, but returns the value, if no panic occurred.
func (ATimeDuration) NotEq ¶
func (m ATimeDuration) NotEq(notEq T, customErrMsg ...string) A
NotEq
Value expects to be not equal to "notEq".
func (ATimeDuration) NotIn ¶
func (m ATimeDuration) NotIn(slice []T, customErrMsg ...string) A
NotIn
Value expects to be not equal to each of the provided elements.
Passes check, if no elements provided.
func (ATimeDuration) NotInRange ¶
func (m ATimeDuration) NotInRange(min T, max T, customErrMsg ...string) A
NotInRange
Value expects to be not in range [min, max] -- i.e. to be in ranges [PossibleMin, min) or (max, PossibleMax]
Passes check, if min > max -- it works like empty range.
func (*ATimeDuration) NotZero ¶
func (a *ATimeDuration) NotZero(customErrMsg ...string) *ATimeDuration
NotZero -- alias to NotEq(time.Duration(0))
func (*ATimeDuration) Zero ¶
func (a *ATimeDuration) Zero(customErrMsg ...string) *ATimeDuration
Zero -- alias to Eq(time.Duration(0))