Documentation ¶
Index ¶
- Constants
- Variables
- func RegisterBytesFilter(name string, fn func(v []byte) ([]byte, bool))
- func RegisterBytesFilterWithDescription(name string, fn func(v []byte) ([]byte, bool), description string)
- func RegisterRegexp(name string, rp *regexp.Regexp)
- type Defaulter
- type Document
- type Field
- type FormError
- type Former
- type Password
- type Rules
- type SimpleDocument
- func (m *SimpleDocument) AddTags(tags ...string) *SimpleDocument
- func (m *SimpleDocument) Description() string
- func (m *SimpleDocument) Input() string
- func (m *SimpleDocument) Output() string
- func (m *SimpleDocument) SetDescription(desc string) *SimpleDocument
- func (m *SimpleDocument) Tags() []string
Constants ¶
View Source
const ( MissingRequired = _FormErrorType(iota) BadValue )
Variables ¶
View Source
var CustomFormError func(fe *FormError) string
View Source
var ErrPeekManyValuesFromURLParamsOrCookie = errors.New("sha.validator: peek many values from URLParams or cookie")
View Source
var MarkdownTableHeader = "\n|name|type|required|field bytes size|int value range|list size range|default|regexp|function|description|\n"
View Source
var NameCast func(fieldName string) string
View Source
var ParseBool func(v []byte) (bool, error)
View Source
var PasswordValidator func(data []byte) bool = func(data []byte) bool { s := utils.S(data) var ( hasMinLen = false hasUpper = false hasLower = false hasNumber = false hasSpecial = false ) if len(s) >= 6 { hasMinLen = true } for _, char := range s { switch { case unicode.IsUpper(char): hasUpper = true case unicode.IsLower(char): hasLower = true case unicode.IsNumber(char): hasNumber = true case unicode.IsPunct(char) || unicode.IsSymbol(char): hasSpecial = true default: return false } } return hasMinLen && hasUpper && hasLower && hasNumber && hasSpecial }
View Source
var Undefined = &_undefined{}
Functions ¶
func RegisterRegexp ¶
Types ¶
type FormError ¶
type FormError struct { FormName string Type _FormErrorType }
func BindAndValidateForm ¶ added in v0.0.5
return value is a ptr, not an interface.
func ValidateStruct ¶ added in v0.0.5
func ValidateStruct(vPtr interface{}) (err *FormError)
func (*FormError) StatusCode ¶
type Former ¶
type Former interface { URLParam(name string) ([]byte, bool) QueryValue(name string) ([]byte, bool) QueryValues(name string) [][]byte BodyValue(name string) ([]byte, bool) BodyValues(name string) [][]byte FormValue(name string) ([]byte, bool) FormValues(name string) [][]byte HeaderValue(name string) ([]byte, bool) HeaderValues(name string) [][]byte CookieValue(name string) ([]byte, bool) }
type SimpleDocument ¶ added in v0.0.5
type SimpleDocument struct {
// contains filtered or unexported fields
}
func NewDocument ¶ added in v0.0.5
func NewDocument(input interface{}, output interface{}) *SimpleDocument
func (*SimpleDocument) AddTags ¶ added in v0.0.5
func (m *SimpleDocument) AddTags(tags ...string) *SimpleDocument
func (*SimpleDocument) Description ¶ added in v0.0.5
func (m *SimpleDocument) Description() string
func (*SimpleDocument) Input ¶ added in v0.0.5
func (m *SimpleDocument) Input() string
func (*SimpleDocument) Output ¶ added in v0.0.5
func (m *SimpleDocument) Output() string
func (*SimpleDocument) SetDescription ¶ added in v0.0.5
func (m *SimpleDocument) SetDescription(desc string) *SimpleDocument
func (*SimpleDocument) Tags ¶ added in v0.0.5
func (m *SimpleDocument) Tags() []string
Click to show internal directories.
Click to hide internal directories.