form

package
v0.0.0-...-8ed6344 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 28, 2020 License: GPL-3.0 Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PhoneRX = regexp.MustCompile("(^\\+[0-9]{2}|^\\+[0-9]{2}\\(0\\)|^\\(\\+[0-9]{2}\\)\\(0\\)|^00[0-9]{2}|^0)([0-9]{9}$|[0-9\\-\\s]{10}$)")

PhoneRX represents phone number maching pattern

Functions

This section is empty.

Types

type Input

type Input struct {
	Values  url.Values
	VErrors ValidationErrors
	CSRF    string
}

Input represents form input values and validations

func (*Input) MatchesPattern

func (inVal *Input) MatchesPattern(field string, pattern *regexp.Regexp)

MatchesPattern checks if a given input form field matchs a given pattern

func (*Input) MinLength

func (inVal *Input) MinLength(field string, d int)

MinLength checks if a given minium length is satisfied

func (*Input) PasswordMatches

func (inVal *Input) PasswordMatches(password string, confPassword string)

PasswordMatches checks if Password and Confirm Password fields match

func (*Input) Required

func (inVal *Input) Required(fields ...string)

Required checks if list of provided form input fields have values

func (*Input) Valid

func (inVal *Input) Valid() bool

Valid checks if any form input validation has failed or not

type ValidationErrors

type ValidationErrors map[string][]string

ValidationErrors represents input validation errors

func (ValidationErrors) Add

func (ve ValidationErrors) Add(field, message string)

Add method to add error messages for a given field to the map

func (ValidationErrors) Get

func (ve ValidationErrors) Get(field string) string

Get method to retrieve the first error message for a given// field from the map.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL