from typing import Iterable


def validation_failed_dict(
    items: Iterable,
    dict_code: int = 1001,
    dict_message: str = 'Validation Failed'
):
    """Generate dict for failed validation in format of DRF-friendly-errors.

    Attributes:
        items: Items to put into dict. In format: [(code, field, message), ...]

    Returns:
        dict: In format of DRF
    """
    return {
        'code': dict_code,
        'message': dict_message,
        'errors': [
            {'code': i[0], 'field': i[1], 'message': i[2]} for i in items
        ]
    }