当前位置: 首页>>代码示例>>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;未经允许,请勿转载。