|
|
|
@ -6,7 +6,7 @@ import (
|
|
|
|
|
"reflect" |
|
|
|
|
"strings" |
|
|
|
|
|
|
|
|
|
ut "git.ningdatech.com/ningda/gin_valid/go-playground/universal-translator" |
|
|
|
|
ut "git.hpds.cc/Component/gin_valid/go-playground/universal-translator" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
const ( |
|
|
|
@ -58,27 +58,27 @@ func (ve ValidationErrors) Error() string {
|
|
|
|
|
|
|
|
|
|
// yang 修改
|
|
|
|
|
// Translate translates all of the ValidationErrors
|
|
|
|
|
//func (ve ValidationErrors) Translate(ut ut.Translator) ValidationErrorsTranslations {
|
|
|
|
|
// func (ve ValidationErrors) Translate(ut ut.Translator) ValidationErrorsTranslations {
|
|
|
|
|
//
|
|
|
|
|
// trans := make(ValidationErrorsTranslations)
|
|
|
|
|
// trans := make(ValidationErrorsTranslations)
|
|
|
|
|
//
|
|
|
|
|
// var fe *fieldError
|
|
|
|
|
// var fe *fieldError
|
|
|
|
|
//
|
|
|
|
|
// for i := 0; i < len(ve); i++ {
|
|
|
|
|
// fe = ve[i].(*fieldError)
|
|
|
|
|
// for i := 0; i < len(ve); i++ {
|
|
|
|
|
// fe = ve[i].(*fieldError)
|
|
|
|
|
//
|
|
|
|
|
// // // in case an Anonymous struct was used, ensure that the key
|
|
|
|
|
// // // would be 'Username' instead of ".Username"
|
|
|
|
|
// // if len(fe.ns) > 0 && fe.ns[:1] == "." {
|
|
|
|
|
// // trans[fe.ns[1:]] = fe.Translate(ut)
|
|
|
|
|
// // continue
|
|
|
|
|
// // }
|
|
|
|
|
// // // in case an Anonymous struct was used, ensure that the key
|
|
|
|
|
// // // would be 'Username' instead of ".Username"
|
|
|
|
|
// // if len(fe.ns) > 0 && fe.ns[:1] == "." {
|
|
|
|
|
// // trans[fe.ns[1:]] = fe.Translate(ut)
|
|
|
|
|
// // continue
|
|
|
|
|
// // }
|
|
|
|
|
//
|
|
|
|
|
// trans[fe.ns] = fe.Translate(ut)
|
|
|
|
|
// }
|
|
|
|
|
// trans[fe.ns] = fe.Translate(ut)
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// return trans
|
|
|
|
|
//}
|
|
|
|
|
// return trans
|
|
|
|
|
// }
|
|
|
|
|
type TransValidError struct { |
|
|
|
|
ErrorString string |
|
|
|
|
} |
|
|
|
|