修改包地址
This commit is contained in:
parent
1d60bf7f13
commit
1c1e77a6e9
|
@ -4,7 +4,7 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.ningdatech.com/ningda/gin_valid/go-playground/locales/currency"
|
"git.hpds.cc/Component/gin_valid/go-playground/locales/currency"
|
||||||
)
|
)
|
||||||
|
|
||||||
// // ErrBadNumberValue is returned when the number passed for
|
// // ErrBadNumberValue is returned when the number passed for
|
||||||
|
|
|
@ -5,8 +5,8 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.ningdatech.com/ningda/gin_valid/go-playground/locales"
|
"git.hpds.cc/Component/gin_valid/go-playground/locales"
|
||||||
"git.ningdatech.com/ningda/gin_valid/go-playground/locales/currency"
|
"git.hpds.cc/Component/gin_valid/go-playground/locales/currency"
|
||||||
)
|
)
|
||||||
|
|
||||||
type zh struct {
|
type zh struct {
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"git.ningdatech.com/ningda/gin_valid/go-playground/locales"
|
"git.hpds.cc/Component/gin_valid/go-playground/locales"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
|
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
"git.ningdatech.com/ningda/gin_valid/go-playground/locales"
|
"git.hpds.cc/Component/gin_valid/go-playground/locales"
|
||||||
)
|
)
|
||||||
|
|
||||||
type translation struct {
|
type translation struct {
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"git.ningdatech.com/ningda/gin_valid/go-playground/locales"
|
"git.hpds.cc/Component/gin_valid/go-playground/locales"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
|
@ -3,7 +3,7 @@ package ut
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"git.ningdatech.com/ningda/gin_valid/go-playground/locales"
|
"git.hpds.cc/Component/gin_valid/go-playground/locales"
|
||||||
)
|
)
|
||||||
|
|
||||||
// UniversalTranslator holds all locale & translation data
|
// UniversalTranslator holds all locale & translation data
|
||||||
|
|
|
@ -27,11 +27,11 @@ Installation
|
||||||
|
|
||||||
Use go get.
|
Use go get.
|
||||||
|
|
||||||
go get git.ningdatech.com/ningda/gin_valid/go-playground/validator/v10
|
go get git.hpds.cc/Component/gin_valid/go-playground/validator/v10
|
||||||
|
|
||||||
Then import the validator package into your own code.
|
Then import the validator package into your own code.
|
||||||
|
|
||||||
import "git.ningdatech.com/ningda/gin_valid/go-playground/validator/v10"
|
import "git.hpds.cc/Component/gin_valid/go-playground/validator/v10"
|
||||||
|
|
||||||
Error Return Value
|
Error Return Value
|
||||||
-------
|
-------
|
||||||
|
|
|
@ -6,7 +6,7 @@ import (
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
ut "git.ningdatech.com/ningda/gin_valid/go-playground/universal-translator"
|
ut "git.hpds.cc/Component/gin_valid/go-playground/universal-translator"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -58,27 +58,27 @@ func (ve ValidationErrors) Error() string {
|
||||||
|
|
||||||
// yang 修改
|
// yang 修改
|
||||||
// Translate translates all of the ValidationErrors
|
// 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++ {
|
// for i := 0; i < len(ve); i++ {
|
||||||
// fe = ve[i].(*fieldError)
|
// fe = ve[i].(*fieldError)
|
||||||
//
|
//
|
||||||
// // // in case an Anonymous struct was used, ensure that the key
|
// // // in case an Anonymous struct was used, ensure that the key
|
||||||
// // // would be 'Username' instead of ".Username"
|
// // // would be 'Username' instead of ".Username"
|
||||||
// // if len(fe.ns) > 0 && fe.ns[:1] == "." {
|
// // if len(fe.ns) > 0 && fe.ns[:1] == "." {
|
||||||
// // trans[fe.ns[1:]] = fe.Translate(ut)
|
// // trans[fe.ns[1:]] = fe.Translate(ut)
|
||||||
// // continue
|
// // continue
|
||||||
// // }
|
// // }
|
||||||
//
|
//
|
||||||
// trans[fe.ns] = fe.Translate(ut)
|
// trans[fe.ns] = fe.Translate(ut)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return trans
|
||||||
// }
|
// }
|
||||||
//
|
|
||||||
// return trans
|
|
||||||
//}
|
|
||||||
type TransValidError struct {
|
type TransValidError struct {
|
||||||
ErrorString string
|
ErrorString string
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package validators
|
package validators
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"git.ningdatech.com/ningda/gin_valid/go-playground/validator/v10"
|
"git.hpds.cc/Component/gin_valid/go-playground/validator/v10"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package validators
|
package validators
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"git.ningdatech.com/ningda/gin_valid/go-playground/validator/v10"
|
"git.hpds.cc/Component/gin_valid/go-playground/validator/v10"
|
||||||
"github.com/go-playground/assert/v2"
|
"github.com/go-playground/assert/v2"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package validator
|
package validator
|
||||||
|
|
||||||
import ut "git.ningdatech.com/ningda/gin_valid/go-playground/universal-translator"
|
import ut "git.hpds.cc/Component/gin_valid/go-playground/universal-translator"
|
||||||
|
|
||||||
// TranslationFunc is the function type used to register or override
|
// TranslationFunc is the function type used to register or override
|
||||||
// custom translations
|
// custom translations
|
||||||
|
|
|
@ -8,9 +8,9 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.ningdatech.com/ningda/gin_valid/go-playground/locales"
|
"git.hpds.cc/Component/gin_valid/go-playground/locales"
|
||||||
ut "git.ningdatech.com/ningda/gin_valid/go-playground/universal-translator"
|
ut "git.hpds.cc/Component/gin_valid/go-playground/universal-translator"
|
||||||
"git.ningdatech.com/ningda/gin_valid/go-playground/validator/v10"
|
"git.hpds.cc/Component/gin_valid/go-playground/validator/v10"
|
||||||
)
|
)
|
||||||
|
|
||||||
// RegisterDefaultTranslations registers a set of default translations
|
// RegisterDefaultTranslations registers a set of default translations
|
||||||
|
|
|
@ -8,9 +8,9 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.ningdatech.com/ningda/gin_valid/go-playground/locales"
|
"git.hpds.cc/Component/gin_valid/go-playground/locales"
|
||||||
ut "git.ningdatech.com/ningda/gin_valid/go-playground/universal-translator"
|
ut "git.hpds.cc/Component/gin_valid/go-playground/universal-translator"
|
||||||
"git.ningdatech.com/ningda/gin_valid/go-playground/validator/v10"
|
"git.hpds.cc/Component/gin_valid/go-playground/validator/v10"
|
||||||
)
|
)
|
||||||
|
|
||||||
// RegisterDefaultTranslations registers a set of default translations
|
// RegisterDefaultTranslations registers a set of default translations
|
||||||
|
|
|
@ -8,9 +8,9 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.ningdatech.com/ningda/gin_valid/go-playground/locales"
|
"git.hpds.cc/Component/gin_valid/go-playground/locales"
|
||||||
ut "git.ningdatech.com/ningda/gin_valid/go-playground/universal-translator"
|
ut "git.hpds.cc/Component/gin_valid/go-playground/universal-translator"
|
||||||
"git.ningdatech.com/ningda/gin_valid/go-playground/validator/v10"
|
"git.hpds.cc/Component/gin_valid/go-playground/validator/v10"
|
||||||
)
|
)
|
||||||
|
|
||||||
// RegisterDefaultTranslations registers a set of default translations
|
// RegisterDefaultTranslations registers a set of default translations
|
||||||
|
|
|
@ -8,9 +8,9 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.ningdatech.com/ningda/gin_valid/go-playground/locales"
|
"git.hpds.cc/Component/gin_valid/go-playground/locales"
|
||||||
ut "git.ningdatech.com/ningda/gin_valid/go-playground/universal-translator"
|
ut "git.hpds.cc/Component/gin_valid/go-playground/universal-translator"
|
||||||
"git.ningdatech.com/ningda/gin_valid/go-playground/validator/v10"
|
"git.hpds.cc/Component/gin_valid/go-playground/validator/v10"
|
||||||
)
|
)
|
||||||
|
|
||||||
// RegisterDefaultTranslations registers a set of default translations
|
// RegisterDefaultTranslations registers a set of default translations
|
||||||
|
|
|
@ -8,9 +8,9 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.ningdatech.com/ningda/gin_valid/go-playground/locales"
|
"git.hpds.cc/Component/gin_valid/go-playground/locales"
|
||||||
ut "git.ningdatech.com/ningda/gin_valid/go-playground/universal-translator"
|
ut "git.hpds.cc/Component/gin_valid/go-playground/universal-translator"
|
||||||
"git.ningdatech.com/ningda/gin_valid/go-playground/validator/v10"
|
"git.hpds.cc/Component/gin_valid/go-playground/validator/v10"
|
||||||
)
|
)
|
||||||
|
|
||||||
// RegisterDefaultTranslations registers a set of default translations
|
// RegisterDefaultTranslations registers a set of default translations
|
||||||
|
|
|
@ -8,9 +8,9 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.ningdatech.com/ningda/gin_valid/go-playground/locales"
|
"git.hpds.cc/Component/gin_valid/go-playground/locales"
|
||||||
ut "git.ningdatech.com/ningda/gin_valid/go-playground/universal-translator"
|
ut "git.hpds.cc/Component/gin_valid/go-playground/universal-translator"
|
||||||
"git.ningdatech.com/ningda/gin_valid/go-playground/validator/v10"
|
"git.hpds.cc/Component/gin_valid/go-playground/validator/v10"
|
||||||
)
|
)
|
||||||
|
|
||||||
// RegisterDefaultTranslations registers a set of default translations
|
// RegisterDefaultTranslations registers a set of default translations
|
||||||
|
|
|
@ -8,9 +8,9 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.ningdatech.com/ningda/gin_valid/go-playground/locales"
|
"git.hpds.cc/Component/gin_valid/go-playground/locales"
|
||||||
ut "git.ningdatech.com/ningda/gin_valid/go-playground/universal-translator"
|
ut "git.hpds.cc/Component/gin_valid/go-playground/universal-translator"
|
||||||
"git.ningdatech.com/ningda/gin_valid/go-playground/validator/v10"
|
"git.hpds.cc/Component/gin_valid/go-playground/validator/v10"
|
||||||
)
|
)
|
||||||
|
|
||||||
// RegisterDefaultTranslations registers a set of default translations
|
// RegisterDefaultTranslations registers a set of default translations
|
||||||
|
|
|
@ -8,9 +8,9 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.ningdatech.com/ningda/gin_valid/go-playground/locales"
|
"git.hpds.cc/Component/gin_valid/go-playground/locales"
|
||||||
ut "git.ningdatech.com/ningda/gin_valid/go-playground/universal-translator"
|
ut "git.hpds.cc/Component/gin_valid/go-playground/universal-translator"
|
||||||
"git.ningdatech.com/ningda/gin_valid/go-playground/validator/v10"
|
"git.hpds.cc/Component/gin_valid/go-playground/validator/v10"
|
||||||
)
|
)
|
||||||
|
|
||||||
// RegisterDefaultTranslations registers a set of default translations
|
// RegisterDefaultTranslations registers a set of default translations
|
||||||
|
|
|
@ -8,9 +8,9 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.ningdatech.com/ningda/gin_valid/go-playground/locales"
|
"git.hpds.cc/Component/gin_valid/go-playground/locales"
|
||||||
ut "git.ningdatech.com/ningda/gin_valid/go-playground/universal-translator"
|
ut "git.hpds.cc/Component/gin_valid/go-playground/universal-translator"
|
||||||
"git.ningdatech.com/ningda/gin_valid/go-playground/validator/v10"
|
"git.hpds.cc/Component/gin_valid/go-playground/validator/v10"
|
||||||
)
|
)
|
||||||
|
|
||||||
// RegisterDefaultTranslations registers a set of default translations
|
// RegisterDefaultTranslations registers a set of default translations
|
||||||
|
|
|
@ -8,9 +8,9 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.ningdatech.com/ningda/gin_valid/go-playground/locales"
|
"git.hpds.cc/Component/gin_valid/go-playground/locales"
|
||||||
ut "git.ningdatech.com/ningda/gin_valid/go-playground/universal-translator"
|
ut "git.hpds.cc/Component/gin_valid/go-playground/universal-translator"
|
||||||
"git.ningdatech.com/ningda/gin_valid/go-playground/validator/v10"
|
"git.hpds.cc/Component/gin_valid/go-playground/validator/v10"
|
||||||
)
|
)
|
||||||
|
|
||||||
// RegisterDefaultTranslations registers a set of default translations
|
// RegisterDefaultTranslations registers a set of default translations
|
||||||
|
|
|
@ -8,9 +8,9 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.ningdatech.com/ningda/gin_valid/go-playground/locales"
|
"git.hpds.cc/Component/gin_valid/go-playground/locales"
|
||||||
ut "git.ningdatech.com/ningda/gin_valid/go-playground/universal-translator"
|
ut "git.hpds.cc/Component/gin_valid/go-playground/universal-translator"
|
||||||
"git.ningdatech.com/ningda/gin_valid/go-playground/validator/v10"
|
"git.hpds.cc/Component/gin_valid/go-playground/validator/v10"
|
||||||
)
|
)
|
||||||
|
|
||||||
// RegisterDefaultTranslations registers a set of default translations
|
// RegisterDefaultTranslations registers a set of default translations
|
||||||
|
|
|
@ -8,9 +8,9 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.ningdatech.com/ningda/gin_valid/go-playground/locales"
|
"git.hpds.cc/Component/gin_valid/go-playground/locales"
|
||||||
ut "git.ningdatech.com/ningda/gin_valid/go-playground/universal-translator"
|
ut "git.hpds.cc/Component/gin_valid/go-playground/universal-translator"
|
||||||
"git.ningdatech.com/ningda/gin_valid/go-playground/validator/v10"
|
"git.hpds.cc/Component/gin_valid/go-playground/validator/v10"
|
||||||
)
|
)
|
||||||
|
|
||||||
// RegisterDefaultTranslations registers a set of default translations
|
// RegisterDefaultTranslations registers a set of default translations
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
ut "git.ningdatech.com/ningda/gin_valid/go-playground/universal-translator"
|
ut "git.hpds.cc/Component/gin_valid/go-playground/universal-translator"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -142,13 +142,13 @@ func (v *Validate) SetTagName(name string) {
|
||||||
//
|
//
|
||||||
// eg. to use the names which have been specified for JSON representations of structs, rather than normal Go field names:
|
// eg. to use the names which have been specified for JSON representations of structs, rather than normal Go field names:
|
||||||
//
|
//
|
||||||
// validate.RegisterTagNameFunc(func(fld reflect.StructField) string {
|
// validate.RegisterTagNameFunc(func(fld reflect.StructField) string {
|
||||||
// name := strings.SplitN(fld.Tag.Get("json"), ",", 2)[0]
|
// name := strings.SplitN(fld.Tag.Get("json"), ",", 2)[0]
|
||||||
// if name == "-" {
|
// if name == "-" {
|
||||||
// return ""
|
// return ""
|
||||||
// }
|
// }
|
||||||
// return name
|
// return name
|
||||||
// })
|
// })
|
||||||
func (v *Validate) RegisterTagNameFunc(fn TagNameFunc) {
|
func (v *Validate) RegisterTagNameFunc(fn TagNameFunc) {
|
||||||
v.tagNameFunc = fn
|
v.tagNameFunc = fn
|
||||||
v.hasTagNameFunc = true
|
v.hasTagNameFunc = true
|
||||||
|
|
Loading…
Reference in New Issue