form

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2026 License: MPL-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool added in v0.1.5

func Bool(values Values, name string) (bool, bool, error)

Bool decodes one scalar boolean field and rejects repeated scalar values.

func Checkbox added in v0.1.5

func Checkbox(values Values, name string) (bool, error)

Checkbox decodes one checkbox as checked when the field was submitted. Absent checkboxes are false. Repeated values are rejected so checkbox groups use CheckboxGroup instead.

func CheckboxGroup added in v0.1.5

func CheckboxGroup(values Values, name string) []string

CheckboxGroup returns all submitted values for a checkbox group.

func Int added in v0.1.5

func Int(values Values, name string, bitSize int) (int64, bool, error)

Int decodes one signed integer field with the requested bit size.

func IsRuntimeField added in v0.1.5

func IsRuntimeField(name string) bool

IsRuntimeField reports whether a field is reserved for generated runtime metadata instead of user form input.

func Radio added in v0.1.5

func Radio(values Values, name string) (string, bool, error)

Radio decodes one selected radio value.

func Select added in v0.1.5

func Select(values Values, name string) (string, bool, error)

Select decodes a single-select field.

func SelectMultiple added in v0.1.5

func SelectMultiple(values Values, name string) []string

SelectMultiple returns all submitted values for a multiple select field.

func String added in v0.1.5

func String(values Values, name string) (string, bool, error)

String decodes one scalar string field and rejects repeated scalar values.

func Strings added in v0.1.5

func Strings(values Values, name string) []string

Strings returns all submitted values for a repeated string field.

func Uint added in v0.1.5

func Uint(values Values, name string, bitSize int) (uint64, bool, error)

Uint decodes one unsigned integer field with the requested bit size.

Types

type DecodeError

type DecodeError struct {
	Field   string
	Message string
}

DecodeError describes a generated form decoding failure without exposing submitted values.

func (DecodeError) Error

func (err DecodeError) Error() string

type Field

type Field struct {
	Name string
}

Field describes one expected form field for generated decoders.

type Schema

type Schema struct {
	Fields []Field
}

Schema describes the submitted fields accepted by a generated decoder.

type Values

type Values map[string][]string

Values is the normalized representation passed to generated action decoders.

func DecodeExpected

func DecodeExpected(values Values, schema Schema) (Values, error)

DecodeExpected returns a copy of the submitted values restricted to the schema field allowlist. Missing expected fields are allowed; validation decides whether an absent value is acceptable.

func FromURLValues

func FromURLValues(values url.Values) Values

FromURLValues copies request form values into a stable runtime structure.

func (Values) All

func (values Values) All(name string) []string

All returns all submitted values for a field.

func (Values) First

func (values Values) First(name string) string

First returns the first submitted value for a field.

func (Values) HasSubmitted

func (values Values) HasSubmitted(name string) bool

HasSubmitted reports whether a field was submitted with at least one non-blank value.

func (Values) Names

func (values Values) Names() []string

Names returns submitted field names in stable order.

Jump to

Keyboard shortcuts

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