schema

Simple data validation library for Python

pipmacoslinuxwindows
Try with needOr install directly
Source

About

Simple data validation library

Commands

schema

Examples

Validate a dictionary against a schema definition$ python -c "from schema import Schema; s = Schema({'name': str, 'age': int}); print(s.validate({'name': 'John', 'age': 30}))"
Validate a list of items with optional fields$ python -c "from schema import Schema, Optional; s = Schema({'id': int, Optional('email'): str}); print(s.validate({'id': 1}))"
Catch validation errors and handle them$ python -c "from schema import Schema, SchemaError; s = Schema(int); try: s.validate('invalid') except SchemaError as e: print(f'Validation error: {e}')"