Getting started
Install zodify, validate a dict, and handle a validation error.
Install zodify
Use a virtual environment with supported Python 3.10–3.13. Pin 0.8.1 to run the same release as these examples.
python -m pip install zodify==0.8.1Validate a dict and read the result
Pass the schema first and the data second. Valid input returns a dict; invalid input raises ValueError. This example prints both the successful result and the error for a string where an int is expected.
from zodify import validate
schema = {"name": str, "age": int}
print(validate(schema, {"name": "Ada", "age": 36}))
try:
validate(schema, {"name": "Ada", "age": "36"})
except ValueError as error:
print(f"ValueError: {error}")
Output
{'name': 'Ada', 'age': 36}
ValueError: age: expected int, got str