Using "validator.v5"

This commit is contained in:
Manu Mtz-Almeida 2015-05-22 16:46:21 +02:00
parent 37b6f6c179
commit 8549810e2e

View File

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