diff --git a/pkg/net/http/blademaster/binding/binding.go b/pkg/net/http/blademaster/binding/binding.go index 46f1c770d..ea2c8e017 100644 --- a/pkg/net/http/blademaster/binding/binding.go +++ b/pkg/net/http/blademaster/binding/binding.go @@ -37,6 +37,9 @@ type StructValidator interface { // NOTE: if the key already exists, the previous validation function will be replaced. // NOTE: this method is not thread-safe it is intended that these all be registered prior to any validation RegisterValidation(string, validator.Func) error + + //GetValidate return the default validate + GetValidate() *validator.Validate } // Validator default validator. diff --git a/pkg/net/http/blademaster/binding/default_validator.go b/pkg/net/http/blademaster/binding/default_validator.go index 5dbf67ed2..9e1e8fc02 100644 --- a/pkg/net/http/blademaster/binding/default_validator.go +++ b/pkg/net/http/blademaster/binding/default_validator.go @@ -43,3 +43,8 @@ func kindOfData(data interface{}) reflect.Kind { } return valueType } + +func (v *defaultValidator) GetValidate() *validator.Validate { + v.lazyinit() + return v.validate +} \ No newline at end of file diff --git a/pkg/net/rpc/warden/validate.go b/pkg/net/rpc/warden/validate.go index f9444fca0..ddd715ca6 100644 --- a/pkg/net/rpc/warden/validate.go +++ b/pkg/net/rpc/warden/validate.go @@ -29,3 +29,8 @@ func (s *Server) validate() grpc.UnaryServerInterceptor { func (s *Server) RegisterValidation(key string, fn validator.Func) error { return validate.RegisterValidation(key, fn) } + +//GetValidate return the default validate +func (s *Server) GetValidate() *validator.Validate { + return validate +}