当前位置: 首页>>代码示例>>PHP>>正文


PHP Validator::getMessageBag方法代码示例

本文整理汇总了PHP中Illuminate\Validation\Validator::getMessageBag方法的典型用法代码示例。如果您正苦于以下问题:PHP Validator::getMessageBag方法的具体用法?PHP Validator::getMessageBag怎么用?PHP Validator::getMessageBag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Illuminate\Validation\Validator的用法示例。


在下文中一共展示了Validator::getMessageBag方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: validationFails

 public function validationFails(Validator $validator)
 {
     $this->success = false;
     $this->errors = $validator->getMessageBag();
     $this->validationErrors = $validator->getMessageBag();
     return $this->toJson();
 }
开发者ID:rbmowatt,项目名称:alohalbi.surf,代码行数:7,代码来源:ApiResponse.php

示例2: fetchMessages

 /**
  * fetch error messages from validator and optionally prepend them with a custom message
  * @param Validator $validator
  */
 protected function fetchMessages(Validator $validator)
 {
     /**
      * $errors array is constructed like: field1 => array(0 => 'error message 1', 1 => 'error message 2' ...)
      * I will prepend the custom error message (added by addValidation()) to this messages array per field
      */
     $this->errors = $validator->getMessageBag()->getMessages();
     foreach ($this->errors as $name => &$messages) {
         if (!empty($this->validations[$name]['message'])) {
             $attributeName = str_replace('_', ' ', $name);
             $customMessage = str_replace(':attribute', $attributeName, $this->validations[$name]['message']);
             array_unshift($messages, $customMessage);
         }
     }
 }
开发者ID:winkbrace,项目名称:winkform,代码行数:19,代码来源:FormValidator.php

示例3: getMessageBag

 public function getMessageBag()
 {
     return $this->validator->getMessageBag();
 }
开发者ID:Junyue,项目名称:zidisha2,代码行数:4,代码来源:AbstractForm.php

示例4: setResponse

 /**
  * Set the response based on validation.
  *
  * @param Validator   $validator
  * @param FormBuilder $builder
  */
 protected function setResponse(Validator $validator, FormBuilder $builder)
 {
     if (!$validator->passes()) {
         $builder->setSave(false);
         $bag = $validator->getMessageBag();
         foreach ($bag->getMessages() as $field => $messages) {
             foreach ($messages as $message) {
                 $builder->addFormError($field, $message);
             }
         }
         $this->dispatch(new SetErrorMessages($builder));
     }
     $this->dispatch(new RepopulateFields($builder));
 }
开发者ID:huglester,项目名称:streams-platform,代码行数:20,代码来源:FormValidator.php

示例5: setResponse

 /**
  * Set the response based on validation.
  *
  * @param Validator   $validator
  * @param FormBuilder $builder
  */
 protected function setResponse(Validator $validator, FormBuilder $builder)
 {
     if (!$validator->passes()) {
         $builder->setSave(false)->setFormErrors($validator->getMessageBag());
         $this->dispatch(new SetErrorMessages($builder));
     }
     $this->dispatch(new RepopulateFields($builder));
 }
开发者ID:jacksun101,项目名称:streams-platform,代码行数:14,代码来源:FormValidator.php


注:本文中的Illuminate\Validation\Validator::getMessageBag方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。