Returns a masked representation of input using the spec's mask pattern.
input
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.
min(4, floor(numPlaceholders / 3))
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.
"***"
Document type whose mask pattern applies.
Raw or normalized document body.
A masked, display-safe string with separators preserved.
if code is not registered. Symmetric with hash/lastN.
code
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", "");// "***" Copy
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", "");// "***"
Returns a masked representation of
inputusing 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.