Skip to content

Instantly share code, notes, and snippets.

@long25vn
Forked from apzuk3/validation_rules.go
Created July 3, 2020 03:55
Show Gist options
  • Save long25vn/bea586b52f8d2eaf38b306b991c19347 to your computer and use it in GitHub Desktop.
Save long25vn/bea586b52f8d2eaf38b306b991c19347 to your computer and use it in GitHub Desktop.
Validation rules
package main
import "fmt"
type User struct {
Email string `json:"email" validate:"required,email"`
Name string `json:"name" validate:"required,min=2,max=100"`
}
func main() {
u := User{}
err := validate.Validate(a)
fmt.Fatal(err)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment