Using "validator.v5"

This commit is contained in:
Manu Mtz-Almeida 2015-05-22 16:46:21 +02:00
parent 37b6f6c179
commit 8549810e2e
1 changed files with 11 additions and 4 deletions

View File

@ -7,7 +7,7 @@ package binding
import ( import (
"net/http" "net/http"
"gopkg.in/joeybloggs/go-validate-yourself.v4" "gopkg.in/bluesuncorp/validator.v5"
) )
const ( const (
@ -25,7 +25,7 @@ type Binding interface {
Bind(*http.Request, interface{}) error Bind(*http.Request, interface{}) error
} }
var _validator = validator.NewValidator("binding", validator.BakedInValidators) var validate = validator.New("binding", validator.BakedInValidators)
var ( var (
JSON = jsonBinding{} JSON = jsonBinding{}
@ -48,8 +48,15 @@ func Default(method, contentType string) Binding {
} }
} }
func Validate(obj interface{}) error { func ValidateField(f interface{}, tag string) error {
if err := _validator.ValidateStruct(obj); err != nil { if err := validate.Field(f, tag); err != nil {
return error(err)
}
return nil
}
func Validate(obj interface{}) error {
if err := validate.Struct(obj); err != nil {
return error(err) return error(err)
} }
return nil return nil