Skip to main content

ValidateLite

PyPI version Python 3.8+ License: MIT Code Coverage

ValidateLite: A lightweight data validation tool for engineers who need answers, fast.

Unlike other complex data validation tools, ValidateLite provides two powerful, focused commands for different scenarios:

  • vlite check: For quick, ad-hoc data checks. Need to verify if a column is unique or not null right now? The check command gets you an answer in 30 seconds, zero config required.

  • vlite schema: For robust, repeatable database schema validation. It's your best defense against schema drift. Embed it in your CI/CD and ETL pipelines to enforce data contracts, ensuring data integrity before it becomes a problem.


Core Use Case: Automated Schema Validation

The vlite schema command is key to ensuring the stability of your data pipelines. It allows you to quickly verify that a database table or data file conforms to a defined structure.

Scenario 1: Gate Deployments in CI/CD

Automatically check for breaking schema changes before they get deployed, preventing production issues caused by unexpected modifications.

Example Workflow (.github/workflows/ci.yml)

jobs:
  validate-db-schema:
    name: Validate Database Schema
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v3

      - name: Set up Python
        uses: actions/setup-python@v4
        with:
          python-version: '3.9'

      - name: Install ValidateLite
        run: pip install validatelite

      - name: Run Schema Validation
        run: |
          vlite schema --conn "mysql://${{ secrets.DB_USER }}:${{ secrets.DB_PASS }}@${{ secrets.DB_HOST }}/sales" \
                           --rules ./schemas/customers_schema.json

Scenario 2: Monitor ETL/ELT Pipelines

Set up validation checkpoints at various stages of your data pipelines to guarantee data quality and avoid "garbage in, garbage out."

Example Rule File (customers_schema.json)

{
  "customers": {
    "rules": [
      { "field": "id", "type": "integer", "required": true },
      { "field": "name", "type": "string", "required": true },
      { "field": "email", "type": "string", "required": true },
      { "field": "age", "type": "integer", "min": 18, "max": 100 },
      { "field": "gender", "enum": ["Male", "Female", "Other"] },
      { "field": "invalid_col" }
    ]
  }
}

Run Command:

vlite schema --conn "mysql://user:pass@host:3306/sales" --rules customers_schema.json

Advanced Schema Examples

Multi-Table Validation:

{
  "customers": {
    "rules": [
      { "field": "id", "type": "integer", "required": true },
      { "field": "name", "type": "string", "required": true },
      { "field": "email", "type": "string", "required": true },
      { "field": "age", "type": "integer", "min": 18, "max": 100 }
    ],
    "strict_mode": true
  },
  "orders": {
    "rules": [
      { "field": "id", "type": "integer", "required": true },
      { "field": "customer_id", "type": "integer", "required": true },
      { "field": "total", "type": "float", "min": 0 },
      { "field": "status", "enum": ["pending", "completed", "cancelled"] }
    ]
  }
}

CSV File Validation:

# Validate CSV file structure
vlite schema --conn "sales_data.csv" --rules csv_schema.json --output json

Complex Data Types:

{
  "events": {
    "rules": [
      { "field": "timestamp", "type": "datetime", "required": true },
      { "field": "event_type", "enum": ["login", "logout", "purchase"] },
      { "field": "user_id", "type": "string", "required": true },
      { "field": "metadata", "type": "string" }
    ],
    "case_insensitive": true
  }
}

Available Data Types:

  • string - Text data (VARCHAR, TEXT, CHAR)
  • integer - Whole numbers (INT, BIGINT, SMALLINT)
  • float - Decimal numbers (FLOAT, DOUBLE, DECIMAL)
  • boolean - True/false values (BOOLEAN, BOOL, BIT)
  • date - Date only (DATE)
  • datetime - Date and time (DATETIME, TIMESTAMP)

Enhanced Schema Validation with Metadata

ValidateLite now supports metadata validation for precise schema enforcement without scanning table data. This provides superior performance by validating column constraints directly from database metadata.

