A flexible and extensible validation library for Python
Project description
ValidX
A flexible and extensible validation library for Python.
Features
- 🔍 Type Validators: Check for strings, integers, floats, booleans, lists, dicts, and None
- 📧 Format Validators: Validate emails and URLs with robust regex patterns
- 📏 Range & Length Validators: Check numeric ranges and string/collection lengths
- 🎯 Decorators: Validate function arguments and return values
- 🛠️ Utilities: Helper functions for empty/non-empty checks
- ✨ Type Hints: Full type annotation support for better IDE experience
- 🧪 Well Tested: Comprehensive test suite with high coverage
Installation
pip install validify-py
For development:
pip install validify-py[dev]
Quick Start
from validx import is_email, is_url, is_string, is_in_range, ValidationError
# Basic type validation
is_string("hello") # True
is_string(123) # False
# Email validation
is_email("user@example.com") # True
is_email("invalid-email") # False
# URL validation
is_url("https://github.com") # True
is_url("not-a-url") # False
# Range validation
is_in_range(5, min_value=0, max_value=10) # True
is_in_range(15, min_value=0, max_value=10) # False
Using Decorators
from validx import validate_args, validate_return, ValidationError
def is_positive(x):
return x > 0
@validate_args(is_positive)
def square(x):
return x * x
square(5) # Returns 25
square(-1) # Raises ValidationError
def is_not_none(value):
return value is not None
@validate_return(is_not_none)
def find_user(user_id):
# ... lookup logic
return user
find_user(123) # Works if user found
find_user(999) # Raises ValidationError if returns None
Available Validators
| Function | Description |
|---|---|
is_string(value) |
Check if value is a string |
is_integer(value) |
Check if value is an integer (excludes booleans) |
is_float(value) |
Check if value is a float |
is_boolean(value) |
Check if value is a boolean |
is_list(value) |
Check if value is a list |
is_dict(value) |
Check if value is a dictionary |
is_none(value) |
Check if value is None |
is_email(value) |
Check if value is a valid email format |
is_url(value) |
Check if value is a valid URL format |
is_in_range(value, min_value, max_value) |
Check if numeric value is in range |
has_min_length(value, min_length) |
Check minimum length |
has_max_length(value, max_length) |
Check maximum length |
is_empty(value) |
Check if value is empty (None, '', or empty collection) |
is_not_empty(value) |
Check if value is not empty |
Contributing
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run tests (
pytest) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Development
# Clone the repository
git clone https://github.com/2024si96524-Mithun/ValidX.git
cd ValidX
# Install development dependencies
pip install -e .[dev]
# Run tests
pytest
# Run linting
flake8 src tests
black --check src tests
isort --check-only src tests
mypy src
# Format code
black src tests
isort src tests
License
This project is licensed under the MIT License - see the LICENSE file for details.
Security
If you discover a security vulnerability, please open an issue or contact the maintainers directly. All security vulnerabilities will be promptly addressed.
Changelog
See CHANGELOG.md for a list of changes.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file validify_py-0.1.0.tar.gz.
File metadata
- Download URL: validify_py-0.1.0.tar.gz
- Upload date:
- Size: 9.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eda7964db8314663dd9e3d0283915a79a1a08adaf2ef434d3313d3c668d5e56f
|
|
| MD5 |
d3a7699e34ff3366fc2e5fab3ecdaace
|
|
| BLAKE2b-256 |
d3441c5cfa8abdb069a410ff545a2229942bd68f768330f50023cc73343e9658
|
File details
Details for the file validify_py-0.1.0-py3-none-any.whl.
File metadata
- Download URL: validify_py-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1752ca5ccaf10a3b74bc6c49f5c0eb2c635cba7aac3f8f7009ec9f82fa998498
|
|
| MD5 |
692024b265b7715d112788c828a689e3
|
|
| BLAKE2b-256 |
7e77f7dc929b4223e2a6cb23bb3ee541fd5c7e2e048357b47f4178f261002e75
|