forms

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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])?)*$")

EmailRX emails must match this pattern

Functions

This section is empty.

Types

type Form

type Form struct {
	url.Values
	Errors errors
}

Form anonymous url.Values object for form data and Errors field for validation

func New

func New(data url.Values) *Form

New inits a new Form struct, takes form data as arg

func (*Form) MatchesPattern

func (f *Form) MatchesPattern(field string, pattern *regexp.Regexp)

MatchesPattern verifies a value matches a regex pattern

func (*Form) MaxLength

func (f *Form) MaxLength(field string, d int)

MaxLength use RuneCount to verify max length is not breached

func (*Form) MinLength

func (f *Form) MinLength(field string, d int)

MinLength use RuneCount to verify minimum length is reached

func (*Form) PermittedValues

func (f *Form) PermittedValues(field string, opts ...string)

PermittedValues check if field matches a permitted option

func (*Form) Required

func (f *Form) Required(fields ...string)

Required check if required fields are present

func (*Form) Valid

func (f *Form) Valid() bool

Valid check if our Form has any errors

Jump to

Keyboard shortcuts

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