PyValidX
PyValidX is a small Python validation library that helps developers check data before using it.
It is useful for form input, API request bodies, configuration files, and any place where incoming data should follow clear rules.
Installation
pip install pyvalidx
Quick Start
from pyvalidx import validate
validate("john@example.com", ["required", "email"])
validate("secure-password", ["required", "min:8"])
validate(25, ["required", "between:18,100"])
If the value is invalid, PyValidX raises a ValidationError.
from pyvalidx import ValidationError, validate
try:
validate("", ["required"])
except ValidationError as error:
print(error)
Available Rules
| Rule | Example | Meaning |
|---|---|---|
required |
required |
Value cannot be empty |
email |
email |
Value must look like an email address |
min |
min:8 |
Value length or number must be at least 8 |
max |
max:100 |
Value length or number must be at most 100 |
between |
between:18,100 |
Number must be between 18 and 100 |
regex |
regex:^[A-Z]+$ |
Value must match a regular expression |
in |
in:admin,user |
Value must be one of the allowed options |
Validate Dictionaries
from pyvalidx import validate_data
rules = {
"name": ["required", "min:2"],
"email": ["required", "email"],
"age": ["required", "between:18,100"],
}
validate_data(
{"name": "Jane", "email": "jane@example.com", "age": 30},
rules,
)
Custom Validators
from pyvalidx import validate
def starts_with_a(value):
return str(value).startswith("A")
validate("Alice", [starts_with_a])
Custom validators can return:
Truefor validFalsefor invalid- A string error message for invalid
Development
python -m pip install -e . pytest build twine
python -m pytest
python -m build
python -m twine check dist/*
Publish to PyPI
First test with TestPyPI:
python -m twine upload --repository testpypi dist/*
Then upload to PyPI:
python -m twine upload dist/*
Metadata
Release files for pyvalidYR 0.1.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 |
|---|---|---|---|---|
| pyvalidyr-0.1.0.tar.gz | 5.7 kB | Without provenance | Details for pyvalidyr-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyvalidyr-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for pyvalidyr-0.1.0-py3-none-any.whl |
Total release size: 11.1 kB
Release files / pyvalidyr-0.1.0.tar.gz
| Download URL | pyvalidyr-0.1.0.tar.gz |
|---|---|
| Size | 5.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a8edf23db1decfb9ef8a196d3ccf9ac0aaf96e48d0a2f031df7f001f8c3c4e1d
|
|
BLAKE2b-256 checksum How to use checksums |
b55e1553aa42b7e756aa211680a19960c6e51806a99616f1f959748baad9fb8c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.6
|
Release files / pyvalidyr-0.1.0-py3-none-any.whl
| Download URL | pyvalidyr-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e5fe42440512f9bcd6d1a0b9b71917cf9ef507f369aa92be8f4d1f1782a0eae3
|
|
BLAKE2b-256 checksum How to use checksums |
7cc291cabf8581b0232f8724e4bdca9503eb52331e36d99aad191d5a84fefb7a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.6
|
Security for pyvalidYR 0.1.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.