在Laravel 5.3中抛出自定义验证异常/错误

时间:2017-02-06 10:44:05

标签: laravel-5 laravel-5.3

我正在将Laravel从5.2升级到5.3。在5.2中,我正在抛出Illuminate\Contracts\Validation\ValidationException(使用我自己的验证逻辑),如下所示:

$this->errors = new MessageBag();
...
ValidationException($this->errors);

在5.3中,Illuminate\Contracts\Validation\ValidationException被删除。如何保持相同的刀片输出行为?我只是重新创建ValidationException

// In blade, this should still print error. (JSON should keep same behaviour too)
@if (count($errors) > 0)
    <div class="alert alert-danger">
        <ul>
            @foreach ($errors->all() as $error)
                <li>{{ $error }}</li>
            @endforeach
        </ul>
    </div>
@endif

0 个答案:

没有答案