forms

package
v0.0.0-...-4a31f9d Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2019 License: MIT Imports: 8 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])?)*$")

Functions

func ShipLength

func ShipLength(shipName string) int

ShipLength - how many pins should this ship get?

Types

type Form

type Form struct {
	url.Values
	Errors errors
}

Create a custom Form struct, which anonymously embeds a url.Values object (to hold the form data) and an Errors field to hold any validation errors

func New

func New(data url.Values) *Form

Define a New function to initialize a custom Form struct

Takes the Form data as the parameter

func (*Form) FieldsMatch

func (f *Form) FieldsMatch(f1, f2 string, shouldTheyMatch bool)

FieldsMatch - check to ensure fields match; ex: passwords

func (*Form) MatchesPattern

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

Matches Pattern - for verifying a pattern match

func (*Form) MaxLength

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

MaxLength - for checking maximum number of characters

func (*Form) MinLength

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

MinLength - for checking presence of a minimum number of characters

func (*Form) PasswordComplexity

func (f *Form) PasswordComplexity()

PasswordComplexity - make sure password meets basic complexity requirements

func (*Form) PermittedValues

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

PermittedValues - matches one of a set of specific permitted values

func (*Form) Required

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

Required - check for the presence of an item in a field list

func (*Form) RequiredNumberOfItems

func (f *Form) RequiredNumberOfItems(shipType string, requiredNumber int, countedNumber int)

RequiredNumberOfItems - require X number of coordinates for the specific ship

func (*Form) SpacesAbsent

func (f *Form) SpacesAbsent(field string)

MaxLength - for checking maximum number of characters

func (*Form) Valid

func (f *Form) Valid() bool

Implement a Valid method which returns true if there are no errors.

func (*Form) ValidNumberOfItems

func (f *Form) ValidNumberOfItems(coordinates []string, shipName string)

ValidNumberOfItems - make sure that the ship in question has proper pin placement

Jump to

Keyboard shortcuts

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