mirror of
https://github.com/go-kratos/kratos.git
synced 2025-01-10 00:29:01 +02:00
add GetValidate func to get the default validator (#558)
* add GetValidate func to get the default validator * warden server expose GetValidate func Co-authored-by: John Sun <sunqiang@styd.cn>
This commit is contained in:
parent
d57df0b443
commit
52cb7ec27f
@ -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.
|
||||
|
@ -43,3 +43,8 @@ func kindOfData(data interface{}) reflect.Kind {
|
||||
}
|
||||
return valueType
|
||||
}
|
||||
|
||||
func (v *defaultValidator) GetValidate() *validator.Validate {
|
||||
v.lazyinit()
|
||||
return v.validate
|
||||
}
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user