forms

package
v0.0.0-...-0cd45ec Latest Latest
Warning

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

Go to latest
Published: May 12, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Form

type Form struct {
	url.Values
	Errors errors
}

Form holds URL values which essentially are Values maps a string key to a list of values. It is typically used for query parameters and form values. Unlike in the http.Header map, the keys in a Values map are case-sensitive and errors associated with form fields.

func New

func New(data url.Values) *Form

New creates a new form based on query parameter, or form value data (i.e. url.Values) and empty error map.

func (*Form) Has

func (f *Form) Has(field string) bool

Has checks whether or not a specific form field has a value or not.

func (*Form) IsEmail

func (f *Form) IsEmail(field string)

IsEmail checks for a valid email address

func (*Form) MinLength

func (f *Form) MinLength(field string, length int) bool

MinLength checks if a specific field has at least 'length' (a function parameter) characters.

func (*Form) MinValueFloat64

func (f *Form) MinValueFloat64(field string, value float64) bool

MinValueFloat64 checks if a specific field is greater or equal then specified value.

func (*Form) MinValueInt64

func (f *Form) MinValueInt64(field string, value int64) bool

MinValueInt64 checks if a specific field is greater or equal then specified value.

func (*Form) Required

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

Required checks whether or not all specified fields have a value. For those fields that do NOT have any value, a new error masseg is added to the Form object errors map.

func (*Form) Valid

func (f *Form) Valid() bool

Valid checks if the length of errors map of the specific Form object is empty or not. If it is, form is valid, otherwise, form is invalid.

Jump to

Keyboard shortcuts

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