fastavro.validation

validate(datum: Any, schema: Union[str, List[T], Dict[KT, VT]], field: str = '', raise_errors: bool = True, strict: bool = False, disable_tuple_notation: bool = False) → 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
  • strict – If true, fields without values will raise errors rather than implicitly defaulting to None
  • disable_tuple_notation – If set to True, tuples will not be treated as a special case. Therefore, using a tuple to indicate the type of a record will not work

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, strict: bool = False, disable_tuple_notation: bool = False) → 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
  • strict – If true, fields without values will raise errors rather than implicitly defaulting to None
  • disable_tuple_notation – If set to True, tuples will not be treated as a special case. Therefore, using a tuple to indicate the type of a record will not work

Example:

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