ValidX
raw JSON → 0.8.1 verified Fri May 01 auth: no python
ValidX is a fast, powerful, and flexible data validation library for Python with a clean and sane syntax. It supports complex nested validations, transformations, and custom rules. Current version is 0.8.1, released under MIT license. Release cadence is irregular.
pip install validx Common errors
error ModuleNotFoundError: No module named 'validx' ↓
cause Library not installed or installed in wrong environment.
fix
Run
pip install validx and ensure you are in the correct virtual environment. error AttributeError: module 'validx' has no attribute 'validate' ↓
cause Incorrect import: you imported 'validx' instead of 'validate'.
fix
Change
import validx to from validx import validate. Warnings
deprecated In versions < 0.8.0, `validate` returned a tuple (valid, errors). In 0.8.0+ it returns a Result object with attributes .valid and .errors. ↓
fix Update code to use .valid and .errors attributes instead of tuple unpacking.
gotcha Nested schemas must be defined as dicts, not as tuples or lists. Using a tuple for a nested validation will be treated as a sequence validator, not a dict validator. ↓
fix Always use dict for object schemas: {'nested': {'key': int}}
Imports
- validate wrong
import validxcorrectfrom validx import validate
Quickstart
from validx import validate
schema = {
"name": str,
"age": int,
"email": str
}
data = {"name": "Alice", "age": 30, "email": "alice@example.com"}
result = validate(schema, data)
print(result.valid) # True if valid, False otherwise
print(result.errors) # Empty list if valid