feat(binding): add support for custom validator / validation tags (#1068)
* feat(binding): Add support for custom validation tags * docs: Add example for custom validation tag * test(binding): Add test for registering custom validation
This commit is contained in:
committed by
Javier Provecho Fernandez
parent
030b1aaf72
commit
26c3f42095
@@ -28,6 +28,11 @@ func (v *defaultValidator) ValidateStruct(obj interface{}) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (v *defaultValidator) RegisterValidation(key string, fn validator.Func) error {
|
||||
v.lazyinit()
|
||||
return v.validate.RegisterValidation(key, fn)
|
||||
}
|
||||
|
||||
func (v *defaultValidator) lazyinit() {
|
||||
v.once.Do(func() {
|
||||
config := &validator.Config{TagName: "binding"}
|
||||
|
||||
Reference in New Issue
Block a user