當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。