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

    Function normalizePostalCode

    • Normalizes a postal code into a 5-digit string (e.g. 100 -> '00100').

      Parameters

      • input: unknown

        Postal code as text or an integer. Shorter codes are padded to five digits.

      Returns string | null

      The five-digit code, or null if the input is not one to five digits.

      normalizePostalCode(100); // '00100'
      normalizePostalCode('20000'); // '20000'
      normalizePostalCode('2000A'); // null