当前位置: 首页>>代码示例>>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;未经允许,请勿转载。