def get_validation_error(message, data=None, code=None):
    """ 方便快捷抛 400 的函数。shortcut for raising bad request error in django-rest-framework.

    Examples::

        raise get_validation_error('非法的请求')

    :rtype: rest_framework.exceptions.ValidationError
    """
    from rest_framework.exceptions import ValidationError
    error = {'message': str(message)}
    if data is not None:
        error['data'] = data
    if code is not None:
        error['code'] = code
    return ValidationError(error)
