🔒 Stop Exposing Emails, Phones & Cards in Logs — Meet `validata-py`
Source: Dev.to
Introduction
validata-py is a lightweight, privacy‑focused Python library that provides simple, consistent, production‑ready data masking. It helps prevent sensitive information—such as emails, phone numbers, and card numbers—from leaking into logs, monitoring systems, or debug payloads.
Installation
pip install validata-py
Usage
Import
from validata_py import Veil
Email masking
Veil.shield_email("alice@example.com")
# a****@e******.com
Phone masking
Veil.shield_phone("+91 98765-43210")
# +91 *****-3210
Card masking
Veil.shield_card("4111 1111 1111 1111")
# **** **** **** 1111
PII scrubbing in free‑form text
Veil.scrub_text("Contact me at dev@example.com or 9876543210")
# Contact me at [EMAIL] or [PHONE]
Payload shielding
payload = {
"name": "Priya Sharma",
"email": "priya@example.com",
"mobile": "+91-98765-43210",
"salary": 950000,
}
blueprint = {
"name": "text",
"email": "email",
"mobile": "phone",
"salary": "zero",
}
masked = Veil.shield_payload(payload, blueprint)
print(masked)
Output
{
"name": "P**********a",
"email": "p****@e******.com",
"mobile": "+91-*****-3210",
"salary": 0
}
Generic covering
Veil.cover("secret-token", from_index=3)
# sec*********
Key Features
- Zero dependencies – works out of the box.
- Single import, single class –
Veil. - Consistent API for emails, phones, cards, and arbitrary text.
- Formatting‑preserving masking (e.g., retains spaces, dashes).
- Payload‑level shielding with a simple blueprint schema.
- Production‑ready and GDPR‑friendly.
Common Use Cases
- Backend APIs
- Logging systems
- GDPR / privacy workflows
- Audit pipelines
- Debug payload sanitization
- Security tooling
- Internal admin dashboards
- Data anonymization
Extensibility & Future Ideas
The library is designed to be extended. Planned or explored features include:
- PAN (Primary Account Number) masking
- Aadhaar masking
- IBAN masking
- Custom regex strategies
- Async processing
- FastAPI middleware integration
- Structured log sanitizers
Contributions and ideas from the community are welcome.
Contributing
validata-py is an early open‑source release. Feedback, feature ideas, bug reports, and pull requests are appreciated.
- GitHub repository: https://github.com/vishnusharma511/validata-py
- PyPI package: https://pypi.org/project/validata-py/
If you work with APIs, logs, privacy tooling, or security systems, feel free to share how you would use the library. 🚀