form

package
v0.1353.0-weblatepr.1 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package form provides types for some common forms.

Index

Constants

This section is empty.

Variables

View Source
var FieldNames = SharedFieldNames{
	LanguagePreference: "language-preference",
	Address: AddressFieldNames{
		Line1:      "address-line-1",
		Line2:      "address-line-2",
		Line3:      "address-line-3",
		TownOrCity: "address-town",
		Postcode:   "address-postcode",
		Action:     "action",
	},
	YesNo: "yes-no",
}
View Source
var YesNoValues = YesNoOptions{
	Unknown: YesNoUnknown,
	Yes:     Yes,
	No:      No,
}

Functions

func DecodeAddress

func DecodeAddress(s string) *place.Address

func PostFormString

func PostFormString(r *http.Request, name string) string

Types

type AddressFieldNames added in v0.943.0

type AddressFieldNames struct {
	Line1      string
	Line2      string
	Line3      string
	TownOrCity string
	Postcode   string
	Action     string
}

type AddressForm

type AddressForm struct {
	Action         string
	LookupPostcode string
	Address        *place.Address
	FieldNames     AddressFieldNames
}

func NewAddressForm added in v0.943.0

func NewAddressForm() *AddressForm

func ReadAddressForm

func ReadAddressForm(r *http.Request) *AddressForm

func (*AddressForm) Validate

func (f *AddressForm) Validate(useYour bool) validation.List

type LanguagePreferenceForm added in v0.884.0

type LanguagePreferenceForm struct {
	Preference localize.Lang
	Error      error
	ErrorLabel string
}

func ReadLanguagePreferenceForm added in v0.884.0

func ReadLanguagePreferenceForm(r *http.Request, errorLabel string) *LanguagePreferenceForm

func (*LanguagePreferenceForm) Validate added in v0.884.0

func (f *LanguagePreferenceForm) Validate() validation.List

type SharedFieldNames added in v0.943.0

type SharedFieldNames struct {
	Address            AddressFieldNames
	LanguagePreference string
	YesNo              string
}

type YesNo

type YesNo uint8
const (
	YesNoUnknown YesNo = iota
	Yes                // yes
	No                 // no
)

func ParseYesNo

func ParseYesNo(s string) (YesNo, error)

func (YesNo) IsNo

func (i YesNo) IsNo() bool

func (YesNo) IsUnknown added in v0.947.0

func (i YesNo) IsUnknown() bool

func (YesNo) IsYes

func (i YesNo) IsYes() bool

func (YesNo) MarshalText added in v0.912.0

func (i YesNo) MarshalText() ([]byte, error)

func (YesNo) String

func (i YesNo) String() string

func (*YesNo) UnmarshalText added in v0.1095.0

func (i *YesNo) UnmarshalText(text []byte) error

type YesNoForm

type YesNoForm struct {
	YesNo      YesNo
	Error      error
	ErrorLabel string
	Options    YesNoOptions
	FieldName  string
}

func NewYesNoForm added in v0.947.0

func NewYesNoForm(yesNo YesNo) *YesNoForm

func ReadYesNoForm

func ReadYesNoForm(r *http.Request, errorLabel string) *YesNoForm

func (*YesNoForm) Validate

func (f *YesNoForm) Validate() validation.List

type YesNoOptions

type YesNoOptions struct {
	Unknown YesNo
	Yes     YesNo
	No      YesNo
}

Jump to

Keyboard shortcuts

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