A tool for validating and enforcing data schemas across various data sources.
- Schema definition
- Data validation
- Error reporting
pip install data-schema-validatorYou can define a schema using a dictionary. Here is an example:
from data_schema_validator import Schema
schema = Schema({
'name': str,
'age': int,
'email': str
})To validate data against the schema, use the validate method:
data = {
'name': 'John Doe',
'age': 30,
'email': 'john.doe@example.com'
}
errors = schema.validate(data)
if errors:
print('Validation errors:', errors)
else:
print('Data is valid')The validate method returns a list of errors if the data does not conform to the schema. Each error includes the field name and the error message.