forms

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

EmailRegexp regexp.

View Source
var UsernameRegexp = regexp.MustCompile(`^[a-zA-Z0-9\\.\\-_]+$`)

UsernameRegexp regexp.

Functions

func DecodeBody

func DecodeBody(w http.ResponseWriter, r *http.Request, dst interface{}) error

DecodeBody function.

Types

type Bag

type Bag map[string][]string

Bag type.

func (Bag) Add

func (b Bag) Add(field, message string)

Add function.

type Error

type Error struct {
	Status int
	Msg    string
}

Error type.

func (*Error) Error

func (e *Error) Error() string

Error function.

type Form

type Form struct {
	Data   map[string]interface{}
	Errors Bag
}

Form type.

func New

func New(data map[string]interface{}) *Form

New function.

func NewFromRequest

func NewFromRequest(w http.ResponseWriter, r *http.Request) (*Form, error)

NewFromRequest function.

func (*Form) IsValid

func (f *Form) IsValid() bool

IsValid function.

func (*Form) MatchesPattern

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

MatchesPattern function.

func (*Form) Max

func (f *Form) Max(field string, max float64)

Max function.

func (*Form) Min

func (f *Form) Min(field string, min float64)

Min function.

func (*Form) Required

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

Required function.

Jump to

Keyboard shortcuts

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