|
|
|
@ -16,7 +16,6 @@ import ( |
|
|
|
|
// RegisterDefaultTranslations registers a set of default translations
|
|
|
|
|
// for all built in tag's in validator; you may add your own as desired.
|
|
|
|
|
func RegisterDefaultTranslations(v *validator.Validate, trans ut.Translator) (err error) { |
|
|
|
|
|
|
|
|
|
translations := []struct { |
|
|
|
|
tag string |
|
|
|
|
translation string |
|
|
|
@ -62,7 +61,6 @@ func RegisterDefaultTranslations(v *validator.Validate, trans ut.Translator) (er |
|
|
|
|
{ |
|
|
|
|
tag: "len", |
|
|
|
|
customRegisFunc: func(ut ut.Translator) (err error) { |
|
|
|
|
|
|
|
|
|
if err = ut.Add("len-string", "{0}길이는{1}이어야합니다", false); err != nil { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
@ -91,10 +89,8 @@ func RegisterDefaultTranslations(v *validator.Validate, trans ut.Translator) (er |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
customTransFunc: func(ut ut.Translator, fe validator.FieldError) string { |
|
|
|
|
|
|
|
|
|
var err error |
|
|
|
|
var t string |
|
|
|
|
|
|
|
|
@ -153,7 +149,6 @@ func RegisterDefaultTranslations(v *validator.Validate, trans ut.Translator) (er |
|
|
|
|
{ |
|
|
|
|
tag: "min", |
|
|
|
|
customRegisFunc: func(ut ut.Translator) (err error) { |
|
|
|
|
|
|
|
|
|
if err = ut.Add("min-string", "{0}길이는{1}이상이어야합니다", false); err != nil { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
@ -182,10 +177,8 @@ func RegisterDefaultTranslations(v *validator.Validate, trans ut.Translator) (er |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
customTransFunc: func(ut ut.Translator, fe validator.FieldError) string { |
|
|
|
|
|
|
|
|
|
var err error |
|
|
|
|
var t string |
|
|
|
|
|
|
|
|
@ -208,7 +201,6 @@ func RegisterDefaultTranslations(v *validator.Validate, trans ut.Translator) (er |
|
|
|
|
|
|
|
|
|
switch kind { |
|
|
|
|
case reflect.String: |
|
|
|
|
|
|
|
|
|
var c string |
|
|
|
|
|
|
|
|
|
c, err = ut.C("min-string-character", f64, digits, ut.FmtNumber(f64, digits)) |
|
|
|
@ -244,7 +236,6 @@ func RegisterDefaultTranslations(v *validator.Validate, trans ut.Translator) (er |
|
|
|
|
{ |
|
|
|
|
tag: "max", |
|
|
|
|
customRegisFunc: func(ut ut.Translator) (err error) { |
|
|
|
|
|
|
|
|
|
if err = ut.Add("max-string", "{0}길이는{1}을초과할수없습니다", false); err != nil { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
@ -273,10 +264,8 @@ func RegisterDefaultTranslations(v *validator.Validate, trans ut.Translator) (er |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
customTransFunc: func(ut ut.Translator, fe validator.FieldError) string { |
|
|
|
|
|
|
|
|
|
var err error |
|
|
|
|
var t string |
|
|
|
|
|
|
|
|
@ -336,36 +325,17 @@ func RegisterDefaultTranslations(v *validator.Validate, trans ut.Translator) (er |
|
|
|
|
tag: "eq", |
|
|
|
|
translation: "{0}은{1}과같지않습니다", |
|
|
|
|
override: false, |
|
|
|
|
customTransFunc: func(ut ut.Translator, fe validator.FieldError) string { |
|
|
|
|
|
|
|
|
|
t, err := ut.T(fe.Tag(), fe.Field(), fe.Param()) |
|
|
|
|
if err != nil { |
|
|
|
|
fmt.Printf("경고: 번역필드오류: %#v", fe) |
|
|
|
|
return fe.(error).Error() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return t |
|
|
|
|
}, |
|
|
|
|
customTransFunc: customTransFuncV1, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
tag: "ne", |
|
|
|
|
translation: "{0}은{1}과같지않아야합니다", |
|
|
|
|
override: false, |
|
|
|
|
customTransFunc: func(ut ut.Translator, fe validator.FieldError) string { |
|
|
|
|
|
|
|
|
|
t, err := ut.T(fe.Tag(), fe.Field(), fe.Param()) |
|
|
|
|
if err != nil { |
|
|
|
|
fmt.Printf("경고: 번역필드오류: %#v", fe) |
|
|
|
|
return fe.(error).Error() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return t |
|
|
|
|
}, |
|
|
|
|
customTransFunc: customTransFuncV1, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
tag: "lt", |
|
|
|
|
customRegisFunc: func(ut ut.Translator) (err error) { |
|
|
|
|
|
|
|
|
|
if err = ut.Add("lt-string", "{0}길이는{1}보다작아야합니다", false); err != nil { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
@ -399,10 +369,8 @@ func RegisterDefaultTranslations(v *validator.Validate, trans ut.Translator) (er |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
customTransFunc: func(ut ut.Translator, fe validator.FieldError) string { |
|
|
|
|
|
|
|
|
|
var err error |
|
|
|
|
var t string |
|
|
|
|
var f64 float64 |
|
|
|
@ -410,7 +378,6 @@ func RegisterDefaultTranslations(v *validator.Validate, trans ut.Translator) (er |
|
|
|
|
var kind reflect.Kind |
|
|
|
|
|
|
|
|
|
fn := func() (err error) { |
|
|
|
|
|
|
|
|
|
if idx := strings.Index(fe.Param(), "."); idx != -1 { |
|
|
|
|
digits = uint64(len(fe.Param()[idx+1:])) |
|
|
|
|
} |
|
|
|
@ -485,7 +452,6 @@ func RegisterDefaultTranslations(v *validator.Validate, trans ut.Translator) (er |
|
|
|
|
{ |
|
|
|
|
tag: "lte", |
|
|
|
|
customRegisFunc: func(ut ut.Translator) (err error) { |
|
|
|
|
|
|
|
|
|
if err = ut.Add("lte-string", "{0}길이는{1}을초과할수없습니다", false); err != nil { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
@ -529,7 +495,6 @@ func RegisterDefaultTranslations(v *validator.Validate, trans ut.Translator) (er |
|
|
|
|
var kind reflect.Kind |
|
|
|
|
|
|
|
|
|
fn := func() (err error) { |
|
|
|
|
|
|
|
|
|
if idx := strings.Index(fe.Param(), "."); idx != -1 { |
|
|
|
|
digits = uint64(len(fe.Param()[idx+1:])) |
|
|
|
|
} |
|
|
|
@ -604,7 +569,6 @@ func RegisterDefaultTranslations(v *validator.Validate, trans ut.Translator) (er |
|
|
|
|
{ |
|
|
|
|
tag: "gt", |
|
|
|
|
customRegisFunc: func(ut ut.Translator) (err error) { |
|
|
|
|
|
|
|
|
|
if err = ut.Add("gt-string", "{0}길이는{1}보다커야합니다", false); err != nil { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
@ -640,7 +604,6 @@ func RegisterDefaultTranslations(v *validator.Validate, trans ut.Translator) (er |
|
|
|
|
return |
|
|
|
|
}, |
|
|
|
|
customTransFunc: func(ut ut.Translator, fe validator.FieldError) string { |
|
|
|
|
|
|
|
|
|
var err error |
|
|
|
|
var t string |
|
|
|
|
var f64 float64 |
|
|
|
@ -722,7 +685,6 @@ func RegisterDefaultTranslations(v *validator.Validate, trans ut.Translator) (er |
|
|
|
|
{ |
|
|
|
|
tag: "gte", |
|
|
|
|
customRegisFunc: func(ut ut.Translator) (err error) { |
|
|
|
|
|
|
|
|
|
if err = ut.Add("gte-string", "{0}길이는{1}이상이어야합니다", false); err != nil { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
@ -758,7 +720,6 @@ func RegisterDefaultTranslations(v *validator.Validate, trans ut.Translator) (er |
|
|
|
|
return |
|
|
|
|
}, |
|
|
|
|
customTransFunc: func(ut ut.Translator, fe validator.FieldError) string { |
|
|
|
|
|
|
|
|
|
var err error |
|
|
|
|
var t string |
|
|
|
|
var f64 float64 |
|
|
|
@ -766,7 +727,6 @@ func RegisterDefaultTranslations(v *validator.Validate, trans ut.Translator) (er |
|
|
|
|
var kind reflect.Kind |
|
|
|
|
|
|
|
|
|
fn := func() (err error) { |
|
|
|
|
|
|
|
|
|
if idx := strings.Index(fe.Param(), "."); idx != -1 { |
|
|
|
|
digits = uint64(len(fe.Param()[idx+1:])) |
|
|
|
|
} |
|
|
|
@ -842,181 +802,73 @@ func RegisterDefaultTranslations(v *validator.Validate, trans ut.Translator) (er |
|
|
|
|
tag: "eqfield", |
|
|
|
|
translation: "{0}은{1}과같아야합니다", |
|
|
|
|
override: false, |
|
|
|
|
customTransFunc: func(ut ut.Translator, fe validator.FieldError) string { |
|
|
|
|
|
|
|
|
|
t, err := ut.T(fe.Tag(), fe.Field(), fe.Param()) |
|
|
|
|
if err != nil { |
|
|
|
|
log.Printf("경고: 번역필드오류: %#v", fe) |
|
|
|
|
return fe.(error).Error() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return t |
|
|
|
|
}, |
|
|
|
|
customTransFunc: customTransFuncV1, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
tag: "eqcsfield", |
|
|
|
|
translation: "{0}은{1}과같아야합니다", |
|
|
|
|
override: false, |
|
|
|
|
customTransFunc: func(ut ut.Translator, fe validator.FieldError) string { |
|
|
|
|
|
|
|
|
|
t, err := ut.T(fe.Tag(), fe.Field(), fe.Param()) |
|
|
|
|
if err != nil { |
|
|
|
|
log.Printf("경고: 번역필드오류: %#v", fe) |
|
|
|
|
return fe.(error).Error() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return t |
|
|
|
|
}, |
|
|
|
|
customTransFunc: customTransFuncV1, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
tag: "necsfield", |
|
|
|
|
translation: "{0}은{1}과같지않아야합니다", |
|
|
|
|
override: false, |
|
|
|
|
customTransFunc: func(ut ut.Translator, fe validator.FieldError) string { |
|
|
|
|
|
|
|
|
|
t, err := ut.T(fe.Tag(), fe.Field(), fe.Param()) |
|
|
|
|
if err != nil { |
|
|
|
|
log.Printf("경고: 번역필드오류: %#v", fe) |
|
|
|
|
return fe.(error).Error() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return t |
|
|
|
|
}, |
|
|
|
|
customTransFunc: customTransFuncV1, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
tag: "gtcsfield", |
|
|
|
|
translation: "{0}은{1}보다커야합니다", |
|
|
|
|
override: false, |
|
|
|
|
customTransFunc: func(ut ut.Translator, fe validator.FieldError) string { |
|
|
|
|
|
|
|
|
|
t, err := ut.T(fe.Tag(), fe.Field(), fe.Param()) |
|
|
|
|
if err != nil { |
|
|
|
|
log.Printf("경고: 번역필드오류: %#v", fe) |
|
|
|
|
return fe.(error).Error() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return t |
|
|
|
|
}, |
|
|
|
|
customTransFunc: customTransFuncV1, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
tag: "gtecsfield", |
|
|
|
|
translation: "{0}은{1}보다크거나같아야합니다", |
|
|
|
|
override: false, |
|
|
|
|
customTransFunc: func(ut ut.Translator, fe validator.FieldError) string { |
|
|
|
|
|
|
|
|
|
t, err := ut.T(fe.Tag(), fe.Field(), fe.Param()) |
|
|
|
|
if err != nil { |
|
|
|
|
log.Printf("경고: 번역필드오류: %#v", fe) |
|
|
|
|
return fe.(error).Error() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return t |
|
|
|
|
}, |
|
|
|
|
customTransFunc: customTransFuncV1, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
tag: "ltcsfield", |
|
|
|
|
translation: "{0}은{1}보다작아야합니다", |
|
|
|
|
override: false, |
|
|
|
|
customTransFunc: func(ut ut.Translator, fe validator.FieldError) string { |
|
|
|
|
|
|
|
|
|
t, err := ut.T(fe.Tag(), fe.Field(), fe.Param()) |
|
|
|
|
if err != nil { |
|
|
|
|
log.Printf("경고: 번역필드오류: %#v", fe) |
|
|
|
|
return fe.(error).Error() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return t |
|
|
|
|
}, |
|
|
|
|
customTransFunc: customTransFuncV1, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
tag: "ltecsfield", |
|
|
|
|
translation: "{0}은{1}보다작거나같아야합니다", |
|
|
|
|
override: false, |
|
|
|
|
customTransFunc: func(ut ut.Translator, fe validator.FieldError) string { |
|
|
|
|
|
|
|
|
|
t, err := ut.T(fe.Tag(), fe.Field(), fe.Param()) |
|
|
|
|
if err != nil { |
|
|
|
|
log.Printf("경고: 번역필드오류: %#v", fe) |
|
|
|
|
return fe.(error).Error() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return t |
|
|
|
|
}, |
|
|
|
|
customTransFunc: customTransFuncV1, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
tag: "nefield", |
|
|
|
|
translation: "{0}은{1}과같지않아야합니다", |
|
|
|
|
override: false, |
|
|
|
|
customTransFunc: func(ut ut.Translator, fe validator.FieldError) string { |
|
|
|
|
|
|
|
|
|
t, err := ut.T(fe.Tag(), fe.Field(), fe.Param()) |
|
|
|
|
if err != nil { |
|
|
|
|
log.Printf("경고: 번역필드오류: %#v", fe) |
|
|
|
|
return fe.(error).Error() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return t |
|
|
|
|
}, |
|
|
|
|
customTransFunc: customTransFuncV1, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
tag: "gtfield", |
|
|
|
|
translation: "{0}은{1}보다커야합니다", |
|
|
|
|
override: false, |
|
|
|
|
customTransFunc: func(ut ut.Translator, fe validator.FieldError) string { |
|
|
|
|
|
|
|
|
|
t, err := ut.T(fe.Tag(), fe.Field(), fe.Param()) |
|
|
|
|
if err != nil { |
|
|
|
|
log.Printf("경고: 번역필드오류: %#v", fe) |
|
|
|
|
return fe.(error).Error() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return t |
|
|
|
|
}, |
|
|
|
|
customTransFunc: customTransFuncV1, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
tag: "gtefield", |
|
|
|
|
translation: "{0}은{1}보다크거나같아야합니다", |
|
|
|
|
override: false, |
|
|
|
|
customTransFunc: func(ut ut.Translator, fe validator.FieldError) string { |
|
|
|
|
|
|
|
|
|
t, err := ut.T(fe.Tag(), fe.Field(), fe.Param()) |
|
|
|
|
if err != nil { |
|
|
|
|
log.Printf("경고: 번역필드오류: %#v", fe) |
|
|
|
|
return fe.(error).Error() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return t |
|
|
|
|
}, |
|
|
|
|
customTransFunc: customTransFuncV1, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
tag: "ltfield", |
|
|
|
|
translation: "{0}은{1}보다작아야합니다", |
|
|
|
|
override: false, |
|
|
|
|
customTransFunc: func(ut ut.Translator, fe validator.FieldError) string { |
|
|
|
|
|
|
|
|
|
t, err := ut.T(fe.Tag(), fe.Field(), fe.Param()) |
|
|
|
|
if err != nil { |
|
|
|
|
log.Printf("경고: 번역필드오류: %#v", fe) |
|
|
|
|
return fe.(error).Error() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return t |
|
|
|
|
}, |
|
|
|
|
customTransFunc: customTransFuncV1, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
tag: "ltefield", |
|
|
|
|
translation: "{0}은{1}보다작거나같아야합니다", |
|
|
|
|
override: false, |
|
|
|
|
customTransFunc: func(ut ut.Translator, fe validator.FieldError) string { |
|
|
|
|
|
|
|
|
|
t, err := ut.T(fe.Tag(), fe.Field(), fe.Param()) |
|
|
|
|
if err != nil { |
|
|
|
|
log.Printf("경고: 번역필드오류: %#v", fe) |
|
|
|
|
return fe.(error).Error() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return t |
|
|
|
|
}, |
|
|
|
|
customTransFunc: customTransFuncV1, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
tag: "alpha", |
|
|
|
@ -1107,121 +959,49 @@ func RegisterDefaultTranslations(v *validator.Validate, trans ut.Translator) (er |
|
|
|
|
tag: "contains", |
|
|
|
|
translation: "{0}은텍스트를포함해야합니다'{1}'", |
|
|
|
|
override: false, |
|
|
|
|
customTransFunc: func(ut ut.Translator, fe validator.FieldError) string { |
|
|
|
|
|
|
|
|
|
t, err := ut.T(fe.Tag(), fe.Field(), fe.Param()) |
|
|
|
|
if err != nil { |
|
|
|
|
log.Printf("경고: 번역필드오류: %#v", fe) |
|
|
|
|
return fe.(error).Error() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return t |
|
|
|
|
}, |
|
|
|
|
customTransFunc: customTransFuncV1, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
tag: "containsany", |
|
|
|
|
translation: "{0}은하나이상의문자를포함해야합니다'{1}'", |
|
|
|
|
override: false, |
|
|
|
|
customTransFunc: func(ut ut.Translator, fe validator.FieldError) string { |
|
|
|
|
|
|
|
|
|
t, err := ut.T(fe.Tag(), fe.Field(), fe.Param()) |
|
|
|
|
if err != nil { |
|
|
|
|
log.Printf("경고: 번역필드오류: %#v", fe) |
|
|
|
|
return fe.(error).Error() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return t |
|
|
|
|
}, |
|
|
|
|
customTransFunc: customTransFuncV1, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
tag: "containsrune", |
|
|
|
|
translation: "{0}은문자를포함해야합니다'{1}'", |
|
|
|
|
override: false, |
|
|
|
|
customTransFunc: func(ut ut.Translator, fe validator.FieldError) string { |
|
|
|
|
|
|
|
|
|
t, err := ut.T(fe.Tag(), fe.Field(), fe.Param()) |
|
|
|
|
if err != nil { |
|
|
|
|
log.Printf("경고: 번역필드오류: %#v", fe) |
|
|
|
|
return fe.(error).Error() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return t |
|
|
|
|
}, |
|
|
|
|
customTransFunc: customTransFuncV1, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
tag: "excludes", |
|
|
|
|
translation: "{0}은텍스트를포함할수없습니다'{1}'", |
|
|
|
|
override: false, |
|
|
|
|
customTransFunc: func(ut ut.Translator, fe validator.FieldError) string { |
|
|
|
|
|
|
|
|
|
t, err := ut.T(fe.Tag(), fe.Field(), fe.Param()) |
|
|
|
|
if err != nil { |
|
|
|
|
log.Printf("경고: 번역필드오류: %#v", fe) |
|
|
|
|
return fe.(error).Error() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return t |
|
|
|
|
}, |
|
|
|
|
customTransFunc: customTransFuncV1, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
tag: "excludesall", |
|
|
|
|
translation: "{0}은다음문자중하나를포함할수없습니다'{1}'", |
|
|
|
|
override: false, |
|
|
|
|
customTransFunc: func(ut ut.Translator, fe validator.FieldError) string { |
|
|
|
|
|
|
|
|
|
t, err := ut.T(fe.Tag(), fe.Field(), fe.Param()) |
|
|
|
|
if err != nil { |
|
|
|
|
log.Printf("경고: 번역필드오류: %#v", fe) |
|
|
|
|
return fe.(error).Error() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return t |
|
|
|
|
}, |
|
|
|
|
customTransFunc: customTransFuncV1, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
tag: "excludesrune", |
|
|
|
|
translation: "{0}은'{1}'을포함할수없습니다", |
|
|
|
|
override: false, |
|
|
|
|
customTransFunc: func(ut ut.Translator, fe validator.FieldError) string { |
|
|
|
|
|
|
|
|
|
t, err := ut.T(fe.Tag(), fe.Field(), fe.Param()) |
|
|
|
|
if err != nil { |
|
|
|
|
log.Printf("경고: 번역필드오류: %#v", fe) |
|
|
|
|
return fe.(error).Error() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return t |
|
|
|
|
}, |
|
|
|
|
customTransFunc: customTransFuncV1, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
tag: "endswith", |
|
|
|
|
translation: "{0}텍스트'{1}'으로끝나야합니다", |
|
|
|
|
override: false, |
|
|
|
|
customTransFunc: func(ut ut.Translator, fe validator.FieldError) string { |
|
|
|
|
|
|
|
|
|
t, err := ut.T(fe.Tag(), fe.Field(), fe.Param()) |
|
|
|
|
if err != nil { |
|
|
|
|
log.Printf("경고: 번역필드오류: %#v", fe) |
|
|
|
|
return fe.(error).Error() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return t |
|
|
|
|
}, |
|
|
|
|
customTransFunc: customTransFuncV1, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
tag: "startswith", |
|
|
|
|
translation: "{0}텍스트'{1}'으로시작해야합니다", |
|
|
|
|
override: false, |
|
|
|
|
customTransFunc: func(ut ut.Translator, fe validator.FieldError) string { |
|
|
|
|
|
|
|
|
|
t, err := ut.T(fe.Tag(), fe.Field(), fe.Param()) |
|
|
|
|
if err != nil { |
|
|
|
|
log.Printf("경고: 번역필드오류: %#v", fe) |
|
|
|
|
return fe.(error).Error() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return t |
|
|
|
|
}, |
|
|
|
|
customTransFunc: customTransFuncV1, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
tag: "isbn", |
|
|
|
@ -1397,14 +1177,7 @@ func RegisterDefaultTranslations(v *validator.Validate, trans ut.Translator) (er |
|
|
|
|
tag: "oneof", |
|
|
|
|
translation: "{0}은[{1}]중하나여야합니다", |
|
|
|
|
override: false, |
|
|
|
|
customTransFunc: func(ut ut.Translator, fe validator.FieldError) string { |
|
|
|
|
s, err := ut.T(fe.Tag(), fe.Field(), fe.Param()) |
|
|
|
|
if err != nil { |
|
|
|
|
log.Printf("경고: 번역필드오류: %#v", fe) |
|
|
|
|
return fe.(error).Error() |
|
|
|
|
} |
|
|
|
|
return s |
|
|
|
|
}, |
|
|
|
|
customTransFunc: customTransFuncV1, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
tag: "json", |
|
|
|
@ -1430,16 +1203,7 @@ func RegisterDefaultTranslations(v *validator.Validate, trans ut.Translator) (er |
|
|
|
|
tag: "datetime", |
|
|
|
|
translation: "{0}의형식은{1}이어야합니다", |
|
|
|
|
override: false, |
|
|
|
|
customTransFunc: func(ut ut.Translator, fe validator.FieldError) string { |
|
|
|
|
|
|
|
|
|
t, err := ut.T(fe.Tag(), fe.Field(), fe.Param()) |
|
|
|
|
if err != nil { |
|
|
|
|
log.Printf("경고: 번역필드오류: %#v", fe) |
|
|
|
|
return fe.(error).Error() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return t |
|
|
|
|
}, |
|
|
|
|
customTransFunc: customTransFuncV1, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
tag: "boolean", |
|
|
|
@ -1449,7 +1213,6 @@ func RegisterDefaultTranslations(v *validator.Validate, trans ut.Translator) (er |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for _, t := range translations { |
|
|
|
|
|
|
|
|
|
if t.customTransFunc != nil && t.customRegisFunc != nil { |
|
|
|
|
|
|
|
|
|
err = v.RegisterTranslation(t.tag, trans, t.customRegisFunc, t.customTransFunc) |
|
|
|
@ -1475,26 +1238,28 @@ func RegisterDefaultTranslations(v *validator.Validate, trans ut.Translator) (er |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func registrationFunc(tag string, translation string, override bool) validator.RegisterTranslationsFunc { |
|
|
|
|
|
|
|
|
|
return func(ut ut.Translator) (err error) { |
|
|
|
|
|
|
|
|
|
if err = ut.Add(tag, translation, override); err != nil { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func translateFunc(ut ut.Translator, fe validator.FieldError) string { |
|
|
|
|
|
|
|
|
|
t, err := ut.T(fe.Tag(), fe.Field()) |
|
|
|
|
if err != nil { |
|
|
|
|
log.Printf("경고: 번역필드오류: %#v", fe) |
|
|
|
|
return fe.(error).Error() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return t |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func customTransFuncV1(ut ut.Translator, fe validator.FieldError) string { |
|
|
|
|
s, err := ut.T(fe.Tag(), fe.Field(), fe.Param()) |
|
|
|
|
if err != nil { |
|
|
|
|
log.Printf("경고: 번역필드오류: %#v", fe) |
|
|
|
|
return fe.(error).Error() |
|
|
|
|
} |
|
|
|
|
return s |
|
|
|
|
} |
|
|
|
|