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


PHP AbstractForm::validate方法代码示例

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


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

示例1: validate

 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     if (strlen($this->applicationText) > self::APPLICATION_TEXT_LENGTH) {
         throw new UserInputException('applicationText', 'notValid');
     }
 }
开发者ID:sonicmaster,项目名称:RPG,代码行数:10,代码来源:AllianceApplyForm.class.php

示例2: validate

 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     if ($this->action == 'rename') {
         if (!PlanetUtil::isValid($this->newName)) {
             throw new UserInputException('newName', 'notValid');
         }
     } else {
         if ($this->action == 'delete') {
             // main planet
             if (LWCore::getPlanet()->planetID == WCF::getUser()->id_planet) {
                 throw new SystemException('tried to delete main planet');
             }
             // password
             if (!WCF::getUser()->checkPassword($this->password)) {
                 throw new UserInputException('password', 'notValid');
             }
             // check fleets (moon, if existing and planet)
             if (LWCore::getPlanet()->planetKind == 1 && LWCore::getPlanet()->getMoon() != null) {
                 if (count(Fleet::getByPlanetID(LWCore::getPlanet()->getMoon()->planetID, Fleet::OFIARA | Fleet::OWNER))) {
                     throw new UserInputException('password', 'activityMoon');
                 }
             }
             // check current
             if (count(Fleet::getByPlanetID(LWCore::getPlanet()->planetID, Fleet::OFIARA | Fleet::OWNER))) {
                 throw new UserInputException('password', 'activity');
             }
         }
     }
 }
开发者ID:sonicmaster,项目名称:RPG,代码行数:33,代码来源:PlanetActionsForm.class.php

示例3: validate

 /**
  * @see Form::validate()
  */
 public function validate()
 {
     AbstractForm::validate();
     if ($this->applicationStatus < 0 || $this->applicationStatus > 3) {
         throw new UserInputException('applicationStatus');
     }
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:10,代码来源:UserGroupLeaderApplicationEditForm.class.php

示例4: validate

 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     if (empty($this->reason)) {
         throw new UserInputException('reason');
     }
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:10,代码来源:UserGroupApplyForm.class.php

示例5: validate

 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     if (strlen($this->circularText) > self::CIRCULAR_TEXT_LENGTH) {
         throw new UserInputException('answerText', 'notValid');
     }
 }
开发者ID:sonicmaster,项目名称:RPG,代码行数:10,代码来源:AllianceCircularCreateForm.class.php

示例6: validate

 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     if (empty($this->usernames)) {
         throw new UserInputException('usernames');
     }
     // explode multiple usernames to an array
     $usernameArray = explode(',', $this->usernames);
     $error = array();
     // loop through users
     foreach ($usernameArray as $username) {
         $username = StringUtil::trim($username);
         if (empty($username)) {
             continue;
         }
         try {
             // get user
             $user = new UserEditor(null, null, $username);
             if (!$user->userID) {
                 throw new UserInputException('username', 'notFound');
             }
             // no error
             $this->users[] = $user;
         } catch (UserInputException $e) {
             $error[] = array('type' => $e->getType(), 'username' => $username);
         }
     }
     if (count($error)) {
         throw new UserInputException('usernames', $error);
     }
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:34,代码来源:UserGroupAdministrateForm.class.php

示例7: validate

 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     if (empty($this->fromYear) || $this->fromYear > $this->toYear || $this->fromYear < ICSHE_MINYEAR || $this->toYear > ICSHE_MAXYEAR) {
         throw new UserInputException('timeFrame');
     }
     if (empty($this->country)) {
         throw new UserInputException('country');
     }
 }
开发者ID:Maggan22,项目名称:wbb3addons,代码行数:13,代码来源:IcsHolidayExporterForm.class.php

示例8: validate

 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     // error handling
     if (empty($this->username)) {
         throw new UserInputException('username');
     }
     if (empty($this->password)) {
         throw new UserInputException('password');
     }
     $this->validateUser();
 }
开发者ID:CaribeSoy,项目名称:contest-wcf,代码行数:15,代码来源:LoginForm.class.php

示例9: validate

 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     foreach ($this->activeOptions as $key => $option) {
         try {
             $this->validateOption($key, $option);
         } catch (UserInputException $e) {
             $this->errorType[$e->getField()] = $e->getType();
         }
     }
     if (count($this->errorType) > 0) {
         throw new UserInputException('options', $this->errorType);
     }
 }
开发者ID:CaribeSoy,项目名称:contest-wcf,代码行数:17,代码来源:DynamicOptionListForm.class.php

示例10: validate

 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     $this->loadPlanetData();
     foreach ($this->planetObjs as $planetObj) {
         if (isset($_POST['planet' . $planetObj->planetID])) {
             $sortID = intval($_POST['planet' . $planetObj->planetID]);
             while (isset($this->planets[$sortID])) {
                 ++$sortID;
             }
             $this->planets[$sortID] = $planetObj->planetID;
         }
     }
 }
开发者ID:sonicmaster,项目名称:RPG,代码行数:17,代码来源:PlanetSortForm.class.php

