def convert_error_dict_to_list(error_dict, error_code=None):
    """
    Given an error dict (returned by Marshmallow), convert into a list of errors
    """
    return_value = []
    for f, errors in error_dict.items():
        # error can be a string, a dictionary, list of string or a list of dictionary
        if isinstance(errors, str) or isinstance(errors, dict):
            # if error is just a singular, wrap it in a list so we can treat it the same way
            errors = [errors]
        for error in errors:
            if isinstance(error, dict):
                error['property'] = f
            elif isinstance(error, str):
                error = dict(message=error, property=f)
            if error_code is not None:
                error['error_code'] = error_code
            return_value.append(error)
    return return_value