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


PHP Zend_Validate_Int::isValid方法代码示例

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


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

示例1: testBasic

 /**
  * Ensures that the validator follows expected behavior
  *
  * @return void
  */
 public function testBasic()
 {
     $valuesExpected = array(array(1.0, true), array(0.0, true), array(0.01, false), array(-0.1, false), array(-1, true), array('10', true), array(1, true), array('not an int', false));
     foreach ($valuesExpected as $element) {
         $this->assertEquals($element[1], $this->_validator->isValid($element[0]));
     }
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:12,代码来源:IntTest.php

示例2: getTennisTableRanking

 /**
  * Get tennis table ranking by year and gender
  * @param int $year
  * @param int $gender Only 0 or 1. 0 => woman (WTA), 1 => man (ATP)
  * @return array|boolean
  * @author QuangTM
  */
 public function getTennisTableRanking($year, $gender)
 {
     // Get result
     $result = array();
     try {
         // Validate int
         $validInt = new Zend_Validate_Int();
         // Validate input
         if (!$validInt->isValid($year) || !$validInt->isValid($gender)) {
             return FALSE;
         }
         // Get DB Obj
         $dbObj = Thethao_Global::getDB('sport', 'slave');
         // Prepare SQL
         $stmt = $dbObj->prepare('CALL sp_tennis_getTennisRanking(:p_gender, :p_year);');
         // Bind param
         $stmt->bindParam('p_gender', $gender, PDO::PARAM_INT);
         $stmt->bindParam('p_year', $year, PDO::PARAM_INT);
         // Execute
         $stmt->execute();
         // Get format data
         $formatInstance = new Thethao_Business_Tennis_Metadata_Ranking();
         while ($row = $stmt->fetch()) {
             $result[$row['player_id']] = $formatInstance->init($row)->getFormatedData();
         }
         // Close
         $stmt->closeCursor();
         // Release variables
         unset($stmt);
     } catch (Exception $ex) {
         Thethao_Global::sendlog($ex, 1);
     }
     return $result;
 }
开发者ID:Nhan-Huynh-FO,项目名称:nhan-repo,代码行数:41,代码来源:Mysql.php

示例3: romanNumerals

 /**
  * The function below creates a roman numeral from a number
  * @param int $num
  * @return string
  * @uses Zend_Validate_Int
  */
 public function romanNumerals($date)
 {
     //Check if the number is an integer
     $validator = new Zend_Validate_Int();
     if ($validator->isValid($date)) {
         $n = intval($date);
         $res = '';
         /** Create the array of Roman numerals based on numbers
          */
         $roman_numerals = array('M' => 1000, 'CM' => 900, 'D' => 500, 'CD' => 400, 'C' => 100, 'XC' => 90, 'L' => 50, 'XL' => 40, 'X' => 10, 'IX' => 9, 'V' => 5, 'IV' => 4, 'I' => 1);
         foreach ($roman_numerals as $roman => $number) {
             /**
              * Divide number to get matches 
              */
             $matches = intval($n / $number);
             /**
              *  assign the roman char * $matches 
              */
             $res .= str_repeat($roman, $matches);
             /** 
              * subtract from the number 
              */
             $n = $n % $number;
         }
         /** return the resulting string as a roman numeral
          */
         return $res;
     }
 }
开发者ID:rwebley,项目名称:Beowulf---PAS,代码行数:35,代码来源:Romannumerals.php

示例4: _getValidator

 protected function _getValidator($value)
 {
     $validator = new \App_Validate_IsBoolean();
     if ($validator->isValid($value)) {
         return $validator;
     }
     $validator = new \Zend_Validate_Int();
     if ($validator->isValid($value)) {
         return $validator;
     }
     if (is_string($value)) {
         $validator = new \Zend_Validate_StringLength(array('max' => 2047));
         return $validator;
     }
     if ($value instanceof StructConfigModel) {
         return new StructConfigValidate(array('acceptArrayAsModel' => true));
     }
     if ($value instanceof ArrayConfigModel) {
         return new ArrayConfigValidate(array('acceptArrayAsModel' => true));
     }
     if (is_array($value)) {
         if (!empty($value)) {
             $keys = array_keys($value);
             $key = array_shift($keys);
             if (!is_int($key)) {
                 return new StructConfigValidate(array('acceptArrayAsModel' => true));
             } else {
                 return new ArrayConfigValidate(array('acceptArrayAsModel' => true));
             }
         } else {
             return new ArrayConfigValidate(array('acceptArrayAsModel' => true));
         }
     }
 }
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:34,代码来源:ArrayConfigValidate.php

示例5: isValid

 public function isValid($value)
 {
     if (!parent::isValid($value)) {
         return false;
     }
     if (!is_null($this->_min) || !is_null($this->_max)) {
         $validators = array();
         if (!is_null($this->_min)) {
             $validator = new Zend_Validate_GreaterThan($this->_min);
             $validator->setMin($this->_min);
             $validators[] = $validator;
         }
         if (!is_null($this->_max)) {
             $validator = new Zend_Validate_LessThan($this->_max);
             $validator->setMax($this->_max);
             $validators[] = $validator;
         }
         foreach ($validators as $val) {
             if (!$val->isValid($value)) {
                 $messages = $val->getMessages();
                 if (!is_array($this->_messages)) {
                     $this->_messages = array();
                 }
                 $this->_messageVariables = array('max' => '_max', 'min' => '_min');
                 foreach ($messages as $key => $message) {
                     $this->_error($key, $value);
                 }
                 return false;
             }
         }
     }
     return true;
 }
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:33,代码来源:LimitedInt.php

示例6: trainingAction

 public function trainingAction()
 {
     $validator = new Zend_Validate_Int();
     $ceId = $this->getRequest()->getParam(CalibrationExercise::COL_ID);
     if ($validator->isValid($ceId)) {
         $this->view->ceId = $ceId;
     }
 }
开发者ID:blackskaarj,项目名称:webgr,代码行数:8,代码来源:StatisticController.php

示例7: indexAction

 public function indexAction()
 {
     $validator = new Zend_Validate_Int();
     $ceId = $this->getRequest()->getParam(CalibrationExercise::COL_ID);
     $error = false;
     if ($validator->isValid($ceId)) {
         $dbadapter = Zend_Registry::get('DB_CONNECTION1');
         $select = $dbadapter->select();
         if (Default_ReferenceQuery::isParticipantInCe($ceId)) {
             //set CE id
             $namespace = new Zend_Session_Namespace('default');
             $constCeId = CalibrationExercise::COL_ID;
             $namespace->{$constCeId} = $ceId;
             // Get part_id and part_role
             $auth = Zend_Auth::getInstance();
             $storage = $auth->getStorage();
             $constUserId = User::COL_ID;
             $userId = $storage->read()->{$constUserId};
             $select->from(Participant::TABLE_NAME);
             $select->where(Participant::COL_USER_ID . " =?", $userId);
             $select->where(Participant::COL_CE_ID . " =?", $ceId);
             $array = $dbadapter->fetchAll($select);
             $constPartId = Participant::COL_ID;
             $namespace->{$constPartId} = $array[0][Participant::COL_ID];
             $constPartRole = Participant::COL_ROLE;
             $namespace->{$constPartRole} = $array[0][Participant::COL_ROLE];
             //Set CE-info result Object
             $select->reset();
             $select->from(array('caex' => CalibrationExercise::TABLE_NAME));
             $select->join(array('exp' => Expertise::TABLE_NAME), 'caex.' . CalibrationExercise::COL_EXPERTISE_ID . "=" . 'exp.' . Expertise::COL_ID, array());
             $select->join(array('key' => KeyTable::TABLE_NAME), 'caex.' . CalibrationExercise::COL_KEY_TABLE_ID . "=" . 'key.' . KeyTable::COL_ID);
             $select->join(array('work' => Workshop::TABLE_NAME), 'caex.' . CalibrationExercise::COL_WORKSHOP_ID . "=" . "work." . Workshop::COL_ID, array(Workshop::COL_NAME));
             $select->join(array('vali' => ValueList::TABLE_NAME), 'exp.' . Expertise::COL_SUBJECT . '=vali.' . ValueList::COL_ID, array(Expertise::COL_SUBJECT => ValueList::COL_NAME));
             $select->where('caex.' . CalibrationExercise::COL_ID . "=?", $ceId);
             $ceArray = $dbadapter->fetchAll($select);
             $namespace->ceArray = $ceArray;
             $this->view->subject = $ceArray[0][Expertise::COL_SUBJECT];
         } else {
             $error = true;
             $this->view->message = "Your are not a participant of this CE.<br>" . "Please contact one of the coordinators:<br>";
             $select->from(array('caex' => CalibrationExercise::TABLE_NAME));
             $select->join(array('part' => Participant::TABLE_NAME), 'caex.' . CalibrationExercise::COL_ID . '=' . 'part.' . Participant::COL_CE_ID);
             $select->join(array('user' => User::TABLE_NAME), 'part.' . Participant::COL_USER_ID . '=' . 'user.' . User::COL_ID);
             $select->where('part.' . Participant::COL_CE_ID . '=?', $ceId);
             $select->where('part.' . Participant::COL_ROLE . '=?', 'Coordinator');
             $infoArray = $dbadapter->fetchAll($select);
             $this->view->error = true;
             if (count($infoArray) != 0) {
                 $this->view->coordinators = $infoArray;
             } else {
                 $this->view->message = "The CE doesn't exist.<br>";
                 $this->view->coordinators = array();
             }
         }
     } else {
         throw new Zend_Exception('The CE id was not valid!');
     }
 }
开发者ID:blackskaarj,项目名称:webgr,代码行数:58,代码来源:MakeController.php

示例8: validateAttributeValue

 /**
  * Validate attributes
  * 
  * @param string $validation attribute validation class name
  * @param string $value attribute value
  * @return array returns success and errors as array keys
  */
 protected function validateAttributeValue($validation, $value)
 {
     $valid = array('success' => TRUE, 'errors' => '');
     switch ($validation) {
         case Fox_Eav_Model_Attribute::ATTRIBUTE_VALIDATION_DECIMAL:
             if (!$this->decimalValidation) {
                 $this->decimalValidation = new Zend_Validate_Float();
             }
             $valid['success'] = $this->decimalValidation->isValid($value);
             $valid['errors'] = '"' . $value . '" contains invalid digits.';
             break;
         case Fox_Eav_Model_Attribute::ATTRIBUTE_VALIDATION_EMAIL:
             if (!$this->emailValidation) {
                 $this->emailValidation = new Zend_Validate_EmailAddress();
             }
             $valid['success'] = $this->emailValidation->isValid($value);
             $valid['errors'] = '"' . $value . '" is not a valid email address.';
             break;
         case Fox_Eav_Model_Attribute::ATTRIBUTE_VALIDATION_INT:
             if (!$this->intValidation) {
                 $this->intValidation = new Zend_Validate_Int();
             }
             $valid['success'] = $this->intValidation->isValid($value);
             $valid['errors'] = '"' . $value . '" is not a valid integer.';
             break;
         case Fox_Eav_Model_Attribute::ATTRIBUTE_VALIDATION_LETTERS:
             if (!$this->letterValidation) {
                 $this->letterValidation = new Zend_Validate_Alpha(true);
             }
             $valid['success'] = $this->letterValidation->isValid($value);
             $valid['errors'] = '"' . $value . '" contains invalid characters.';
             break;
         case Fox_Eav_Model_Attribute::ATTRIBUTE_VALIDATION_DATE:
             $valid['success'] = strtotime($value) > 0;
             $valid['errors'] = '"' . $value . '" is invalid date.';
             break;
         case Fox_Eav_Model_Attribute::ATTRIBUTE_VALIDATION_URL:
             if (!$this->urlValidation) {
                 $this->urlValidation = new Uni_Validate_Url();
             }
             $valid['success'] = $this->urlValidation->isValid($value);
             $valid['errors'] = '"' . $value . '" is not a valid url.';
             break;
         case Fox_Eav_Model_Attribute::ATTRIBUTE_VALIDATION_IMAGE:
             if (empty($this->validExtensions)) {
                 $this->validExtensions = array('jpg', 'jpeg', 'png', 'bmp', 'gif', 'tiff');
             }
             $extPos = strrpos($value, '.');
             if (!$extPos || !empty($this->validExtensions) && !in_array(substr($value, $extPos + 1), $this->validExtensions)) {
                 $valid['success'] = FALSE;
                 $valid['errors'] = 'Invalid image was given.';
             }
             break;
         default:
             break;
     }
     return $valid;
 }
开发者ID:UnicodeSystems-PrivateLimited,项目名称:Zendfox,代码行数:65,代码来源:Abstract.php

示例9: isValid

 public function isValid($value)
 {
     $intValidator = new Zend_Validate_Int(array('locale' => 'br'));
     $positiveValidator = new Zend_Validate_GreaterThan(0);
     if ($intValidator->isValid($value) && $positiveValidator->isValid($value)) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:racporto,项目名称:c3op,代码行数:10,代码来源:ValidId.php

示例10: isValid

 public function isValid($value)
 {
     if (!parent::isValid($value)) {
         return false;
     }
     if ($value % $this->_mod !== 0) {
         $this->_error(self::NOT_MODULO, $value);
         return false;
     }
     return true;
 }
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:11,代码来源:Mod.php

示例11: Pluralism

 public function Pluralism($number)
 {
     $filter = new Zend_Validate_Int();
     if ($filter->isValid($number)) {
         if ($number === 0) {
             return self::NONE;
         }
         if ($number === 1) {
             return self::SINGULAR;
         }
         return $number . ' ' . self::PLURAL;
     } else {
         return $filter->getMessages();
     }
 }
开发者ID:rwebley,项目名称:Beowulf---PAS,代码行数:15,代码来源:Pluralism.php

示例12: adbc

 /** A function for turning the integer into a string with AD or BC added
  * 
  * @param $date integer 
  * @param $suffix string
  * @param $prefix string
  */
 public function adbc($date = NULL, $suffix = "BC", $prefix = "AD")
 {
     $validator = new Zend_Validate_Int();
     if ($validator->isValid($date)) {
         if ($date < 0) {
             return abs($date) . ' ' . $suffix;
         } else {
             if ($date > 0) {
                 return $prefix . ' ' . abs($date);
             } else {
                 if ($date === 0) {
                     return false;
                 }
             }
         }
     } else {
         return false;
     }
 }
开发者ID:rwebley,项目名称:Beowulf---PAS,代码行数:25,代码来源:Adbc.php

示例13: certainty

 /**
  * Check for the certainty
  * @param $int The certainty lookup number 
  */
 public function certainty($int)
 {
     $validator = new Zend_Validate_Int();
     if ($validator->isValid($int)) {
         switch ($int) {
             case 1:
                 $cert = 'Certain';
                 break;
             case 2:
                 $cert = 'Probably';
                 break;
             case 3:
                 $cert = 'Possibly';
                 break;
             default:
                 return false;
                 break;
         }
         return $cert;
     } else {
         return false;
     }
 }
开发者ID:rwebley,项目名称:Beowulf---PAS,代码行数:27,代码来源:Certainty.php

示例14: completeness

 /** Determine the completeness from lookup value
  * 
  * @param integer $string
  * @return string
  */
 public function completeness($string)
 {
     $validator = new Zend_Validate_Int();
     if ($validator->isValid($string)) {
         switch ($string) {
             case 1:
                 $comp = 'Fragment';
                 break;
             case 2:
                 $comp = 'Incomplete';
                 break;
             case 3:
                 $comp = 'Uncertain';
                 break;
             case 4:
                 $comp = 'Complete';
                 break;
             default:
                 return false;
                 break;
         }
         return $comp;
     }
 }
开发者ID:rwebley,项目名称:Beowulf---PAS,代码行数:29,代码来源:Completeness.php

示例15: isInt

 /**
  * Returns TRUE if value is a valid integer value, FALSE otherwise.
  *
  * @deprecated since 0.8.0
  * @param      mixed $value
  * @return     boolean
  */
 public static function isInt($value)
 {
     require_once 'Zend/Validate/Int.php';
     $validator = new Zend_Validate_Int();
     return $validator->isValid($value);
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:13,代码来源:Filter.php


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