🔒 Stop Exposing Emails, Phones & Cards in Logs — Meet `validata-py`

Published: (May 8, 2026 at 02:48 AM EDT)
2 min read
Source: Dev.to

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 classVeil.
  • 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.

If you work with APIs, logs, privacy tooling, or security systems, feel free to share how you would use the library. 🚀

0 views
Back to Blog

Related posts

Read more »

str() vs repr() vs print() in Python

Overview When learning Python you encounter three built‑in utilities that often look similar: - str - repr - print At first they may seem to do the same thing—...