Documentation
¶
Overview ¶
Package validator provides functionality for validating and sanitizing data.
Index ¶
- func Blank(value string) bool
- func IsNumber(value string) bool
- func MaxChars(value string, n int) bool
- func MaxDuration(d, maxDuration time.Duration) bool
- func MinChars(value string, n int) bool
- func NotBlank(value string) bool
- func PermittedValue[T comparable](value T, permittedValues ...T) bool
- type Validator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MaxDuration ¶
MaxDuration validates if a duration is within the maximum allowed duration.
func PermittedValue ¶
func PermittedValue[T comparable](value T, permittedValues ...T) bool
PermittedValue returns true if a value is in a list of permitted integers.
Types ¶
type Validator ¶
Validator is a struct that contains field errors and a non-field errors.
func (*Validator) AddFieldError ¶
AddFieldError adds an error message to the FieldErrors map.
func (*Validator) AddNonFieldError ¶
AddNonFieldError adds an error message to the NonFieldErrors slice.
func (*Validator) CheckField ¶
CheckField adds an error message to the FieldErrors map only if a validation check is not passed.
Click to show internal directories.
Click to hide internal directories.