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

    Function formatNic

    • Formats a Sri Lankan NIC cleanly.

      Parameters

      • nic: unknown

        NIC number, old or new format.

      • Optionalstyle: NicFormatStyle

        Output style: 'old', 'new', 'spaced-old', or 'spaced-new'. Defaults to the input's own format.

      • Optionaloptions: NicOptions

        Optional { referenceDate } used for age and future-date checks. Defaults to today.

      Returns string | null

      The formatted NIC, or null if the input is invalid.

      formatNic('921234567v'); // '921234567V'
      formatNic('921234567V', 'new'); // '199212304567'
      formatNic('199212304567', 'spaced-new'); // '1992 123 0456 7'