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