Documentation ¶
Overview ¶
Package validator is a lightweight model validator written in Go.
::quickstart::
package main import ( "fmt" v "github.com/go-the-way/validator" ) func main() { result := v.New(&struct { int `validate:"min(10,fail)"` }{}).Validate() fmt.Println(result.Passed) fmt.Println(result.Messages()) }
Index ¶
- func Custom(name string, vF func(value reflect.Value) (bool, string))
- type Item
- type Result
- type ResultItem
- type VFunc
- func ArrLengthFunc(str string) VFunc
- func ArrMaxLengthFunc(str string) VFunc
- func ArrMinLengthFunc(str string) VFunc
- func EnumFunc(str string) VFunc
- func LengthFunc(str string) VFunc
- func MaxFunc(str string) VFunc
- func MaxLengthFunc(str string) VFunc
- func MinFunc(str string) VFunc
- func MinLengthFunc(str string) VFunc
- func RegexFunc(str string) VFunc
- func ValidFunc(str string) VFunc
- type Validator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Item ¶
type Item struct { Min string `alias:"min"` // Min for min value Max string `alias:"max"` // Max for max value MinLength string `alias:"minlength"` // MinLength for min length ArrMinLength string `alias:"arr_minlength"` // ArrMinLength for array min length MaxLength string `alias:"maxlength"` // MaxLength for max length ArrMaxLength string `alias:"arr_maxlength"` // ArrMaxLength for array max length Length string `alias:"length"` // Length for length ArrLength string `alias:"arr_length"` // ArrLength for array length Enum string `alias:"enum"` // Enum for enum values Regex string `alias:"regex"` // Regex for regex pattern Msg string `alias:"msg"` // Msg for message Valid string `alias:"valid"` // Valid for valid Custom string `alias:"custom"` // Custom for custom validator }
Item struct
type Result ¶
type Result struct { StructPtr interface{} Passed bool Items []*ResultItem }
Result struct
type ResultItem ¶
type ResultItem struct { Field *reflect.StructField Passed bool Message string }
ResultItem struct
type VFunc ¶
VFunc interface
func ArrMaxLengthFunc ¶ added in v1.0.2
ArrMaxLengthFunc method
func ArrMinLengthFunc ¶ added in v1.0.2
ArrMinLengthFunc method
Click to show internal directories.
Click to hide internal directories.