Documentation ¶
Overview ¶
Package form provides simple helpers for the form validation and query params type casting.
Index ¶
- func ParamBodyJson(r *http.Request, v interface{}, closeBody ...bool) error
- func ParamBoolean(r *http.Request, name string, defaultValue bool) bool
- func ParamDefined(r *http.Request, name string) bool
- func ParamFloat32(r *http.Request, name string, defaultValue float32) float32
- func ParamFloat64(r *http.Request, name string, defaultValue float64) float64
- func ParamInt(r *http.Request, name string, defaultValue int) int
- func ParamInt64(r *http.Request, name string, defaultValue int64) int64
- func ParamJson(r *http.Request, name string, v interface{}) error
- func ParamString(r *http.Request, name string, defaultValue string) string
- func ParamStringOptions(r *http.Request, name string, options []string, defaultValue string) string
- func ValidateEmail(r *http.Request, name string) bool
- func ValidateFileExts(r *http.Request, name string, exts ...string) bool
- func ValidateInt(r *http.Request, name string, minmax ...int64) bool
- func ValidateMobile(r *http.Request, name string) bool
- func ValidateString(r *http.Request, name string, re ...*regexp.Regexp) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParamBodyJson ¶
ParamBodyJson returns a json unmarshal result from the request body
func ParamBoolean ¶
ParamBoolean returns boolean value from the form or query
func ParamDefined ¶
ParamDefined will check if has such param defined in url queries.
func ParamFloat32 ¶
ParamFloat32 returns float32 value from the form or query
func ParamFloat64 ¶
ParamFloat64 returns float64 value from the form or query
func ParamInt64 ¶
ParamInt64 returns int64 value from the form or query
func ParamString ¶
ParamString returns string value from the form or query
func ParamStringOptions ¶
ParamStringOptions will check if the form value is contained in options, otherwise will return the default value.
func ValidateEmail ¶
ValidateEmail will validate a form field and check if it is an Email address.
func ValidateFileExts ¶
ValidateFileExts will validate a form field and check if it's file extension in the allowed list.
func ValidateInt ¶
ValidateInt will avlidate a form field and check if it is a int number or you can pass in the min/max value for this
func ValidateMobile ¶
ValidateMobile will validate a form field and check if it is a mobile phone number (for China format, e.g. "13911119999")
Types ¶
This section is empty.