lanka-validations - v2.1.0
    Preparing search index...

    Function translateValidationCode

    • Returns the message for a validation code in the given language. Unknown codes fall back to a generic "validation failed" message.

      Parameters

      • code: string

        Validation code, such as 'NIC_INVALID_FORMAT'.

      • locale: ValidationLocale = 'en'

        'en' (default), 'si', or 'ta'.

      • Optionaloverrides: Readonly<Record<string, string>>

        Optional messages keyed by code that replace the built-in text.

      Returns string

      The message for the code.

      translateValidationCode('NIC_INVALID_FORMAT'); // 'NIC format is invalid.'
      translateValidationCode('NIC_INVALID_FORMAT', 'en', { NIC_INVALID_FORMAT: 'Check your NIC' }); // 'Check your NIC'