forms

package
v0.0.0-...-88ae880 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2023 License: MIT Imports: 4 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 creates a custom form struct and embeds a url.Values object

func New

func New(data url.Values) *Form

New creates a new Form instance with the provided data and an empty errors map.

func (*Form) Has

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

Has returns true if the form field with the given name has a non-empty value.

func (*Form) IsEmail

func (f *Form) IsEmail(field string)

IsEmail checks if the value of the given field is a valid email address. If the value is not a valid email address, an error message is added to the form errors.

func (*Form) MinLength

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

MinLength checks if the value of the given field is at least of a certain length. If the value is shorter than the given length, an error message is added to the form errors. Returns true if the value is at least of the given length, false otherwise.

func (*Form) Required

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

Required checks if the specified fields in the form are not blank. If any of the fields are blank, an error message is added to the form's Errors field.

func (*Form) Valid

func (f *Form) Valid() bool

Valid returns true if there are no errors in the form, false otherwise.

Jump to

Keyboard shortcuts

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