Documentation ¶
Overview ¶
Package forms provides a way to safely and conveniently extract html Form data using a definied schema.
Index ¶
- Variables
- func Parse(r *http.Request, schema Schema) error
- func ParseValues(data url.Values, schema Schema) error
- type IntType
- type Parser
- func Bool(b *bool) Parser
- func BoolOr(b *bool, alt bool) Parser
- func Float(f *float64) Parser
- func FloatOr(f *float64, alt float64) Parser
- func Int[T IntType](i *T) Parser
- func IntOr[T IntType](i *T, alt T) Parser
- func Secret(s **conceal.Text) Parser
- func String[T StringType](s *T) Parser
- func StringOr[T StringType](s *T, alt T) Parser
- type Schema
- type StringType
Constants ¶
This section is empty.
Variables ¶
Functions ¶
Types ¶
type IntType ¶
type IntType interface { ~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 }
IntType represents any type compatible with the Go integer built-in types, to be used as a destination for writing the value of a form value.
type Parser ¶
A Parser implementation is capable of extracting a value from the value of an url.Values, which is a slice of string.
func Bool ¶
Bool is used to extract a form data value into a Go bool. If the value is not a bool or is missing than an error is returned during parsing.
func BoolOr ¶
BoolOr is used to extract a form data value into a Go bool. If the value is missing, then the alt value is used instead.
func Float ¶
Float is used to extract a form data value into a Go float64. If the value is not a float or is missing then an error is returned during parsing.
func FloatOr ¶
FloatOr is used to extract a form data value into a Go float64. If the value is missing, then the alt value is used instead.
func Int ¶
Int is used to extract a form data value into a Go int. If the value is not an int or is missing then an error is returned during parsing.
func IntOr ¶
IntOr is used to extract a form data value into a Go int. If the value is missing, then the alt value is used instead.
func Secret ¶
func Secret(s **conceal.Text) Parser
Secret is used to extract a form data value into a Go conceal.Text. If the value is missing then an error is returned during parsing.
func String ¶
func String[T StringType](s *T) Parser
String is used to extract a form data value into a Go string. If the value is not a string or is missing then an error is returned during parsing.
func StringOr ¶
func StringOr[T StringType](s *T, alt T) Parser
StringOr is used to extract a form data value into a Go string. If the value is missing, then the alt value is used instead.
type Schema ¶
A Schema describes how a set of url.Values should be parsed. Typically these are coming from an http.Request.Form from inside an http.Handler responding to an inbound request.
type StringType ¶
type StringType interface { ~string }
StringType represents any type compatible with the Go string built-in type, to be used as a destination for writing the value of an environment variable.