独立验证类
权限验证方法
public function authorize()
{
return true;
}
验证规则
public function rules()
{
return [
'name' => ['required', 'min:50'],
];
}
抛出错误
public function failedValidation($validator)
{
$error = $validator->errors()->all();
throw new HttpResponseException(response()->json(['code' => 1, 'message' => $error[0]]));
}
网友评论