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


PHP Validator::messages方法代碼示例

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


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

示例1: messages

 /**
  * Returns validation errors, if any
  *
  * @return MessageBag
  */
 public function messages()
 {
     if (is_null($this->validator)) {
         $this->validate();
     }
     if (!$this->validator->fails()) {
         return App::make(MessageBag::class);
     }
     return $this->validator->messages();
 }
開發者ID:pixelindustries,項目名稱:extended-validators,代碼行數:15,代碼來源:ValidatableTrait.php

示例2: messages

 /**
  * Returns validation errors, if any
  *
  * @return \Illuminate\Contracts\Support\MessageBag
  */
 public function messages()
 {
     if (is_null($this->validator)) {
         $this->validate();
     }
     if (!$this->validator->fails()) {
         return app('\\Illuminate\\Support\\Messagebag');
     }
     return $this->validator->messages();
 }
開發者ID:czim,項目名稱:laravel-dataobject,代碼行數:15,代碼來源:ValidatableTrait.php

示例3: validate

 public function validate()
 {
     if ($this->validator->fails()) {
         $messages = [];
         foreach ($this->validator->messages()->all("The :key variable is not defined or invalid") as $var => $message) {
             $messages[] = $message;
         }
         $msg = 'The .env file has some problems. Please check config/laravel-env-validator.php' . PHP_EOL . implode(PHP_EOL, $messages);
         throw new Exception($msg);
     }
 }
開發者ID:mathiasgrimm,項目名稱:laravel-env-validator,代碼行數:11,代碼來源:EnvValidator.php

示例4: validate

 /**
  * Validate the data given with some optional rules and messages
  *
  * @param array $data
  * @param null $rules
  * @param array $messages
  * @param array $customAttributes
  * @return Validator|\Illuminate\Validation\Validator
  * @throws ValidationException
  */
 public function validate(array $data, $rules = null, array $messages = [], array $customAttributes = [])
 {
     $rules = $rules ?: $this->getRules();
     $messages = empty($messages) ? $this->messages : $messages;
     $customAttributes = empty($customAttributes) ? $this->customAttributes : $customAttributes;
     $this->validated = $this->validatorFactory->make($data, $rules, $messages, $customAttributes);
     if ($this->exceptionStatus) {
         if ($this->validated->fails()) {
             $e = new ValidationException($this->getFailMessage(), static::$statusCode, static::EXCEPTION_KEY);
             $e->setErrors($this->validated->messages());
             throw $e;
         }
     }
     return $this->validated;
 }
開發者ID:laratalks,項目名稱:validator,代碼行數:25,代碼來源:AbstractValidator.php

示例5: validate

 /**
  * @param array $data
  * @param array $rules
  * @param array $messages
  * @param array $customAttributes
  *
  * @return Validator|\Illuminate\Validation\Validator
  * @throw StoreResourceFailedException
  */
 public function validate(array $data, array $rules = [], array $messages = [], array $customAttributes = [])
 {
     if ($this->getScenario() !== null) {
         $scenarioRules = camel_case($this->getScenario() . 'Rules');
         if ($this->{$scenarioRules} !== null) {
             $rules = empty($rules) ? $this->{$scenarioRules} : array_merge($rules, $this->{$scenarioRules});
         }
     } else {
         $rules = empty($rules) ? $this->rules : array_merge($rules, $this->rules);
     }
     $messages = empty($messages) ? $this->messages : array_merge($messages, $this->messages);
     $customAttributes = empty($customAttributes) ? $this->customAttributes : array_merge($customAttributes, $this->customAttributes);
     $this->validated = $this->validatorFactory->make($data, $rules, $messages, $customAttributes);
     if ($this->validated->fails()) {
         throw new StoreResourceFailedException(trans('messages.validation_failed'), $this->validated->messages());
     }
     return $this->validated;
 }
開發者ID:tajrish,項目名稱:api,代碼行數:27,代碼來源:AbstractValidator.php

示例6: failedValidation

 /**
  * Handle a failed validation attempt.
  *
  * @param $validator
  *
  * @return mixed
  */
 protected function failedValidation(Validator $validator)
 {
     return response()->json($validator->messages(), 400);
 }
開發者ID:bjrnblm,項目名稱:blender,代碼行數:11,代碼來源:AddMediaRequest.php


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