Documentation ¶
Overview ¶
Example (Email) ¶
package main import ( "fmt" v "github.com/RussellLuo/validating/v3" "github.com/RussellLuo/vext" ) func main() { value := "foo#example.com" if err := v.Validate(v.Value(value, vext.Email())); err != nil { fmt.Printf("err: %v\n", err) } }
Output: err: INVALID(invalid email)
Example (Ip) ¶
package main import ( "fmt" v "github.com/RussellLuo/validating/v3" "github.com/RussellLuo/vext" ) func main() { value := "127.0.0." if err := v.Validate(v.Value(value, vext.IP())); err != nil { fmt.Printf("err: %v\n", err) } }
Output: err: INVALID(invalid IP)
Example (Time) ¶
package main import ( "fmt" "time" v "github.com/RussellLuo/validating/v3" "github.com/RussellLuo/vext" ) func main() { value := "2006-01-02T15:04:05" // missing timezone if err := v.Validate(v.Value(value, vext.Time(time.RFC3339))); err != nil { fmt.Printf("err: %v\n", err) } }
Output: err: INVALID(invalid time)
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Email ¶
func Email() *v.MessageValidator
func IP ¶
func IP() *v.MessageValidator
func Time ¶
func Time(layout string) (mv *v.MessageValidator)
Time is a leaf validator factory used to create a validator, which will succeed when the field's value matches the given time format specified by layout.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.