改进验证器

This commit is contained in:
Wisp X
2022-01-21 15:47:18 +08:00
parent ffc2895a6c
commit 95fd3fc930
6 changed files with 40 additions and 67 deletions
-22
View File
@@ -2,25 +2,8 @@
namespace App\Http\Requests;
use App\Http\Api;
use Illuminate\Contracts\Validation\Validator;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Http\Exceptions\HttpResponseException;
class UserSettingRequest extends FormRequest
{
use Api;
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
@@ -55,9 +38,4 @@ class UserSettingRequest extends FormRequest
'configs.is_auto_clear_preview.boolean' => '是否自动清除预览选择错误'
];
}
protected function failedValidation(Validator $validator)
{
throw (new HttpResponseException($this->error($validator->errors()->first())));
}
}