Documentation ¶
Index ¶
- Variables
- func Empty(value string) bool
- func EndsWith(value, suffix string) bool
- func In[T comparable](value T, list ...T) bool
- func IsNumber(value string) bool
- func Matches(value string, rx *regexp.Regexp) bool
- func Max[T cmp.Ordered](value T, max T) bool
- func MaxLength(value string, max int) bool
- func Min[T cmp.Ordered](value T, min T) bool
- func MinLength(value string, min int) bool
- func NotEmpty(value string) bool
- func Range[T cmp.Ordered](value T, min, max T) bool
- func RangeLength(value string, min, max int) bool
- func StartsWith(value, prefix string) bool
- func Unique[T cmp.Ordered](values []T) bool
- type Case
- type Validator
Constants ¶
This section is empty.
Variables ¶
var (
EmailRX = regexp.MustCompile("^[a-zA-Z0-9.!#$%&'*+\\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$")
)
Functions ¶
func In ¶
func In[T comparable](value T, list ...T) bool
In checks if the value is present in a given list of arguments.
func Max ¶
Max checks if a value is equal or lesser than a maximum. For length, use MaxLength instead.
func Min ¶
Min checks if a value is equal or bigger than a minimum. For length, use MinLength instead.
func Range ¶
Range checks if a value is inside a number range, inclusive. For length, use RangeLength instead.
func RangeLength ¶
RangeLength checks if a string's utf8 length is inside the given range, inclusive.
func StartsWith ¶
StartsWith check whether a string starts with a particular prefix.
Types ¶
type Case ¶
Case is a test-case, consisting of two parts. Cond will call a function that returns a boolean. if it returns false, Msg will be added to the Validator.Errors.
type Validator ¶
Validator will check for cases by Check method and will return a boolean with Valid method. If a validation error happens, the Msg will be stored inside the Errors map.