protected function failedValidation(Validator $validator) { $messages = $validator->errors(); if ($messages->has('email', '<p>:The email has already been taken.</p>')) { $subscription = Subscription::where('email', $this->request->get('email'))->first(); if (!$subscription->confirmed) { $this->mailer->sendEmailConfirmationFor($subscription); } else { $messages = ['email.unique:subscriptions' => 'That email address is already signed up']; $validator->getMessageBag()->merge($messages); $this->mailer->sendEmailRejectionFor($subscription); } } throw new HttpResponseException($this->response($this->formatErrors($validator))); }
public function formatErrors(Validator $validator) { foreach ($validator->errors()->all() as $error) { Notifications::add($error, 'danger'); } return $validator->errors()->getMessages(); }
protected function formatErrors(Validator $validator) { if (count($validator->errors()->getMessages()) > 8) { return [trans('messages.many-errors')]; } return $validator->errors()->all(); }
protected function formatValidationErrors(Validator $validator) { foreach ($validator->errors()->getMessages() as $key => $message) { if (starts_with($key, 'roles')) { $validator->errors()->add('roles', $message[0]); } } return $validator->errors()->getMessages(); }
/** * Handle a failed validation attempt. * * @param \Illuminate\Contracts\Validation\Validator $validator * * @return void */ protected function failedValidation(Validator $validator) { if ($this->container['request'] instanceof Request) { throw new ValidationHttpException($validator->errors()); } parent::failedValidation($validator); }
public function formatErrors(Validator $validator) { $repeatedAttendee = false; $emptyNames = false; $errors = $validator->errors()->all(); foreach ($errors as $index => $error) { if (fnmatch('The selected user id.* is invalid.', $error)) { // Removes from array; can still iterate through array with foreach unset($errors[$index]); $repeatedAttendee = true; } else { if (fnmatch('The name.* field is required.', $error)) { unset($errors[$index]); $emptyNames = true; } } } // Pushes more descriptive error message onto array if ($repeatedAttendee) { array_push($errors, 'The same attendee has been entered in the attendance list more than once.'); } if ($emptyNames) { array_push($errors, 'One of the names of the listed attendees has not been provided.'); } return $errors; }
/** * Handle a failed validation attempt. * * @param \Illuminate\Contracts\Validation\Validator $validator * * @return mixed */ protected function failedValidation(Validator $validator) { if ($this->container['request'] instanceof BaseRequest) { throw new ApiValidationException($validator->errors(), $this->getFailedValidationMessage($this->container['request'])); } parent::failedValidation($validator); }
/** * Get the response for a error validate. * * @param Validator $validator * @return \Illuminate\Http\Response */ public function failedValidationResponse(Validator $validator) { if ($this->is('api/*')) { return \ResponseFractal::respondErrorWrongArgs($validator->errors()); } return $this->response($this->formatErrors($validator)); }
public function throwStoreResourceFailedException($message = 'Failed to store your requested resource.', Validator $validator = null) { if ($validator instanceof Validator) { throw new \Dingo\Api\Exception\StoreResourceFailedException($message, $validator->errors()); } else { throw new \Dingo\Api\Exception\StoreResourceFailedException($message); } }
protected function formatErrors(Validator $validator) { $errors = $this->parseErrorRest($validator->errors()->getMessages()); $response = new ResponseWService(); $response->setDataResponse(ResponseWService::HEADER_HTTP_RESPONSE_SOLICITUD_INCORRECTA, array(), $errors, 'Datos Invalidos del formulario'); $response->response(); // return $validator->errors()->all(); }
/** * Format error messages for ajax requests * * @param Validator $validator * @return array * @internal param Request $request */ protected function formatErrors(Validator $validator) { $errors = $validator->errors()->all(); $error = ''; foreach ($errors as $errorMessage) { $error = $errorMessage; } return ['success' => false, 'title' => trans('common.fail'), 'message' => $error]; }
/** * Store a newly created resource in storage. * * @return Response */ public function store(Validator $validator, Request $request) { $messages = $validator->errors(); $request->session()->flash('status', 'Task was successful!'); foreach ($messages->all() as $message) { print_r($message); } exit; }
/** * @param Validator $validator * @return array */ protected function formatErrors(Validator $validator) { $messages = $validator->errors(); $errors = []; foreach ($this->fields as $field) { if (!$messages->has($field)) { continue; } $errors[$field] = $messages->first($field); } return $errors; }
/** * @param Validator $validator * @return array */ protected function formatErrors(Validator $validator) { $messages = $validator->errors(); $fields = ['email', 'password', 'password_confirmation', 'token']; $errors = []; foreach ($fields as $field) { if (!$messages->has($field)) { continue; } $errors[$field] = $messages->first($field); } return $errors; }
/** * @param Validator $validator * @return array */ protected function formatErrors(Validator $validator) { $messages = $validator->errors(); $fields = ['product_code', 'product_price', 'product_page', 'product_discount', 'product_quantity']; $errors = []; foreach ($fields as $field) { if (!$messages->has($field)) { continue; } $errors[$field] = $messages->first($field); } return $errors; }
/** * @param Validator $validator * @return array */ protected function formatErrors(Validator $validator) { $messages = $validator->errors(); $fields = ['question_category_id', 'question_content', 'question_title']; $errors = []; foreach ($fields as $field) { if (!$messages->has($field)) { continue; } $errors[$field] = $messages->first($field); } return $errors; }
/** * {@inheritdoc} */ protected function formatValidationErrors(Validator $validator) { return $validator->errors()->all(); }
/** * Make validation error response. * * @param \Illuminate\Contracts\Validation\Validator $validator * @return \Illuminate\Http\JsonResponse */ protected function respondValidationError(Validator $validator) { return json()->unprocessableError($validator->errors()->all()); }
/** * Format the validation errors to be returned. * * @param \Illuminate\Contracts\Validation\Validator $validator * @return array */ protected function formatValidationErrors(Validator $validator) { return $validator->errors()->getMessages(); }
/** * @param Validator $validator * * @throws ValidationHttpException */ protected function failedValidation(Validator $validator) { throw new ValidationHttpException($validator->errors()); }
/** * @param Validator $validator * * @return array */ protected function formatErrors(Validator $validator) { $message = $validator->errors(); return ['success' => false, 'validation' => ['judul' => $message->first('judul'), 'uraian' => $message->first('uraian'), 'tahun' => $message->first('tahun'), 'tanggal_beli' => $message->first('tanggal_beli'), 'harga' => $message->first('harga'), 'gambar' => $message->first('gambar'), 'penulis_id' => $message->first('penulis_id'), 'penerbit_id' => $message->first('penerbit_id'), 'kategori_id' => $message->first('kategori_id')]]; }
/** * @param Validator $validator * * @return array */ protected function formatErrors(Validator $validator) { $message = $validator->errors(); return ['success' => false, 'validation' => ['email' => $message->first('email'), 'password' => $message->first('password')]]; }
/** * {@inheritdoc} */ protected function formatErrors(Validator $validator) { return ['message' => 'Validation Error', 'errors' => $validator->errors()]; }
/** * {@inheritdoc} */ protected function formatErrors(Validator $validator) { $messages = ['required' => 'Por favor preencha todos os campos, com mais de 5 caracteres, em cada campo.']; return $validator->errors()->all($messages); }
/** * @param Validator $validator * * @return array */ protected function formatErrors(Validator $validator) { $message = $validator->errors(); return ['success' => false, 'validation' => ['nama' => $message->first('nama'), 'alamat' => $message->first('alamat'), 'visi' => $message->first('visi'), 'misi' => $message->first('misi'), 'tahun' => $message->first('tahun'), 'jumlah_buku' => $message->first('jumlah_buku')]]; }
/** * Throw the failed validation exception. * * @param \Illuminate\Http\Request $request * @param \Illuminate\Contracts\Validation\Validator $validator * @return void */ protected function throwValidationException(Request $request, $validator) { throw new ValidationException($validator->errors()); }
/** * {@inheritdoc} */ protected function formatErrors(Validator $validator) { $messages = ['required' => 'Por favor preencha todos os campos.']; return $validator->errors()->all($messages); }
/** * @param Validator $validator * * @return array */ protected function formatErrors(Validator $validator) { $message = $validator->errors(); return ['success' => false, 'validation' => ['keluarga_id' => $message->first('keluarga_id'), 'nik' => $message->first('nik'), 'nama' => $message->first('nama'), 'kelamin' => $message->first('kelamin'), 'tempat_lahir' => $message->first('tempat_lahir'), 'tanggal_lahir' => $message->first('tanggal_lahir'), 'golongan_darah' => $message->first('golongan_darah'), 'agama' => $message->first('agama'), 'status_kawin' => $message->first('status_kawin'), 'status_keluarga' => $message->first('status_keluarga'), 'title_depan' => $message->first('title_depan'), 'title_belakang' => $message->first('title_belakang'), 'pendidikan' => $message->first('pendidikan'), 'pekerjaan' => $message->first('pekerjaan')]]; }
protected function formatValidationErrors(Validator $validator) { return ['validation_error' => $validator->errors()->getMessages()]; }
/** * {@inheritdoc} */ protected function formatErrors(Validator $validator) { $messages = ['required' => 'Por favor insira uma quantidade numérica!']; return $validator->errors()->all($messages); }