format the error message using the voluptuous.Invalid object
    :param invalid: voluptuous.Invalid instance
    :param doc_type: type of the object, e.g. Organisation, User

def format_error(invalid, doc_type):
    """
    format the error message using the voluptuous.Invalid object
    :param invalid: voluptuous.Invalid instance
    :param doc_type: type of the object, e.g. Organisation, User
    """
    # using string for checking is probably not ideal,
    # but voluptuous does not have specific sub error
    # types for these errors
    if invalid.error_message == 'extra keys not allowed':
        msg = "Key '{}' is not allowed".format(invalid.path[0])
    elif invalid.error_message == 'required key not provided':
        msg = "{} '{}' is missing".format(doc_type, invalid.path[0])
    else:
        msg = invalid.message
    return {'message': msg, 'field': str(invalid.path[0])}