Documentation ¶
Index ¶
- 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 Error
- type Validator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func In ¶
func In[T comparable](value T, list ...T) bool
In checks if the given value is contained in the given list of arguments.
func MaxLength ¶
MaxLength checks if the given string's UTF8 length is equal or less than the given max.
func MinLength ¶
MinLength checks if the given string's UTF8 length is equal or greater than the given min.
func RangeLength ¶
RangeLength checks if the given string's UTF8 length is within the given range.
func StartsWith ¶
StartsWith checks if the given string starts with the given prefix.
Types ¶
type Case ¶
Case represents a validation test case. Contains a condition that is a the boolean result of the check, and an error message.
type Validator ¶
type Validator struct {
Errors Error `json:"errors"`
}
Validator performs a number of validation checks and determines if eveything is valid or not. Contains the map of error messages.