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


PHP Validator::fails方法代碼示例

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


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

示例1: validate

 /**
  * Validate the form data
  *
  * @param array $formData
  * @param null $id
  * @throws \BB\Exceptions\FormValidationException
  * @return boolean
  */
 public function validate(array $formData, $id = null)
 {
     $this->validation = $this->validator->make($formData, $this->getValidationRules(['id' => $id]));
     if ($this->validation->fails()) {
         throw new FormValidationException('Validation failed', $this->getValidationErrors());
     }
     return true;
 }
開發者ID:adamstrawson,項目名稱:BBMembershipSystem,代碼行數:16,代碼來源:FormValidator.php

示例2: validate

 /**
  * Validate the form data
  *
  * @param array $data
  *
  * @return mixed
  * @throws ValidationException
  */
 public function validate(array $data)
 {
     $this->validation = $this->validator->make($data, $this->getValidationRules(), $this->getValidationMessages());
     if ($this->validation->fails()) {
         throw new ValidationException('Validation failed', $this->getValidationErrors());
     }
     return true;
 }
開發者ID:xintang22,項目名稱:Paxifi,代碼行數:16,代碼來源:Validator.php

示例3: validate

 /**
  * Validate the given data.
  *
  * @param array $data
  * @return bool
  * @throws ValidationException
  */
 public function validate(array $data = null)
 {
     $data = $data ?: $this->getInput();
     $this->validation = $this->validator->make($data, $this->rules(), $this->messages());
     if ($this->validation->fails()) {
         $this->failed();
     }
     return true;
 }
開發者ID:arwinjp,項目名稱:ODTS,代碼行數:16,代碼來源:Validator.php

示例4: validate

 /**
  * @param array $formData
  *
  * @throws FormValidationException
  */
 public function validate(array $formData)
 {
     // Instantiate validator instance by factory
     $this->validation = $this->validator->make($formData, $this->rules());
     // Validate
     if ($this->validation->fails()) {
         throw new FormValidationException('Validation Failed', $this->getValidationErrors());
     }
     return true;
 }
開發者ID:khoilv,項目名稱:cuongthuy,代碼行數:15,代碼來源:BaseForm.php

示例5: 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

示例6: validate

 public function validate(\Illuminate\Validation\Validator $validator)
 {
     if ($validator->fails()) {
         $this->validation_errors = $validator->messages();
         return false;
     }
     return true;
 }
開發者ID:fredlawl,項目名稱:planebox-api,代碼行數:8,代碼來源:PlaneBoxModel.php

示例7: validateOrFail

 public function validateOrFail($additional = array())
 {
     $attributes = $this->getAttributes();
     $this->validator = \Validator::make($attributes, $this->prepareRules());
     if ($this->validator->fails()) {
         $messages = $this->validator->messages();
         foreach ($attributes as $key => $value) {
             if ($messages->has($key)) {
                 foreach ($messages->get($key) as $message) {
                     $additional['attribute'] = $key;
                     $this->errors->add(new Error($message, '', $additional));
                 }
             }
         }
         throw new ValidationException($this->errors->errors());
     }
     return true;
 }
開發者ID:AniartUA,項目名稱:crm,代碼行數:18,代碼來源:BaseModel.php

示例8: validate

 /**
  * Validate data.
  *
  * @author Morten Rugaard <moru@nodes.dk>
  *
  * @return bool
  * @throws \Nodes\Validation\Exceptions\ValidationException
  */
 public function validate()
 {
     // Generate validator instance
     $this->validator = $this->validatorFactory->make($this->getData(), $this->getRules(), $this->getMessages(), $this->getAttributes());
     // Validation was a success!
     if (!$this->validator->fails()) {
         return true;
     }
     // Collect validation errors
     $this->errors = $this->validator->messages();
     return false;
 }
開發者ID:nodes-php,項目名稱:validation,代碼行數:20,代碼來源:AbstractValidator.php

示例9: validateData

 /**
  * Validates the supplied data against the options rules
  *
  * @param array		$data
  * @param array		$rules
  * @param array		$messages
  *
  * @param mixed
  */
 public function validateData(array $data, array $rules, array $messages)
 {
     if ($rules) {
         $this->customValidator->setData($data);
         $this->customValidator->setRules($rules);
         $this->customValidator->setCustomMessages($messages);
         //if the validator fails, kick back the errors
         if ($this->customValidator->fails()) {
             return implode('. ', $this->customValidator->messages()->all());
         }
     }
     return true;
 }
開發者ID:dmitriyuch,項目名稱:Laravel-Administrator,代碼行數:22,代碼來源:Config.php

示例10: fails

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

示例11: __construct

 public function __construct(Validator $validator)
 {
     if ($validator->fails()) {
         parent::__construct(json_encode($validator->errors()->getMessages()));
     }
 }
開發者ID:AudithSoftworks,項目名稱:Basis-API,代碼行數:6,代碼來源:ValidationException.php


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