go-playground/validator · error
tag '%s' không thể dùng trên kiểu struct
Error message
tag '%s' không thể dùng trên kiểu struct
What it means
Raised inside the Vietnamese 'lt' translation registration when the field being translated is a struct. lt only applies to numeric kinds, strings, slices/maps/arrays (length) and time.Time; a generic struct has no 'less than' meaning, so the translator stops with this error. It fires when a struct field other than time.Time carries the lt tag.
Source
Thrown at translations/vi/vi.go:416
case reflect.Slice, reflect.Map, reflect.Array:
var c string
err = fn()
if err != nil {
goto END
}
c, err = ut.C("lt-items-item", f64, digits, ut.FmtNumber(f64, digits))
if err != nil {
goto END
}
t, err = ut.T("lt-items", fe.Field(), c)
case reflect.Struct:
if fe.Type() != reflect.TypeOf(time.Time{}) {
err = fmt.Errorf("tag '%s' không thể dùng trên kiểu struct", fe.Tag())
goto END
}
t, err = ut.T("lt-datetime", fe.Field())
default:
err = fn()
if err != nil {
goto END
}
t, err = ut.T("lt-number", fe.Field(), ut.FmtNumber(f64, digits))
}
END:
if err != nil {
fmt.Printf("cảnh báo: lỗi chuyển ngữ FieldError: %s", err)
return fe.(error).Error()View on GitHub (pinned to facf128d2e)
Solutions
- Remove the lt tag from the struct field
- Apply lt to comparable inner fields instead
- Use RegisterStructValidation for custom struct-wide rules
- Verify datetime fields are exactly of type time.Time
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at translations/vi/vi.go:416 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of go-playground/validator@facf128d2e (2026-09-02).
Data as JSON: /api/errors/fac3656cb72cada0.
Report an issue: GitHub.