Documentation
¶
Index ¶
- Variables
- func CanNotBe(value string, prefix string) bool
- func Matches(value string, rx *regexp.Regexp) bool
- func MaxChars(value string, n int) bool
- func MinChars(value string, n int) bool
- func MustBeFromList(value string, permittedValues ...string) bool
- func MustBeJSON(value string) bool
- func MustBeOfType(value string, typeToCheck string) bool
- func MustBeXML(value string) bool
- func MustNotContainBlanks(value string) bool
- func MustNotStartwith(value string, prefix string) bool
- func MustStartwith(value string, prefix string) bool
- func MustStartwithOneOf(value string, prefixs ...string) bool
- func NotBlank(value string) bool
- func PermittedInt(value int, permittedValues ...int) bool
- 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])?)*$")
Use the regexp.MustCompile() function to parse a regular expression pattern for sanity checking the format of an email address. This returns a pointer to a 'compiled' regexp.Regexp type, or panics in the event of an error. Parsing this pattern once at startup and storing the compiled *regexp.Regexp in a variable is more performant than re-parsing the pattern each time we need it.
Functions ¶
func CanNotBe ¶
------------------------------------------------------
------------------------------------------------------ Cannot be
func Matches ¶
Matches() returns true if a value matches a provided compiled regular expression pattern.
func MaxChars ¶
------------------------------------------------------
------------------------------------------------------ MaxChars() returns true if a value contains no more than n characters.
func MinChars ¶
------------------------------------------------------
------------------------------------------------------ MinChars() returns true if a value contains at least n characters.
func MustBeFromList ¶
------------------------------------------------------
------------------------------------------------------
func MustBeJSON ¶
------------------------------------------------------
------------------------------------------------------
func MustBeOfType ¶
------------------------------------------------------
------------------------------------------------------
func MustBeXML ¶
------------------------------------------------------
------------------------------------------------------
func MustNotContainBlanks ¶
------------------------------------------------------
------------------------------------------------------ Must start with
func MustNotStartwith ¶
------------------------------------------------------
------------------------------------------------------ Must start with
func MustStartwith ¶
------------------------------------------------------
------------------------------------------------------ Must start with
func MustStartwithOneOf ¶
------------------------------------------------------
------------------------------------------------------ Must start with One of
func NotBlank ¶
------------------------------------------------------
------------------------------------------------------ NotBlank() returns true if a value is not an empty string.
func PermittedInt ¶
------------------------------------------------------
------------------------------------------------------ PermittedInt() returns true if a value is in a list of permitted integers.
Types ¶
type Validator ¶
type Validator struct { FieldErrors map[string]string `json:"field_error" db:"-" form:"-"` NonFieldErrors []string }
------------------------------------------------------
------------------------------------------------------ Define a new Validator type which contains a map of validation errors for our form fields.
func (*Validator) AddFieldError ¶
------------------------------------------------------
------------------------------------------------------ AddFieldError() adds an error message to the FieldErrors map (so long as no entry already exists for the given key).
func (*Validator) AddNonFieldError ¶
------------------------------------------------------
------------------------------------------------------
func (*Validator) CheckField ¶
------------------------------------------------------
------------------------------------------------------ CheckField() adds an error message to the FieldErrors map only if a validation check is not 'ok'.