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


PHP Validator::failed方法代碼示例

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


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

示例1: validate

 public function validate()
 {
     $data = $this->toArray();
     $this->validator = Validator::make($data, $this->getSingleValidator());
     $result = !$this->validator->fails();
     $this->failed = $this->validator->failed();
     foreach ($this->getAllValidators() as $key => $validate) {
         $validator = Validator::make($data[$key], $validate->getSingleValidator());
         $result = !$validator->fails() && $result;
         if ($validator->fails()) {
             $this->failed = array_merge($this->failed, [$key => $validator->failed()]);
         }
     }
     return $result;
 }
開發者ID:agustincarmona,項目名稱:laravel-api-restful-schema,代碼行數:15,代碼來源:PropertyBagValidate.php

示例2: __construct

 /**
  * ValidationException constructor.
  *
  * @author Morten Rugaard <moru@nodes.dk>
  * @param  \Illuminate\Validation\Validator $validator
  * @param  array                            $errorCodes
  * @param  array                            $headers
  * @param  bool                          $report
  * @param  string                           $severity
  */
 public function __construct(IlluminateValidator $validator, array $errorCodes, array $headers = [], $report = false, $severity = 'error')
 {
     // Parse failed rules
     $failedRules = $this->parseFailedRules($validator->failed());
     // Set message of exception
     $errorMessages = $validator->errors();
     if ($errorMessages->count() > 1) {
         $message = 'Multiple validation rules failed. See "errors" for more details.';
     } else {
         $message = $errorMessages->first();
     }
     // Custom error codes container
     $customErrorCodes = [];
     // Custom error codes takes priority, so let's see
     // if one of our failed rules has one
     $failedRulesCustomErrorCodes = array_intersect(array_keys($errorCodes), $failedRules);
     if (!empty($failedRulesCustomErrorCodes)) {
         foreach ($failedRulesCustomErrorCodes as $failedRule) {
             $customErrorCodes[$errorCodes[$failedRule]] = $errorCodes[$failedRule];
         }
     }
     // Determine exception and status code
     $exceptionCode = $statusCode = !empty($customErrorCodes) ? array_shift($customErrorCodes) : 412;
     // Construct exception
     parent::__construct($message, $exceptionCode, $headers, $report, $severity);
     // Fill exception's error bag with validation errors
     $this->setErrors($errorMessages);
     // Set status code
     $this->setStatusCode($statusCode, $errorMessages->first());
     // Do not send report
     $this->dontReport();
 }
開發者ID:nodes-php,項目名稱:validation,代碼行數:42,代碼來源:ValidationException.php

示例3: failed

 /**
  * {@inheritDoc}
  */
 public function failed()
 {
     return $this->validator->failed();
 }
開發者ID:bratter,項目名稱:petal,代碼行數:7,代碼來源:Result.php

示例4: getFailedRules

 /**
  * @return array
  */
 public function getFailedRules()
 {
     return $this->validator->failed();
 }
開發者ID:kodicms,項目名稱:laravel-api,代碼行數:7,代碼來源:ValidationException.php

示例5: setValidator

 /**
  * 
  * @param Validator $object
  */
 public function setValidator(Validator $object)
 {
     $this->_messages = $object->errors()->getMessages();
     $this->_rules = $object->failed();
 }
開發者ID:BlueCatTAT,項目名稱:kodicms-laravel,代碼行數:9,代碼來源:ValidationException.php


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