表单验证中,手动创建建验证器,当验证不通过时会返回所有错误信息的一个数组,有什么好的方法处理?
表单验证中,使用手动创建建验证器,当验证不通过时会返回所有错误信息的一个数组,目前我是用App\Exceptions\Handler类中的register方法来注册处理
public function register() {
//表单验证处理
$this->renderable(function (ValidationException $exception){
return Error(Arr::first($exception->errors()));
});
}
请问还有什么好的方法吗?
在Request的验证类里面重写这个方法
failedValidation