Metadata-Version: 2.4
Name: validata-py
Version: 1.0.2
Summary: Conceal sensitive data — strings, emails, phones, numbers, cards, payloads, and free text — with a single clean API.
Author-email: Vishnu Sharma <vishnusharma180999@gmail.com>
License: MIT
Project-URL: Homepage, https://github.com/vishnusharma511/validata-py
Project-URL: Issues, https://github.com/vishnusharma511/validata-py/issues
Keywords: privacy,masking,PII,GDPR,data-security,anonymize,concealment
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Security
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Provides-Extra: dev
Requires-Dist: pytest>=7; extra == "dev"

# validata-py

> Conceal sensitive data in Python — strings, emails, phone numbers, IDs, cards, payloads, and free text — with one import and one clean API.

[![Python](https://img.shields.io/pypi/pyversions/validata-py)](https://pypi.org/project/validata-py/)
[![PyPI Version](https://img.shields.io/pypi/v/validata-py)](https://pypi.org/project/validata-py/)
[![License](https://img.shields.io/pypi/l/validata-py)](LICENSE)

---

## Installation

```bash
pip install validata-py
```

---

## Why validata-py?

Most masking libraries solve only one problem:

- Email masking
- Card masking
- Regex scrubbing
- Payload anonymization

You end up combining multiple libraries with inconsistent APIs.

`validata-py` keeps everything in one lightweight package:

- One import
- One class
- Consistent API
- Zero dependencies
- Production-ready utilities
- Preserves formatting automatically

---

## Quick Start

```python
from validata_py import Veil

# Generic string masking
Veil.cover("order-REF-99812", from_index=10)
# "order-REF-*****"

# Email masking
Veil.shield_email("alice@example.com")
# "a****@e******.com"

# Phone masking
Veil.shield_phone("+91 98765-43210", expose_last=4)
# "+91 *****-3210"

# Number masking
Veil.shield_number(987654321, expose_first=3)
# "987******"

# Card masking
Veil.shield_card("4111 1111 1111 1111")
# "**** **** **** 1111"

# CPF masking
Veil.shield_cpf("123.456.789-01")
# "123.***.789-01"

# CNPJ masking
Veil.shield_cnpj("12.345.678/0001-99")
# "12.***.***/**01-99"
```

---

## Dictionary Payload Masking

```python
from validata_py import Veil

payload = {
    "name":   "Priya Sharma",
    "email":  "priya@example.com",
    "mobile": "+91-98765-43210",
    "salary": 950000,
    "pan":    "ABCDE1234F",
}

blueprint = {
    "name":   "text",
    "email":  "email",
    "mobile": "phone",
    "salary": "zero",
    "pan":    "drop",
}

Veil.shield_payload(payload, blueprint)
```

Output:

```python
{
    "name":   "P**********a",
    "email":  "p****@e******.com",
    "mobile": "+91-*****-3210",
    "salary": 0,
    "pan":    "**********",
}
```

---

## Free Text PII Scrubbing

```python
from validata_py import Veil

Veil.scrub_text(
    "Reach me at dev@example.com or +91 9876543210"
)

# "Reach me at [EMAIL] or [PHONE]"
```

---

# Features

- Generic string concealment
- Email masking
- Phone masking
- Card masking
- Integer masking
- CPF masking
- CNPJ masking
- Payload anonymization
- Regex-based PII detection
- Free-text scrubbing
- Preserves formatting characters
- No external dependencies
- Lightweight and fast

---

# Full API

## `Veil.cover(text, char="*", from_index=0, length=None)`

Mask part of any string.

```python
Veil.cover("secret-token", from_index=3)
# "sec*********"
```

---

## `Veil.shield_email(email, char="*", reveal_user=1, reveal_host=1)`

Mask email addresses.

```python
Veil.shield_email("alice@example.com")
# "a****@e******.com"
```

---

## `Veil.shield_phone(phone, char="*", expose_last=4)`

Mask phone numbers while preserving formatting.

```python
Veil.shield_phone("+91 98765-43210")
# "+91 *****-3210"
```

---

## `Veil.shield_number(value, char="*", expose_first=2)`

Mask integers.

```python
Veil.shield_number(987654321)
# "98*******"
```

---

## `Veil.shield_card(card_number, char="*", expose_last=4)`

Mask card numbers.

```python
Veil.shield_card("4111 1111 1111 1111")
# "**** **** **** 1111"
```

---

## `Veil.shield_cpf(cpf, char="*")`

Mask Brazilian CPF numbers.

---

## `Veil.shield_cnpj(cnpj, char="*")`

Mask Brazilian CNPJ numbers.

---

## `Veil.shield_payload(data, blueprint, in_place=False)`

Mask selected fields in dictionaries.

### Blueprint strategies

| Strategy | Description |
|---|---|
| `"text"` | Conceal middle text |
| `"email"` | Apply email masking |
| `"phone"` | Apply phone masking |
| `"card"` | Apply card masking |
| `"zero"` | Replace value with zero |
| `"scramble"` | Randomize digits |
| `"drop"` | Replace entire value |

---

## `Veil.scrub_text(text, ...)`

Automatically detect and scrub:

- Emails
- Phone numbers
- Card numbers

---

# Project Structure

```text
validata-py/
│
├── pyproject.toml
├── README.md
├── LICENSE
│
├── validata_py/
│   ├── __init__.py
│   └── veil.py
│
└── tests/
    └── test_veil.py
```

---

# Running Tests

Install development dependencies:

```bash
pip install pytest
```

Run tests:

```bash
pytest
```

---

# Requirements

- Python 3.8+

---

# License

MIT License

---

# Author

Vishnu Sharma
