Skip to content

Commit add493f

Browse files
authored
Update errors.go (#975)
**fix for aliases** translate work incorrect for registered aliases ## Fixes Or Enhances **Make sure that you've checked the boxes below before you submit PR:** - [x] Tests exist or have been written that cover this particular change. @go-playground/validator-maintainers
1 parent 84254ae commit add493f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

errors.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,15 +257,19 @@ func (fe *fieldError) Error() string {
257257
// NOTE: if no registered translation can be found, it returns the original
258258
// untranslated error message.
259259
func (fe *fieldError) Translate(ut ut.Translator) string {
260+
var fn TranslationFunc
260261

261262
m, ok := fe.v.transTagFunc[ut]
262263
if !ok {
263264
return fe.Error()
264265
}
265266

266-
fn, ok := m[fe.tag]
267+
fn, ok = m[fe.tag]
267268
if !ok {
268-
return fe.Error()
269+
fn, ok = m[fe.actualTag]
270+
if !ok {
271+
return fe.Error()
272+
}
269273
}
270274

271275
return fn(ut, fe)

0 commit comments

Comments
 (0)