Metadata Validation Features:

  • String Length Validation: Validate max_length for string columns
  • Float Precision Validation: Validate precision and scale for decimal columns
  • Database-Agnostic: Works across MySQL, PostgreSQL, and SQLite
  • Performance Optimized: Uses database catalog queries, not data scans

Enhanced Schema Examples:

String Metadata Validation:

{
  "users": {
    "rules": [
      {
        "field": "username",
        "type": "string",
        "max_length": 50,
        "required": true
      },
      {
        "field": "email",
        "type": "string",
        "max_length": 255,
        "required": true
      },
      {
        "field": "biography",
        "type": "string",
        "max_length": 1000
      }
    ]
  }
}

Float Precision Validation:

{
  "products": {
    "rules": [
      {
        "field": "price",
        "type": "float",
        "precision": 10,
        "scale": 2,
        "required": true
      },
      {
        "field": "weight",
        "type": "float",
        "precision": 8,
        "scale": 3
      }
    ]
  }
}

Mixed Metadata Schema:

{
  "orders": {
    "rules": [
      { "field": "id", "type": "integer", "required": true },
      {
        "field": "customer_name",
        "type": "string",
        "max_length": 100,
        "required": true
      },
      {
        "field": "total_amount",
        "type": "float",
        "precision": 12,
        "scale": 2,
        "required": true
      },
      { "field": "order_date", "type": "datetime", "required": true },
      { "field": "notes", "type": "string", "max_length": 500 }
    ],
    "strict_mode": true
  }
}

Backward Compatibility: Existing schema files without metadata continue to work unchanged. Metadata validation is optional and can be added incrementally to enhance validation precision.

Command Options:

# Basic validation
vlite schema --conn <connection> --rules <rules_file>

# JSON output for automation
vlite schema --conn <connection> --rules <rules_file> --output json

# Exit with error code on any failure
vlite schema --conn <connection> --rules <rules_file> --fail-on-error

# Verbose logging
vlite schema --conn <connection> --rules <rules_file> --verbose

Quick Start: Ad-Hoc Checks with check

For temporary, one-off validation needs, the check command is your best friend.

1. Install (if you haven't already):

pip install validatelite

2. Run a check:

# Check for nulls in a CSV file's 'id' column
vlite check --conn "customers.csv" --table customers --rule "not_null(id)"

# Check for uniqueness in a database table's 'email' column
vlite check --conn "mysql://user:pass@host/db" --table customers --rule "unique(email)"

Learn More


📝 Development Blog

Follow the journey of building ValidateLite through our development blog posts:


📄 License

This project is licensed under the MIT License.

Metadata

Release files for validatelite 0.4.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for validatelite 0.4.3
File Size Uploaded Provenance Actions
validatelite-0.4.3.tar.gz 301.6 kB Without provenance Details for validatelite-0.4.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for validatelite 0.4.3
File Interpreter ABI Platform Actions
validatelite-0.4.3-py3-none-any.whl Python 3 none any Details for validatelite-0.4.3-py3-none-any.whl

Total release size: 467.4 kB

Release files / validatelite-0.4.3.tar.gz

Download URL validatelite-0.4.3.tar.gz
Size 301.6 kB
Tags Source
SHA-256 checksum
How to use checksums
860179570d49784c6af570a47cc03e459e576080df3e4257d89d5f82b74d8839
BLAKE2b-256 checksum
How to use checksums
3f81f35d89b9d796e3c461ae1d0724e12615c6978bdae6e9fa1231f35040181d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.2.0 CPython/3.11.13

Release files / validatelite-0.4.3-py3-none-any.whl

Download URL validatelite-0.4.3-py3-none-any.whl
Size 165.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1a6552f870e4fc319c5b38891438881769a71bab198b62a50dc98f4c55794996
BLAKE2b-256 checksum
How to use checksums
f92364fbcc97662b7951200c33574ab31468798497f880e5bcd5da6671e29fb1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.2.0 CPython/3.11.13

Security for validatelite 0.4.3

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page