2016-04-21 17 views
2

我想了解何时引发验证异常。当我的自定义请求规则方法验证失败时,$e instanceof ValidationException返回false,其中$e instanceof HttpResponseException返回true,并且当我在HttpResponseException上返回return $e->getResponse时,它确实返回了所需的字段,因此在我的自定义请求验证失败时它会特别激发。我注意到在Illuminate \ Foundation \ Exceptions \ Handler类中,render方法的语句为elseif ($e instanceof ValidationException && $e->getResponse()),但由于HttpResponseException是第一个引发Rules方法验证失败的方法,因此它不会被执行。所以我有点困惑。何时抛出Validation Exception?

回答

0

ValidationException被抛出的特质ValidatesRequests

看到照亮/基金/确认/ ValidatesRequests.php

相关问题