'nullable|string', 'file' => 'required|file', ]; } public function messages(): array { return [ 'required' => ':attribute 必填', 'file' => ':attribute 必须上传', ]; } // 这里我是希望走到我自己定义的 异常处理,你如果没有自定义,去掉这个函数的重写即可。 protected function failedValidation(ValidatorInterface $validator) { throw new ApiException(ErrorCode::SERVER_ERROR, $validator->errors()->first()); } }