{"id":23297,"library":"avro-validator","title":"avro-validator","description":"A pure Python Avro schema validator that validates Python dicts against Avro schemas, supporting logical types, recursive types, custom types, and JSON Schema format for union types. Current version 1.2.1, released June 2022; maintenance mode.","status":"maintenance","version":"1.2.1","language":"python","source_language":"en","source_url":"https://github.com/leocalm/avro_validator","tags":["avro","schema","validation","avro-schema"],"install":[{"cmd":"pip install avro-validator","lang":"bash","label":"pip install avro-validator"}],"dependencies":[],"imports":[{"note":"AvroValidator is exposed at package level since 1.0.0","wrong":"from avro_validator.validator import AvroValidator","symbol":"AvroValidator","correct":"from avro_validator import AvroValidator"},{"note":"AvroSchema is also at package level","wrong":"from avro_validator.schema import AvroSchema","symbol":"AvroSchema","correct":"from avro_validator import AvroSchema"}],"quickstart":{"code":"from avro_validator import AvroValidator, AvroSchema\n\nschema = AvroSchema({\n    'type': 'record',\n    'name': 'User',\n    'fields': [{'name': 'name', 'type': 'string'}, {'name': 'age', 'type': 'int'}]\n})\nvalidator = AvroValidator(schema)\n\ndata = {'name': 'Alice', 'age': 30}\nresult = validator.validate(data)\nprint(result.is_valid)  # True\nprint(result.errors)    # []\n","lang":"python","description":"Create an Avro schema, validate a record, and check result."},"warnings":[{"fix":"Use result.is_valid and result.errors instead of comparing result directly.","message":"validate() returns an AvroResult object, not a boolean. Access .is_valid and .errors.","severity":"gotcha","affected_versions":"all"},{"fix":"schema_dict = json.loads(schema_str); schema = AvroSchema(schema_dict)","message":"AvroSchema expects a Python dict, not a JSON string. If you have a JSON string, parse it with json.loads first.","severity":"gotcha","affected_versions":"all"},{"fix":"Manually check defaults before validation or use a different library if strict default validation is needed.","message":"The library does not validate field defaults against the schema. A default with wrong type passes validation.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"validator = AvroValidator(schema); result = validator.validate(data)","cause":"Trying to call validate as a top-level function instead of method on AvroValidator instance.","error":"AttributeError: module 'avro_validator' has no attribute 'validate'"},{"fix":"Ensure all custom types are included in the schema's 'types' or use fully qualified names.","cause":"Schema field type is a custom type name that is not defined in the schema's 'types' list.","error":"avro_validator.exceptions.InvalidSchemaError: invalid literal for int() with base 10: ..."},{"fix":"Use result.errors to get the list of errors.","cause":"Attempting to iterate over the AvroResult object (e.g., for error in result).","error":"TypeError: 'AvroResult' object is not iterable"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}