form

package
v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2017 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package form provides simple helpers for the form validation and query params type casting.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParamBodyJson

func ParamBodyJson(r *http.Request, v interface{}, closeBody ...bool) error

ParamBodyJson returns a json unmarshal result from the request body

func ParamBoolean

func ParamBoolean(r *http.Request, name string, defaultValue bool) bool

ParamBoolean returns boolean value from the form or query

func ParamDefined

func ParamDefined(r *http.Request, name string) bool

ParamDefined will check if has such param defined in url queries.

func ParamFloat32

func ParamFloat32(r *http.Request, name string, defaultValue float32) float32

ParamFloat32 returns float32 value from the form or query

func ParamFloat64

func ParamFloat64(r *http.Request, name string, defaultValue float64) float64

ParamFloat64 returns float64 value from the form or query

func ParamInt

func ParamInt(r *http.Request, name string, defaultValue int) int

ParamInt returns int value from the form or query

func ParamInt64

func ParamInt64(r *http.Request, name string, defaultValue int64) int64

ParamInt64 returns int64 value from the form or query

func ParamJson

func ParamJson(r *http.Request, name string, v interface{}) error

ParamJson returns a json unmarshal result from the form or query

func ParamString

func ParamString(r *http.Request, name string, defaultValue string) string

ParamString returns string value from the form or query

func ParamStringOptions

func ParamStringOptions(r *http.Request, name string, options []string, defaultValue string) string

ParamStringOptions will check if the form value is contained in options, otherwise will return the default value.

func ValidateEmail

func ValidateEmail(r *http.Request, name string) bool

ValidateEmail will validate a form field and check if it is an Email address.

func ValidateFileExts

func ValidateFileExts(r *http.Request, name string, exts ...string) bool

ValidateFileExts will validate a form field and check if it's file extension in the allowed list.

func ValidateInt

func ValidateInt(r *http.Request, name string, minmax ...int64) bool

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

func ValidateMobile(r *http.Request, name string) bool

ValidateMobile will validate a form field and check if it is a mobile phone number (for China format, e.g. "13911119999")

func ValidateString

func ValidateString(r *http.Request, name string, re ...*regexp.Regexp) bool

ValidateString will validate a string field for the form, if the re pattern is passing in, validation would be check on the regexp.MatchString, else only check for emptyness.

Types

This section is empty.

Jump to

Keyboard shortcuts

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