Skip to main content

Runtime Data Contract Enforcer

Project description

rdce

CI Pipeline Python License

Runtime Data Contract Enforcer: A lightweight Python 3 library for recursively validating and diffing nested JSON payloads against explicit Pydantic schemas.

Current Status

🚀 v0.1.0 Complete 🚀 The core recursive validation engine, Pydantic extractor, and public API are complete and fully tested with 100% coverage.

🌟 Features

  • Pydantic Native: Define your data contracts using standard Pydantic BaseModel classes.
  • Recursive Type Validation: Deeply inspects nested dictionaries and payloads without flattening them.
  • Path Tracking: Returns exact dot-notation breadcrumbs for schema drift (e.g., user.address.zip_code).
  • Zero Bloat: Built to do one thing perfectly—diffing data schemas.

📦 Installation

(Note: Pending PyPI release)

pip install rdce
# Or using poetry
poetry add rdce

🚀 Quick Start

rdce is designed to be a transparent bridge between your Pydantic models and incoming, untrusted dictionary payloads.

1. Define your Contract

Use standard Pydantic models. Nested models are fully supported.

from pydantic import BaseModel

class Address(BaseModel):
    city: str
    zip_code: int

class UserContract(BaseModel):
    username: str
    is_active: bool
    address: Address

2. Enforce the Payload

Pass the model class and your raw dictionary payload into the enforce_contract engine.

from rdce import enforce_contract

# A payload with schema drift (wrong type for zip_code, missing is_active)
incoming_payload = {
    "username": "alice_data",
    "address": {
        "city": "London",
        "zip_code": "E1 6AN" # Expected int, got string
    }
}

errors = enforce_contract(UserContract, incoming_payload)

for error in errors:
    print(error)

Output:

[
  {"path": "is_active", "expected": "bool", "actual": "MISSING"},
  {"path": "address.zip_code", "expected": "int", "actual": "str"}
]

🤝 Contributing

We welcome contributions! To set up the project locally:

1 Clone the repository.
2 Initialize the environment: poetry install
3 We strictly enforce formatting and linting via Ruff:
4 Linter: 
    poetry run python3 -m ruff check .
5 Formatter: 
    poetry run python3 -m ruff format .
6 Run the test suite: 
    poetry run pytest
7 Ensure 100% test coverage before submitting a Pull Request.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rdce-0.1.0.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rdce-0.1.0-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file rdce-0.1.0.tar.gz.

File metadata

  • Download URL: rdce-0.1.0.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for rdce-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9405cf55f948cdf450cd2c5011ef52510d89af6e2c5dfcf0a2b1db8e9d1a8237
MD5 d8aec1e5afcfcbe686c250133fdb1067
BLAKE2b-256 94a06d4aa2a5433000f4445d913af776dd3981681af64029ea311712fc4ff4f6

See more details on using hashes here.

Provenance

The following attestation bundles were made for rdce-0.1.0.tar.gz:

Publisher: publish.yml on valdal14/rdce

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rdce-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: rdce-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for rdce-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 870620c365e8745942b14ec1f14a9b5d5de1e32a4ef4b8b3a641fb108b86cca0
MD5 aa958fc3a0e850bc785c9123a92155cc
BLAKE2b-256 a04765f8e77efdaee76dde52c0e4963e3b5a529d01df7131f0f1bbca2d82a164

See more details on using hashes here.

Provenance

The following attestation bundles were made for rdce-0.1.0-py3-none-any.whl:

Publisher: publish.yml on valdal14/rdce

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page