Documentation
¶
Index ¶
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])?)*$")
Regex expression to validate the format of an email string.
Functions ¶
func MaxChars ¶
MaxChars() returns true if the length of the input string is not greater than the limit n.
func PermittedValue ¶
func PermittedValue[T comparable](value T, permittedValues ...T) bool
PermittedInt() returns true if a value is in a list of permitted integers.
Types ¶
type Validator ¶
Define a new Validator type which contains a map of validation errors for form data.
func (*Validator) AddFieldError ¶
AddFieldError() adds a [form field name : error message] mapping to the FieldErrors map, so long as an entry does not already exist.
func (*Validator) AddNonFieldError ¶
AddNonFieldError adds an error message to the NonFieldErrors string array, which stores error messages for validation errors not related to the form field data.
func (*Validator) CheckField ¶
CheckField() adds an error message to the FieldError map only if the validation check is not 'ok'.