fastavro.validation

validate(datum: Any, schema: Union[str, List[T], Dict[KT, VT]], field: str = '', raise_errors: bool = True) → bool

Determine if a python datum is an instance of a schema.

Parameters:
  • datum – Data being validated
  • schema – Schema
  • field – Record field being validated
  • raise_errors – If true, errors are raised for invalid data. If false, a simple True (valid) or False (invalid) result is returned

Example:

from fastavro.validation import validate
schema = {...}
record = {...}
validate(record, schema)
validate_many(records: Iterable[Any], schema: Union[str, List[T], Dict[KT, VT]], raise_errors: bool = True) → bool

Validate a list of data!

Parameters:
  • records – List of records to validate
  • schema – Schema
  • raise_errors – If true, errors are raised for invalid data. If false, a simple True (valid) or False (invalid) result is returned

Example:

from fastavro.validation import validate_many
schema = {...}
records = [{...}, {...}, ...]
validate_many(records, schema)