當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Validator::getMessageBag方法代碼示例

本文整理匯總了PHP中Illuminate\Contracts\Validation\Validator::getMessageBag方法的典型用法代碼示例。如果您正苦於以下問題:PHP Validator::getMessageBag方法的具體用法?PHP Validator::getMessageBag怎麽用?PHP Validator::getMessageBag使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Illuminate\Contracts\Validation\Validator的用法示例。


在下文中一共展示了Validator::getMessageBag方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getErrors

 /**
  * Get validation errors
  *
  * @return array
  */
 public function getErrors()
 {
     if (!$this->validator || !$this->validator instanceof Validator) {
         throw new \InvalidArgumentException(sprintf('Form %s was not validated. To validate it, call "isValid" method before retrieving the errors', get_class($this)));
     }
     return $this->validator->getMessageBag()->getMessages();
 }
開發者ID:pnagaraju25,項目名稱:laravel-form-builder,代碼行數:12,代碼來源:Form.php

示例2: failedValidation

 protected function failedValidation(Validator $validator)
 {
     if ($this->ajax()) {
         $this->session()->flashInput($this->all());
         $this->session()->flash('errors', $validator->getMessageBag());
     }
     parent::failedValidation($validator);
 }
開發者ID:vainproject,項目名稱:vain-blog,代碼行數:8,代碼來源:CommentFormRequest.php

示例3: failedValidation

 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)));
 }
開發者ID:milosodalovic,項目名稱:newsletter,代碼行數:15,代碼來源:SubscriptionRequest.php

示例4: formatErrors

 /**
  * Formats the validators errors to allow any number of security questions.
  *
  * @param Validator $validator
  *
  * @return array
  */
 protected function formatErrors(Validator $validator)
 {
     $errors = $validator->getMessageBag()->toArray();
     $processed = [];
     foreach ($errors as $key => $error) {
         $parts = explode('.', $key);
         // If we have exactly two parts, we can work with the error message.
         if (count($parts) === 2) {
             list($name, $key) = $parts;
             $field = sprintf('%s[%s]', $name, $key);
             $processed[$field] = $error;
         }
     }
     return $processed;
 }
開發者ID:stevebauman,項目名稱:ithub,代碼行數:22,代碼來源:QuestionRequest.php

示例5: formatErrors

 /**
  * Format the errors from the given Validator instance.
  *
  * @param  \Illuminate\Contracts\Validation\Validator  $validator
  * @return array
  */
 protected function formatErrors(Validator $validator)
 {
     return $validator->getMessageBag()->toArray();
 }
開發者ID:ziracmo,項目名稱:Projet-transversal-2,代碼行數:10,代碼來源:FormRequest.php

示例6: errorWrongArgsValidator

 /**
  * Generates a Response with a 400 HTTP header and a given message from validator
  *
  * @param Validator $validator
  * @return ResponseFactory
  */
 public function errorWrongArgsValidator(Validator $validator)
 {
     return $this->errorWrongArgs($validator->getMessageBag()->toArray());
 }
開發者ID:antho-firuze,項目名稱:api-response,代碼行數:10,代碼來源:Response.php

示例7: addValidatorErrors

 /**
  * @param Validator $validator
  */
 protected function addValidatorErrors(Validator $validator)
 {
     $messages = $validator->getMessageBag();
     $this->addErrors($this->errorFactory->filterParametersMessages($messages));
 }
開發者ID:cloudcreativity,項目名稱:laravel-json-api,代碼行數:8,代碼來源:FilterValidator.php

示例8: pushValidation

 /**
  * Creates an alert from the result of validator.
  *
  * The type of the alert will be TYPE_VALIDATION
  *
  * @param Validator $validator
  * @param null $title
  * @param null $view
  */
 public function pushValidation(Validator $validator, $title = null, $view = null)
 {
     $messages = $validator->getMessageBag()->all();
     $this->push($messages, Alert::TYPE_VALIDATION, $title, $view);
 }
開發者ID:MarkVaughn,項目名稱:illuminated,代碼行數:14,代碼來源:AlertManager.php

示例9: getData

 /**
  * Get the error data.
  *
  * @return array|null
  */
 public function getData()
 {
     return ['fields' => $this->validator->getMessageBag()->toArray()];
 }
開發者ID:flugger,項目名稱:laravel-responder,代碼行數:9,代碼來源:ValidationFailedException.php

示例10: addValidatorErrors

 /**
  * @param Validator $validator
  */
 protected function addValidatorErrors(Validator $validator)
 {
     $messages = $validator->getMessageBag();
     $this->addErrors($this->errorFactory->resourceInvalidAttributesMessages($messages));
 }
開發者ID:cloudcreativity,項目名稱:laravel-json-api,代碼行數:8,代碼來源:AttributesValidator.php

示例11: throwValidationException

 /**
  * Throw the failed validation exception.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Illuminate\Contracts\Validation\Validator  $validator
  * @return void
  *
  * @throws ResourceException
  */
 protected function throwValidationException(Request $request, $validator)
 {
     throw new ResourceException($this->failedValidationMessage, $validator->getMessageBag());
 }
開發者ID:chico-rei,項目名稱:restify,代碼行數:13,代碼來源:BaseController.php

示例12: formatValidationErrors

 /**
  * Format the validation errors to be returned.
  *
  * @param  \Illuminate\Contracts\Validation\Validator  $validator
  * @return array
  */
 protected function formatValidationErrors(\Illuminate\Contracts\Validation\Validator $validator)
 {
     zbase_alert(\Zbase\Zbase::ALERT_ERROR, $validator->getMessageBag(), ['formvalidation' => true]);
     return $validator->errors()->getMessages();
 }
開發者ID:claremontdesign,項目名稱:zbase,代碼行數:11,代碼來源:Controller.php


注:本文中的Illuminate\Contracts\Validation\Validator::getMessageBag方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。