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


PHP Validator::errors方法代码示例

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


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

示例1: error

 public function error()
 {
     if ($this->validator->errors()) {
         return $this->validator->errors()->first();
     }
     return null;
 }
开发者ID:fintech-fab,项目名称:bank-emulator,代码行数:7,代码来源:Input.php

示例2: callCustomCallback

 /**
  * Call the custom plan eligibility checker callback.
  *
  * @param  \Illuminate\Validation\Validator  $validator
  * @param  \Laravel\Spark\Plan  $plan
  * @return void
  */
 protected function callCustomCallback($validator, $plan)
 {
     try {
         if (!Spark::eligibleForTeamPlan($this->route('team'), $plan)) {
             $validator->errors()->add('plan', 'This team is not eligible for this plan.');
         }
     } catch (IneligibleForPlan $e) {
         $validator->errors()->add('plan', $e->getMessage());
     }
 }
开发者ID:defenestrator,项目名称:groid,代码行数:17,代码来源:DeterminesTeamPlanEligibility.php

示例3: runValidation

 /**
  * Validates the model.
  *
  * @param array $customRules
  * @param array $customMessages
  * @param array $attributeNames
  *
  * @return bool
  */
 protected function runValidation(array $customRules = [], array $customMessages = [], array $attributeNames = [])
 {
     $rules = empty($customRules) ? $this->getRules() : $customRules;
     $messages = empty($customMessages) ? $this->getCustomMessages() : $customMessages;
     $attributeNames = empty($attributeNames) ? $this->getAttributeNames() : $attributeNames;
     $attributes = $this->prepareAttributes();
     $this->validator = $this->makeValidator($attributes, $rules, $messages);
     $this->validator->setAttributeNames($attributeNames);
     $success = $this->validator->passes();
     if (!$success) {
         $this->setErrors($this->validator->errors());
     }
     return $success;
 }
开发者ID:vinicius73,项目名称:laravel-model-shield,代码行数:23,代码来源:ShieldValidator.php

示例4: __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

示例5: fieldHasError

 /**
  * Check if a field has any errors
  *
  * @param $field
  * @return mixed
  */
 public function fieldHasError($field)
 {
     if (!isset($this->validator)) {
         $this->validate();
     }
     return isset($this->validator->errors()->getMessages()[$field]);
 }
开发者ID:andyvenus,项目名称:laravel-forms,代码行数:13,代码来源:LaravelValidatorExtension.php

示例6: __construct

 public function __construct(Validator $validator)
 {
     $errors = '';
     foreach ($validator->errors()->getMessages() as $key => $messages) {
         $errors .= implode(' ', $messages) . ' ';
     }
     parent::__construct(422, trim($errors));
 }
开发者ID:antriver,项目名称:youtube-automator,代码行数:8,代码来源:ValidationException.php

示例7: formatErrors

 protected function formatErrors(Validator $validator)
 {
     $errors = $this->parseErrorRest($validator->errors()->getMessages());
     $response = new ResponseWService();
     $response->setDataResponse(ResponseWService::HEADER_HTTP_RESPONSE_SOLICITUD_INCORRECTA, array(), $errors, 'Datos Invalidos del formulario');
     $response->response();
     //            return $validator->errors()->all();
 }
开发者ID:josmel,项目名称:hostpots,代码行数:8,代码来源:RequestWservice.php

示例8: validateMaximumTeamsNotExceeded

 /**
  * Validate that the maximum number of teams hasn't been exceeded.
  *
  * @param  \Illuminate\Validation\Validator  $validator
  * @param  \Illuminate\Contracts\Auth\Authenticatable  $user
  * @return void
  */
 protected function validateMaximumTeamsNotExceeded($validator, $user)
 {
     if (!($plan = $user->sparkPlan())) {
         return;
     }
     if (is_null($plan->teams)) {
         return;
     }
     if ($plan->teams <= $user->ownedTeams()->count()) {
         $validator->errors()->add('name', 'Please upgrade your subscription to create more teams.');
     }
 }
开发者ID:defenestrator,项目名称:groid,代码行数:19,代码来源:CreateTeam.php

示例9: appendErrors

 public static function appendErrors(\Illuminate\Validation\Validator $validator)
 {
     foreach ($validator->errors()->all() as $message) {
         Session::push('field_validation_errors', $message);
     }
 }
开发者ID:kcattakcaz,项目名称:CALwebtool,代码行数:6,代码来源:SubmissionController.php

示例10: validateLocation

 /**
  * Validate that the request's location information agrees.
  *
  * @param  \Illuminate\Validation\Validator  $validator
  * @return void
  */
 protected function validateLocation($validator)
 {
     if (!app(StripeService::class)->tokenIsForCountry($this->stripe_token, $this->country)) {
         $validator->errors()->add('country', 'This country does not match the origin country of your card.');
     }
 }
开发者ID:defenestrator,项目名称:groid,代码行数:12,代码来源:ValidatesBillingAddresses.php

示例11: formatErrors

 protected function formatErrors(Validator $validator)
 {
     Session::flash('am-alert', ['type' => 'warning', 'data' => array_values($validator->errors()->all())]);
     return $validator->errors()->all();
 }
开发者ID:dalinhuang,项目名称:hi_xinxian_laravel_admin,代码行数:5,代码来源:Request.php

示例12: formatValidationErrors

 protected function formatValidationErrors(Validator $validator)
 {
     return $validator->errors()->all('<li>:message</li>');
 }
开发者ID:nikitasnv777,项目名称:mathtest,代码行数:4,代码来源:Controller.php

示例13: validator

 /**
  * Set error messages from a validator instance.
  *
  * @param Validator
  *
  * @return $this
  */
 public function validator(Validator $validator)
 {
     $this->attributes['message'] = $validator->errors()->all();
     return $this;
 }
开发者ID:marwelln,项目名称:notifier,代码行数:12,代码来源:Notify.php

示例14: formatValidationErrors

 /**
  * {@inheritdoc}
  */
 protected function formatValidationErrors(Validator $validator)
 {
     return ['errno' => 1, 'msg' => $validator->errors()->first()];
 }
开发者ID:printempw,项目名称:blessing-skin-server,代码行数:7,代码来源:Controller.php

示例15: formatValidationErrors

 protected function formatValidationErrors(Validator $validator)
 {
     $errors = ['status' => 400, 'errors' => $validator->errors()->getMessages()];
     return $errors;
 }
开发者ID:aririfani,项目名称:laravel-rest-api,代码行数:5,代码来源:Controller.php


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