23 lines
408 B
Go
23 lines
408 B
Go
|
package myvalidator
|
||
|
|
||
|
import (
|
||
|
ut "github.com/go-playground/universal-translator"
|
||
|
"github.com/go-playground/validator/v10"
|
||
|
)
|
||
|
|
||
|
var (
|
||
|
ginTrans ut.Translator
|
||
|
)
|
||
|
|
||
|
func InitGin(ginVt *validator.Validate) {
|
||
|
//if vt2, ok := binding.Validator.Engine().(*validator.Validate); ok {
|
||
|
// ginVt = vt2
|
||
|
//}
|
||
|
ginTrans = RegisterTranslate(ginVt)
|
||
|
|
||
|
}
|
||
|
|
||
|
func TransGin(err error) error {
|
||
|
return GetTransError(ginTrans, err)
|
||
|
}
|