I’m working with multiple entities (e.g., customers, leads, contacts), each containing phone numbers of varying lengths. I need to display masked versions of the phone numbers for privacy (e.g., in UI or logs), while still being able to access and use the original number for operations like click-to-dial.
Example Use Case:
- Displayed on screen: +1-*****3210
- Original value used for dialing: +1-9876543210
Requirements:
- Phone numbers can vary in length and format (some may include country codes).
- Masked version should:
- Preserve last 3–4 digits.
- Optionally keep prefix (e.g., +1).
- Original (unmasked) number must remain accessible for backend logic like click-to-dial.
- Must work across multiple entities consistently.
- Should avoid storing two versions of the number if possible—masking should be on-the-fly or display-only.
Questions:
- What is the best way to implement this masking logic (UI masking vs data masking)?
- How can I ensure the original number is still used for dialing while showing only a masked version in the UI?
- Are there recommended libraries, functions, or design patterns for this use case in [your tech stack]?
Any suggestions, best practices, or code examples would be greatly appreciated!