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


PHP Parameter::validate方法代碼示例

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


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

示例1: validate

 /**
  * If the parameter is required, checks that it has been set.
  * Checks the value complies with minimal and maximal length.
  * Checks the value validates the rule sets with setValidateType().
  * 
  * @return void
  * @throws UserError When the value doesn't comply with the requirements.
  */
 public function validate()
 {
     parent::validate();
     // When the parameter is required, checks that it has been set.
     $value = $this->getValue();
     $length = strlen($value);
     if ($length < $this->getMinimalLength()) {
         Tools::ThrowUserError(wfMessage('wfmk-validation-error', $this->getName(), $value, wfMessage('wfmk-min-length', $this->getMinimalLength())));
     } elseif ($this->getMaximalLength() != 0 && $length > $this->getMaximalLength()) {
         Tools::ThrowUserError(wfMessage('wfmk-validation-error', $this->getName(), $value, wfMessage('wfmk-max-length', $this->getMaximalLength())));
     } elseif (!Tools::Validate($value, $this->validate_type)) {
         Tools::ThrowUserError(wfMessage('wfmk-validation-error', $this->getName(), $value, wfMessage('wfmk-string-validate-type', $this->validate_type)));
     }
 }
開發者ID:eFFemeer,項目名稱:seizamcore,代碼行數:22,代碼來源:String.php

示例2: validate

 /**
  * If the parameter is required, checks that it has been set.
  * 
  * Check that the value complies with the minimum and maximum values.
  * 
  * @return void
  *When @throws UserError <ul>
  * <li>When the parameter is required and not set.</li>
  * <li>When value doesn't complies with the minimum and the maximum.</li>
  * </ul>
  */
 public function validate()
 {
     parent::validate();
     // If the parameter is required, checks that it has been set.
     $value = $this->getValue();
     $min = $this->getMin();
     if (!is_null($min)) {
         if ($value < $min) {
             Tools::ThrowUserError(wfMessage('wfmk-validation-error', $this->getName(), $value, wfMessage('wfmk-min-value', $min)));
         }
     }
     $max = $this->getMax();
     if (!is_null($max)) {
         if ($value > $max) {
             Tools::ThrowUserError(wfMessage('wfmk-validation-error', $this->getName(), $value, wfMessage('wfmk-max-value', $max)));
         }
     }
 }
開發者ID:eFFemeer,項目名稱:seizamcore,代碼行數:29,代碼來源:Integer.php

示例3: validate

 /**
  * If the xor-parameter is required, checks that a sub-parameter
  * has been set.
  * 
  * If a sub-parameter has been set, calls its validate() method.
  * 
  * @return void
  * @throws UserError
  */
 public function validate()
 {
     parent::validate();
     // If the parameter is required, checks that it has been set.
     $parameter = $this->getParameter();
     if (!is_null($parameter)) {
         $parameter->validate();
     }
 }
開發者ID:eFFemeer,項目名稱:seizamcore,代碼行數:18,代碼來源:XorParameter.php


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