Skip to content

Localized Validation Errors in Go

Valgo includes localization support for validation messages. You can switch locales, override message templates, and reuse localization options through a validation factory.

Localized errors matter when validation messages are shown directly to users. A backend can keep field names and rule names stable while returning messages in the user’s preferred language.

Valgo validation messages are generated from rule templates. You can configure those templates globally for a validation session or reuse them with a factory.

factory := v.NewFactory(
v.WithLocale("es"),
)
val := factory.Is(
v.String(input.Name, "name").Not().Blank(),
)

The validation result can still use stable field paths while the message text changes by locale. That is useful for APIs where clients depend on field keys like email, profile.name, or items[0].

For details, see Localized Go Validation Messages and the Localization cookbook.