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

    Function convertNewToOldNic

    • Converts a 12-digit New Sri Lankan NIC into a 10-character Old NIC if the birth year is between 1900 and 1999. Note: If the 4-digit serial does not start with '0', conversion is strictly lossy/incompatible. Format: YY + DDD + SSS + C + (V or X)

      Parameters

      • newNic: unknown

        New-format 12-digit NIC.

      • Optionaloptions: NicOptions & { isVoter?: boolean }

        Optional { referenceDate, isVoter }. isVoter: false produces the X suffix; the default is V.

      Returns string | null

      The equivalent old-format NIC, or null if the input is invalid or the holder was not born between 1900 and 1999.

      convertNewToOldNic('199212304567'); // '921234567V'
      convertNewToOldNic('199212304567', { isVoter: false }); // '921234567X'
      convertNewToOldNic('200012304567'); // null