-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Labels
Description
What happened?
When using Arabic translations with the validator, a nil pointer dereference occurs in the translator. Line 177 (ar.go:177) C method during a struct validation especially (min or max) tags.
Error Stack Trace
runtime error: invalid memory address or nil pointer dereference
goroutine 16 [running]:
github.com/go-playground/universal-translator.(translator).C(0xc0004c0870, {0xc18a20, 0x11434d0}, 0x4020000000000000, 0x0, {0x1165f80, 0x1})
/home/blacksudo/go/pkg/mod/github.com/go-playground/universal-translator@v0.18.1/translator.go:335 +0xdf
github.com/go-playground/validator/v10/translations/ar.RegisterDefaultTranslations.func4({0x115a980, 0xc0004c0870}, {0x1150cb0, 0xc00044e510})
go/pkg/mod/github.com/go-playground/validator/v10@v10.15.4/translations/ar/ar.go:177 +0x3acEnvironment & Version
- Go version: 1.24
- echo web framework v4.13.3
- validator version: v10.15.4
- universal-translator version: v0.18.1
Steps to Reproduce
- Initialize a validator with Arabic language support
- Register default Arabic translations
- Attempt to validate a struct with validation tags eg. (min, max)
Example Code
Login struct {
Username string `json:"username" validate:"required,min=3,max=50"`
Password string `json:"password" validate:"required,min=8"`
}