Show HN: Automatically Validate Python Packages

EdwardK11 pts1 comments

validatedata · PyPI

Skip to main content<br>Switch to mobile version

Warning

You are using an unsupported browser, upgrade to a newer version.

Warning

Some features may not work without JavaScript. Please try enabling it if you encounter problems.

Search PyPI

Search

validatedata 0.6.1

pip install validatedata

Copy PIP instructions

Latest release

Released:<br>Jun 16, 2026

An easier way to validate data in python

Navigation

Verified details

These details have been verified by PyPI<br>Project links

Homepage

Issues

Repository

GitHub Statistics

Repository

Stars:

Forks:

Open issues:

Open PRs:

Maintainers

Edward-K1

Unverified details

These details have not been verified by PyPI<br>Project links

Documentation

Meta

License Expression: MIT

SPDX<br>License Expression

Author: Edward Kigozi

Tags

validate

data

validation

Requires: Python >=3.7

Classifiers

Operating System

OS Independent

Programming Language

Python :: 3

Report project as malware

Project description

Validatedata

An easier way to validate data in python.

Six validation modes – one simple syntax.

validator() – compile rules into ultra‑fast boolean callables. Ideal for high‑throughput streaming.

validate_data_fast() – compiled speed with full error messages (preview of the next‑gen engine – will eventually replace validate_data).

validate_data() – general‑purpose validation with detailed errors, nested structures, and optional mutation.

@validate – decorator for function argument validation.

@validate_types – decorator that uses Python type annotations.

autovalidate / autovalidate_package – automatically apply @validate_types to entire modules or packages.

Validatedata gives you expressive, inline validation rules without defining model classes. It fits naturally into any Python workflow – from lightweight scripts to high‑volume data processing.

New in v0.6.0:

validate_data_fast – the speed of validator() combined with rich error messages (experimental fast path, will eventually replace validate_data).

autovalidate & autovalidate_package – automatic application of @validate_types to whole modules or packages.

Custom type registration – add your own type checkers with register_type / unregister_type.

Benchmarks (1 million repetitions)

Test<br>validatedata<br>manual<br>pydantic v2<br>msgspec<br>beartype<br>fastjsonschema

Scalar: type (int)<br>0.1109s<br>0.0842s<br>0.4254s<br>0.0793s<br>0.3594s<br>0.1478s

Scalar: type + range<br>0.1508s<br>0.1286s<br>0.1314s<br>0.1353s<br>0.3841s<br>0.1493s

Dict (valid)<br>1.9438s<br>1.1996s<br>1.8246s<br>1.2350s<br>3.8948s<br>2.8658s

Dict (invalid)<br>0.2644s<br>0.5856s<br>2.1661s<br>1.1895s<br>2.0818s<br>2.7938s

Note: The “manual” column represents hand‑written if statements + dataclasses – fastest but not reusable. Validatedata’s small overhead buys you maintainability and expressiveness.

Fast validation with validator()

When you only need a boolean pass/fail result (no error messages), use validator(). It compiles a rule into a callable that returns True or False with minimal overhead. Its faster than Pydantic v2 and msgspec on invalid data dicts.

The performance advantage of the validator function on invalid data comes from early‑exit optimisations.

from validatedata import validator

# Single value – pipe syntax<br>is_valid_username = validator('str|min:3|max:32')<br>is_valid_username('alice') # True<br>is_valid_username('a') # False

# Multiple fields – flat dict rule<br>validate_user = validator({<br>'username': 'str|min:3|max:32',<br>'email': 'email',<br>'age': 'int|min:18'<br>})

validate_user({'username': 'bob', 'email': 'bob@example.com', 'age': 25}) # True

# Parameterized containers<br>is_str_list = validator('list[str]')<br>is_str_list(['a', 'b', 'c']) # True<br>is_str_list(['a', 1, 'c']) # False

is_str_or_int_list = validator('list[str,int]')<br>is_str_or_int_list(['a', 1, 'c']) # True

# Nested dicts. Mirror structure<br>v = validator({<br>'owner': 'str|min:2',<br>'address': {'street': 'str', 'city': 'str'},<br>})

v({<br>'owner': 'Alice',<br>'address': {'street': '1 Main St', 'city': 'Springfield'},<br>})

Installation

pip install validatedata

For extended phone number validation (national, international, and region-specific formats):

pip install phonenumbers

📖 Read the full documentation

Quick Start

from validatedata import validate_data

# with shorthand<br>rule={<br>'username': 'str|min:3|max:32',<br>'email': 'email',<br>'age': 'int|min:18',

result = validate_data(<br>data={'username': 'alice', 'email': 'alice@example.com', 'age': 25},<br>rule=rule

if result.ok:<br>print('valid!')<br>else:<br>print(result.errors)

Six Ways to Validate

1. validator() – for high performance (boolean only)

from validatedata import validator

is_valid_username = validator('str|min:3|max:32')<br>if is_valid_username('alice'):<br>do_xyz()

2. compiled speed + error messages (experimental)

from validatedata import validate_data_fast

result = validate_data_fast({'name': 'alice'}, {'name': 'str|min:3'})<br>if not result.ok:<br>print(result.errors) # ['name: string too short (minimum length: 3)']

3. validate_types decorator

Validates function...

validator validatedata python data validation result

Related Articles