AdonisJS API
    Preparing search index...

    VineJS messages provider to read validation messages from I18n translations. Provides field name translations and validation error messages with fallback support.

    const i18n = new I18n('en', emitter, manager)
    const provider = new I18nMessagesProvider('validation', i18n)
    const message = provider.getMessage('The field is required', 'required', field)

    Implements

    • MessagesProviderContact
    Index
    • Retrieves and formats a validation message with field-specific and rule-specific fallbacks

      Message resolution priority:

      1. Field-specific message: {prefix}.messages.{fieldPath}.{rule}
      2. Rule-specific message: {prefix}.messages.{rule}
      3. Default message with interpolation

      Parameters

      • defaultMessage: string

        The default validation message to use as final fallback

      • rule: string

        The validation rule name (e.g., 'required', 'email')

      • field: FieldContext

        The field context containing name and path information

      • Optionalmeta: Record<string, any>

        Optional metadata for message interpolation (e.g., otherField, min, max)

      Returns string

      Formatted validation message string

      const message = provider.getMessage(
      'The field is required',
      'required',
      { name: 'email', wildCardPath: 'user.email' },
      { min: 5 }
      )
    • Translates a field name using the configured prefix.

      Parameters

      • name: string | number

      Returns string | number