Skip to content

Commit

Permalink
Update errors.go (#975)
Browse files Browse the repository at this point in the history
**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
  • Loading branch information
maltsev25 committed Jan 14, 2024
1 parent 84254ae commit add493f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions errors.go
Expand Up @@ -257,15 +257,19 @@ func (fe *fieldError) Error() string {
// NOTE: if no registered translation can be found, it returns the original
// untranslated error message.
func (fe *fieldError) Translate(ut ut.Translator) string {
var fn TranslationFunc

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

fn, ok := m[fe.tag]
fn, ok = m[fe.tag]
if !ok {
return fe.Error()
fn, ok = m[fe.actualTag]
if !ok {
return fe.Error()
}
}

return fn(ut, fe)
Expand Down

0 comments on commit add493f

Please sign in to comment.