schemaguard
Lightweight Schema Validator for Python
About
schemaguard is a lightweight Python library that allows you to define and validate schemas for Pandas DataFrames.
It helps ensure your data meets expected formats, types, and constraints before entering production pipelines, saving you time and reducing errors.
With schemaguard, you can:
- Define column types, nullability, uniqueness, regex patterns, and numeric bounds.
- Validate Pandas DataFrames against YAML or Python-based schemas.
- Version your schemas to track changes over time.
- Integrate easily into ETL pipelines, Airflow, or CI/CD workflows.
Features
- Column type validation (
int,float,str, etc.) - Null check (
not_null) - Uniqueness check (
unique) - Regex pattern matching (
regex) - Numeric bounds (
min_value,max_value) - Schema versioning
- YAML-based schema loader
- Lightweight and fast, ideal for small and large datasets.
Installation
You can install schemaguard via pip:
pip install schemaguard
Or install from source for development:
git clone https://github.com/inzamam1121/schemaguard.git
cd schemaguard
pip install -e .
Quick Start
1. Define a YAML schema
Create files/schema_v1.yml:
version: "1.0"
columns:
order_id:
type: int
not_null: true
unique: true
amount:
type: float
not_null: true
min: 0
max: 10000
email:
type: string
regex: "^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}$"
2. Validate your DataFrame
import pandas as pd
from schemaguard.loader.yaml_loader import load_schema_from_yaml
# Load schema
schema = load_schema_from_yaml("files/schema_v1.yml")
# Load data
df = pd.read_csv("files/data.csv")
# Validate
report = schema.validate(df, raise_on_error=False)
# Print report
print(report)
3. Sample Output
{
'ok': False,
'errors': {
'amount': 'null values present',
'email': 'regex mismatch',
'order_id': 'duplicate values found'
},
'version': '1.0'
}
Versioning
schemaguard uses semantic versioning:
0.1.0— Initial release with YAML schema loader and basic validators.- Future releases will add more validators, performance improvements, and integration examples.
Use Cases
- Validate incoming ETL data before storing in warehouse.
- Ensure API payloads match expected schema.
- Quickly enforce data contracts in collaborative teams.
- Detect and prevent data quality issues in production.
Author
Inzamam Yousaf Email: uniprecisionofficial@gmail.com GitHub: https://github.com/inzamam1121
License
This project is licensed under the MIT License — see the LICENSE file for details.
Contributing
Contributions, issues, and feature requests are welcome! Feel free to fork the repository and submit pull requests.
Metadata
Release files for schemaguard 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| schemaguard-0.2.0.tar.gz | 9.5 kB | Without provenance | Details for schemaguard-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| schemaguard-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for schemaguard-0.2.0-py3-none-any.whl |
Total release size: 20.3 kB
Release files / schemaguard-0.2.0.tar.gz
| Download URL | schemaguard-0.2.0.tar.gz |
|---|---|
| Size | 9.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
edfa8ba709ea181d9647d7f0320000e781671958bbf97b63c9ba47b6ac64e8a9
|
|
BLAKE2b-256 checksum How to use checksums |
eac38fe127b1fc73ebc3c171b542fa127da505ddf3a3e14ee07d1d6d34aa5e07
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.4
|
Release files / schemaguard-0.2.0-py3-none-any.whl
| Download URL | schemaguard-0.2.0-py3-none-any.whl |
|---|---|
| Size | 10.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
87756596bcc8edc22a7ac29c44686951f0bff1d3a42ec61216a5019b1dd75134
|
|
BLAKE2b-256 checksum How to use checksums |
a30a680bb0b441ccf4d951784c7ba539ef339b182300af118d433545e9e97f73
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.4
|
Security for schemaguard 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.