maskPII

fun maskPII(value: Any?): String(source)

Partially masks a value while preserving some characters for debugging.

Used for parameters annotated with @PII (Personally Identifiable Information).

Masking behavior:

  • null: Returns "null"

  • Empty string: Returns ""

  • String with 4 or fewer chars: Returns "****"

  • Email (contains @): Masks local part, preserves domain (e.g., "jo***@example.com")

  • Other strings: Shows first 2 and last 2 chars (e.g., "Jo***oe" for "JohnDoe")

  • Other types: Converts to string and masks

Return

Partially masked string representation

Parameters

value

The value to mask