nationid - v2.2.1
    Preparing search index...

    Function mask

    • Returns a masked representation of input using the spec's mask pattern.

      Reveal rule: min(4, floor(numPlaceholders / 3)) chars at the tail. So a 9-digit DUI reveals 3, a 14-digit CNPJ reveals 4, an 18-char CURP reveals 4.

      Stars only fall on placeholder positions; separators are preserved verbatim so the masked form is visually consistent with the formatted form.

      Returns "***" for empty/whitespace-only input.

      Parameters

      • code: DocumentTypeCode

        Document type whose mask pattern applies.

      • input: string

        Raw or normalized document body.

      Returns string

      A masked, display-safe string with separators preserved.

      if code is not registered. Symmetric with hash/lastN.

      import { mask } from "nationid/pii";

      mask("BR_CNPJ", "12345678000190");
      // "**.***.***/01-90" (separators kept; last 4 placeholders revealed)

      mask("MX_CURP", "GOMC850315HDFRRR07");
      // "**************RR07" (last 4 chars revealed)

      mask("SV_DUI", "");
      // "***"