Skip to content

[Bug]: Nil pointer dereference in Arabic translations #1385

@blacksud0

Description

@blacksud0

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 +0x3ac

Environment & 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

  1. Initialize a validator with Arabic language support
  2. Register default Arabic translations
  3. 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"`
	}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions