Skip to content

Proper Internationalization(i18n) Support #357

@gk-wino

Description

@gk-wino

Summary
Fastest-Validator currently doesn’t provide a clean or native way to define internationalized validation messages and dynamically switch between locales based on a locale option. As a result, applications that need multi-language support must implement custom workarounds, message maps, or manual message overrides, which becomes messy and difficult to maintain.

Problem

  • Validation messages are static and tied directly to rule definitions.
  • There is no built-in mechanism to specify message strings per locale.
  • There is no global or per-validation locale option that automatically selects the correct localized message.
  • Implementing i18n requires writing custom logic that defeats the purpose of using a structured validation library.

What’s Needed

  1. Ability to define messages in a multi-locale format, for example:

    messages: {
      required: {
        en: "The field '{field}' is required.",
        fr: "Le champ '{field}' est obligatoire.",
        sw: "Sehemu ya '{field}' inahitajika."
      }
    }
  2. A validator-level or call-level locale option:

    const validate = v.compile(schema, { locale: "fr" });

    or:

    v.validate(data, schema, { locale: "fr" });
  3. Automatic fallback (e.g., fallback to en if the specified locale is missing).

Why It Matters
Proper i18n support is essential for real-world applications that serve users across different regions. Without it, developers are forced to duplicate schemas or build their own localization systems around the validator.

Proposed Outcome
A first-class internationalization API that allows developers to define localized messages cleanly and select the active locale at runtime.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions