# Path: fastavro/const.py
# INT_MAX_VALUE = (1 << 31) - 1
# 
# INT_MIN_VALUE = -(1 << 31)
# 
# LONG_MAX_VALUE = (1 << 63) - 1
# 
# LONG_MIN_VALUE = -(1 << 63)
# 
# Path: fastavro/_validate_common.py
# class ValidationError(Exception):
#     def __init__(self, *errors):
#         message = json.dumps([str(e) for e in errors], indent=2, ensure_ascii=False)
#         super(ValidationError, self).__init__(message)
#         self.errors = errors
# 
# class ValidationErrorData(
#     namedtuple("ValidationErrorData", ["datum", "schema", "field"])
# ):
#     def __str__(self):
#         # update field for prettier printing
#         field = self.field
#         if field is None:
#             field = ""
# 
#         if self.datum is None:
#             return f"Field({field}) is None expected {self.schema}"
# 
#         return (
#             f"{field} is <{self.datum}> of type "
#             + f"{type(self.datum)} expected {self.schema}"
#         )
# 
# Path: fastavro/schema.py
# FINGERPRINT_ALGORITHMS = _schema.FINGERPRINT_ALGORITHMS
# 
# Path: fastavro/logical_writers.py
# LOGICAL_WRITERS = _logical_writers.LOGICAL_WRITERS
# 
# Path: fastavro/_schema_common.py
# class UnknownType(ValueError):
#     def __init__(self, name):
#         super().__init__(name)
#         self.name = name


import array
import numbers
from collections.abc import Mapping, Sequence
from fastavro.const import INT_MAX_VALUE, INT_MIN_VALUE, LONG_MAX_VALUE, LONG_MIN_VALUE
from ._validate_common import ValidationError, ValidationErrorData
from .schema import extract_record_type, extract_logical_type, schema_name, parse_schema
from .logical_writers import LOGICAL_WRITERS
from ._schema_common import UnknownType
    record_type = extract_record_type(schema)
    result = None

    logical_type = extract_logical_type(schema)
    if logical_type:
        prepare = LOGICAL_WRITERS.get(logical_type)
        if prepare:
            datum = prepare(datum, schema)

    validator = VALIDATORS.get(record_type)
    if validator:
        result = validator(
            datum,
            schema=schema,
            named_schemas=named_schemas,
            parent_ns=field,
            raise_errors=raise_errors,
        )
    elif record_type in named_schemas:
        result = _validate(
            datum,
            schema=named_schemas[record_type],
            named_schemas=named_schemas,
            field=field,
            raise_errors=raise_errors,
        )
    else:
        raise UnknownType(record_type)

    if raise_errors and result is False:

# Path: fastavro/const.py
# INT_MAX_VALUE = (1 << 31) - 1
# 
# INT_MIN_VALUE = -(1 << 31)
# 
# LONG_MAX_VALUE = (1 << 63) - 1
# 
# LONG_MIN_VALUE = -(1 << 63)
# 
# Path: fastavro/_validate_common.py
# class ValidationError(Exception):
#     def __init__(self, *errors):
#         message = json.dumps([str(e) for e in errors], indent=2, ensure_ascii=False)
#         super(ValidationError, self).__init__(message)
#         self.errors = errors
# 
# class ValidationErrorData(
#     namedtuple("ValidationErrorData", ["datum", "schema", "field"])
# ):
#     def __str__(self):
#         # update field for prettier printing
#         field = self.field
#         if field is None:
#             field = ""
# 
#         if self.datum is None:
#             return f"Field({field}) is None expected {self.schema}"
# 
#         return (
#             f"{field} is <{self.datum}> of type "
#             + f"{type(self.datum)} expected {self.schema}"
#         )
# 
# Path: fastavro/schema.py
# FINGERPRINT_ALGORITHMS = _schema.FINGERPRINT_ALGORITHMS
# 
# Path: fastavro/logical_writers.py
# LOGICAL_WRITERS = _logical_writers.LOGICAL_WRITERS
# 
# Path: fastavro/_schema_common.py
# class UnknownType(ValueError):
#     def __init__(self, name):
#         super().__init__(name)
#         self.name = name


# Path: fastavro/_validation_py.py
import array
import numbers
from collections.abc import Mapping, Sequence
from fastavro.const import INT_MAX_VALUE, INT_MIN_VALUE, LONG_MAX_VALUE, LONG_MIN_VALUE
from ._validate_common import ValidationError, ValidationErrorData
from .schema import extract_record_type, extract_logical_type, schema_name, parse_schema
from .logical_writers import LOGICAL_WRITERS
from ._schema_common import UnknownType

    record_type = extract_record_type(schema)
    result = None

    logical_type = extract_logical_type(schema)
    if logical_type:
        prepare = LOGICAL_WRITERS.get(logical_type)
        if prepare:
            datum = prepare(datum, schema)

    validator = VALIDATORS.get(record_type)
    if validator:
        result = validator(
            datum,
            schema=schema,
            named_schemas=named_schemas,
            parent_ns=field,
            raise_errors=raise_errors,
        )
    elif record_type in named_schemas:
        result = _validate(
            datum,
            schema=named_schemas[record_type],
            named_schemas=named_schemas,
            field=field,
            raise_errors=raise_errors,
        )
    else:
        raise UnknownType(record_type)

    if raise_errors and result is False:

        raise ValidationError(ValidationErrorData(datum, schema, field))