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


PHP Validator::errors方法代码示例

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


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

示例1: formatErrors

 protected function formatErrors(Validator $validator)
 {
     if (count($validator->errors()->getMessages()) > 8) {
         return [trans('messages.many-errors')];
     }
     return $validator->errors()->all();
 }
开发者ID:Tisho84,项目名称:conference,代码行数:7,代码来源:DepartmentRequest.php

示例2: formatErrors

 public function formatErrors(Validator $validator)
 {
     foreach ($validator->errors()->all() as $error) {
         Notifications::add($error, 'danger');
     }
     return $validator->errors()->getMessages();
 }
开发者ID:vitos8686,项目名称:0ez,代码行数:7,代码来源:StoreCategoryRequest.php

示例3: formatValidationErrors

 protected function formatValidationErrors(Validator $validator)
 {
     foreach ($validator->errors()->getMessages() as $key => $message) {
         if (starts_with($key, 'roles')) {
             $validator->errors()->add('roles', $message[0]);
         }
     }
     return $validator->errors()->getMessages();
 }
开发者ID:Aphix-Labs,项目名称:laravel-aphix-boilerplate,代码行数:9,代码来源:UsersController.php

示例4: failedValidation

 /**
  * Handle a failed validation attempt.
  *
  * @param \Illuminate\Contracts\Validation\Validator $validator
  *
  * @return void
  */
 protected function failedValidation(Validator $validator)
 {
     if ($this->container['request'] instanceof Request) {
         throw new ValidationHttpException($validator->errors());
     }
     parent::failedValidation($validator);
 }
开发者ID:dingo,项目名称:api,代码行数:14,代码来源:FormRequest.php

示例5: formatErrors

 public function formatErrors(Validator $validator)
 {
     $repeatedAttendee = false;
     $emptyNames = false;
     $errors = $validator->errors()->all();
     foreach ($errors as $index => $error) {
         if (fnmatch('The selected user id.* is invalid.', $error)) {
             // Removes from array; can still iterate through array with foreach
             unset($errors[$index]);
             $repeatedAttendee = true;
         } else {
             if (fnmatch('The name.* field is required.', $error)) {
                 unset($errors[$index]);
                 $emptyNames = true;
             }
         }
     }
     // Pushes more descriptive error message onto array
     if ($repeatedAttendee) {
         array_push($errors, 'The same attendee has been entered in the attendance list more than once.');
     }
     if ($emptyNames) {
         array_push($errors, 'One of the names of the listed attendees has not been provided.');
     }
     return $errors;
 }
开发者ID:natalieduong,项目名称:konnection,代码行数:26,代码来源:CreateActivityRequest.php

示例6: failedValidation

 /**
  * Handle a failed validation attempt.
  *
  * @param \Illuminate\Contracts\Validation\Validator $validator
  *
  * @return mixed
  */
 protected function failedValidation(Validator $validator)
 {
     if ($this->container['request'] instanceof BaseRequest) {
         throw new ApiValidationException($validator->errors(), $this->getFailedValidationMessage($this->container['request']));
     }
     parent::failedValidation($validator);
 }
开发者ID:jenky,项目名称:laravel-api-starter,代码行数:14,代码来源:Request.php

示例7: failedValidationResponse

 /**
  * Get the response for a error validate.
  *
  * @param Validator $validator
  * @return \Illuminate\Http\Response
  */
 public function failedValidationResponse(Validator $validator)
 {
     if ($this->is('api/*')) {
         return \ResponseFractal::respondErrorWrongArgs($validator->errors());
     }
     return $this->response($this->formatErrors($validator));
 }
开发者ID:gdgfoz,项目名称:codelab-todo-api,代码行数:13,代码来源:BaseRequest.php

示例8: throwStoreResourceFailedException

 public function throwStoreResourceFailedException($message = 'Failed to store your requested resource.', Validator $validator = null)
 {
     if ($validator instanceof Validator) {
         throw new \Dingo\Api\Exception\StoreResourceFailedException($message, $validator->errors());
     } else {
         throw new \Dingo\Api\Exception\StoreResourceFailedException($message);
     }
 }
开发者ID:muhammadshakeel,项目名称:laravel-api-boilerplate-oauth,代码行数:8,代码来源:BaseController.php

示例9: 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,项目名称:buen,代码行数:8,代码来源:RequestWservice.php

示例10: formatErrors

 /**
  * Format error messages for ajax requests
  *
  * @param Validator $validator
  * @return array
  * @internal param Request $request
  */
 protected function formatErrors(Validator $validator)
 {
     $errors = $validator->errors()->all();
     $error = '';
     foreach ($errors as $errorMessage) {
         $error = $errorMessage;
     }
     return ['success' => false, 'title' => trans('common.fail'), 'message' => $error];
 }
开发者ID:bitller,项目名称:nova,代码行数:16,代码来源:AjaxRequest.php

示例11: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Validator $validator, Request $request)
 {
     $messages = $validator->errors();
     $request->session()->flash('status', 'Task was successful!');
     foreach ($messages->all() as $message) {
         print_r($message);
     }
     exit;
 }
开发者ID:system3d,项目名称:consultas-tecnicas,代码行数:14,代码来源:UserController.php

示例12: formatErrors

 /**
  * @param Validator $validator
  * @return array
  */
 protected function formatErrors(Validator $validator)
 {
     $messages = $validator->errors();
     $errors = [];
     foreach ($this->fields as $field) {
         if (!$messages->has($field)) {
             continue;
         }
         $errors[$field] = $messages->first($field);
     }
     return $errors;
 }
开发者ID:bitller,项目名称:nova,代码行数:16,代码来源:AjaxRequestWithFormedErrors.php

示例13: formatErrors

 /**
  * @param Validator $validator
  * @return array
  */
 protected function formatErrors(Validator $validator)
 {
     $messages = $validator->errors();
     $fields = ['email', 'password', 'password_confirmation', 'token'];
     $errors = [];
     foreach ($fields as $field) {
         if (!$messages->has($field)) {
             continue;
         }
         $errors[$field] = $messages->first($field);
     }
     return $errors;
 }
开发者ID:bitller,项目名称:nova,代码行数:17,代码来源:CreateAccountRequest.php

示例14: formatErrors

 /**
  * @param Validator $validator
  * @return array
  */
 protected function formatErrors(Validator $validator)
 {
     $messages = $validator->errors();
     $fields = ['product_code', 'product_price', 'product_page', 'product_discount', 'product_quantity'];
     $errors = [];
     foreach ($fields as $field) {
         if (!$messages->has($field)) {
             continue;
         }
         $errors[$field] = $messages->first($field);
     }
     return $errors;
 }
开发者ID:bitller,项目名称:nova,代码行数:17,代码来源:AddProductRequest.php

示例15: formatErrors

 /**
  * @param Validator $validator
  * @return array
  */
 protected function formatErrors(Validator $validator)
 {
     $messages = $validator->errors();
     $fields = ['question_category_id', 'question_content', 'question_title'];
     $errors = [];
     foreach ($fields as $field) {
         if (!$messages->has($field)) {
             continue;
         }
         $errors[$field] = $messages->first($field);
     }
     return $errors;
 }
开发者ID:bitller,项目名称:nova,代码行数:17,代码来源:AskQuestionRequest.php


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