示例11: validate

 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     // get user
     require_once WCF_DIR . 'lib/data/user/UserEditor.class.php';
     $this->user = new UserEditor($this->userID);
     if (!$this->user->userID) {
         throw new UserInputException('userID', 'invalid');
     }
     if (!$this->user->lostPasswordKey) {
         throw new UserInputException('lostPasswordKey');
     }
     if ($this->user->lostPasswordKey != $this->lostPasswordKey) {
         throw new UserInputException('lostPasswordKey', 'invalid');
     }
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:19,代码来源:NewPasswordForm.class.php

示例12: validate

 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     if (empty($this->email)) {
         throw new UserInputException('email');
     }
     $sql = 'SELECT COUNT(email) AS count
     		FROM wcf' . WCF_N . '_' . $this->subscriberTable . "\n        \t\tWHERE email = '" . escapeString($this->email) . "'";
     $row = WCF::getDB()->getFirstRow($sql);
     if ($row['count']) {
         throw new UserInputException('email', 'notUnique');
     }
     if (!$this->checkbox) {
         throw new UserInputException('checkbox', 'notAgreed');
     }
 }
开发者ID:CaribeSoy,项目名称:Newsletter-System,代码行数:19,代码来源:NewsletterRegisterGuestForm.class.php

示例13: validate

 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     if ($this->agreed === null) {
         throw new UserInputException('agreed', 'notValid');
     }
     if (strlen($this->answerText) > self::ANSWER_TEXT_LENGTH) {
         throw new UserInputException('answerText', 'notValid');
     }
     // check for application
     $sql = "SELECT COUNT(*)\r\n\t\t\t\t\t\tAS count\r\n\t\t\t\tFROM ugml_users\r\n\t\t\t\tWHERE ally_request = " . WCF::getUser()->ally_id . "\r\n\t\t\t\t\tAND id = " . $this->userID;
     $result = WCF::getDB()->getFirstRow($sql);
     if ($result['count'] != 1) {
         require_once WCF_DIR . 'lib/system/exception/IllegalLinkException.class.php';
         throw new IllegalLinkException();
     }
 }
开发者ID:sonicmaster,项目名称:RPG,代码行数:20,代码来源:AllianceApplicationViewForm.class.php

示例14: validate

 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     // title
     if (empty($this->title)) {
         throw new UserInputException('title');
     }
     // conditions
     if (!count($this->ruleConditions)) {
         throw new UserInputException('ruleConditions');
     }
     foreach ($this->ruleConditions as $ruleCondition) {
         $type = isset($ruleCondition['type']) ? $ruleCondition['type'] : '';
         $condition = isset($ruleCondition['condition']) ? $ruleCondition['condition'] : '';
         $value = isset($ruleCondition['value']) ? $ruleCondition['value'] : '';
         // type
         if (!isset($this->availableRuleConditionTypes[$type])) {
             throw new UserInputException('ruleConditions');
         }
         // condition
         $availableConditions = $this->availableRuleConditionTypes[$type]->getAvailableConditions();
         if (count($availableConditions) > 0 && !isset($availableConditions[$condition])) {
             throw new UserInputException('ruleConditions');
         }
         // value
         $availableValues = $this->availableRuleConditionTypes[$type]->getAvailableValues();
         if ($this->availableRuleConditionTypes[$type]->getValueType() == 'text' && empty($value) || $this->availableRuleConditionTypes[$type]->getValueType() == 'options' && !isset($availableValues[$value])) {
             throw new UserInputException('ruleConditions');
         }
     }
     // operator
     if ($this->logicalOperator != 'and' && $this->logicalOperator != 'or' && $this->logicalOperator != 'nor') {
         throw new UserInputException('logicalOperator');
     }
     // action
     if (!isset($this->availableRuleActions[$this->ruleAction])) {
         throw new UserInputException('ruleAction');
     }
     // destination
     $availableDestinations = $this->availableRuleActions[$this->ruleAction]->getAvailableDestinations();
     if ($this->availableRuleActions[$this->ruleAction]->getDestinationType() == 'text' && empty($this->ruleDestination) || $this->availableRuleActions[$this->ruleAction]->getDestinationType() == 'options' && !isset($availableDestinations[$this->ruleDestination])) {
         throw new UserInputException('ruleAction');
     }
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:47,代码来源:PMRuleAddForm.class.php

示例15: validate

 public function validate()
 {
     $is_valid = parent::validate();
     if ($postcode = $this->getField('postcode')) {
         if ($postcode->isRequired()) {
             $country = $this->formatter->getCountry();
             if (!$country->checkZipCode($postcode->getValue())) {
                 // FIXME: the translator adapter is crap at the moment,
                 // but once it is not, the sprintf needs to go away.
                 $postcode->addError(sprintf($this->translator->trans('Invalid postcode - should look like "%1$s"', [], 'Shop.Forms.Errors'), $country->zip_code_format));
                 $is_valid = false;
             }
         }
     }
     if ($hookReturn = Hook::exec('actionValidateCustomerAddressForm', array('form' => $this)) != '') {
         $is_valid &= (bool) $hookReturn;
     }
     return $is_valid;
 }
开发者ID:M03G,项目名称:PrestaShop,代码行数:19,代码来源:CustomerAddressForm.php


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