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


PHP Validation::range方法代碼示例

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


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

示例1: answerTextValidation

 /**
  * answerValidation 登録內容の正當性
  *
  * @param object &$model use model
  * @param array $data Validation対象データ
  * @param array $question 登録データに対応する項目
  * @param array $allAnswers 入力された登録すべて
  * @return bool
  */
 public function answerTextValidation(&$model, $data, $question, $allAnswers)
 {
     if (!in_array($question['question_type'], $this->_textValidateType)) {
         return true;
     }
     $ret = true;
     // 數値型登録を望まれている場合
     if ($question['question_type_option'] == RegistrationsComponent::TYPE_OPTION_NUMERIC) {
         if (!Validation::numeric($data['answer_value'])) {
             $ret = false;
             $model->validationErrors['answer_value'][] = __d('registrations', 'Number required');
         }
         if ($question['is_range'] == RegistrationsComponent::USES_USE) {
             $rangeRes = Validation::range($data['answer_value'], intval($question['min']), intval($question['max']));
             if (!$rangeRes) {
                 $ret = false;
                 $model->validationErrors['answer_value'][] = sprintf(__d('registrations', 'Please enter the answer between %s and %s.'), $question['min'], $question['max']);
             }
         }
     } else {
         if ($question['is_range'] == RegistrationsComponent::USES_USE) {
             if (!Validation::minLength($data['answer_value'], intval($question['min'])) || !Validation::maxLength($data['answer_value'], intval($question['max']))) {
                 $ret = false;
                 $model->validationErrors['answer_value'][] = sprintf(__d('registrations', 'Please enter the answer between %s letters and %s letters.'), $question['min'], $question['max']);
             }
         }
     }
     return $ret;
 }
開發者ID:NetCommons3,項目名稱:Registrations,代碼行數:38,代碼來源:RegistrationAnswerTextBehavior.php

示例2: testRange

 /**
  * testRange method
  *
  * @return void
  */
 public function testRange()
 {
     $this->assertFalse(Validation::range(20, 100, 1));
     $this->assertTrue(Validation::range(20, 1, 100));
     $this->assertFalse(Validation::range(0.5, 1, 100));
     $this->assertTrue(Validation::range(0.5, 0, 100));
     $this->assertTrue(Validation::range(5));
     $this->assertTrue(Validation::range(-5, -10, 1));
     $this->assertFalse(Validation::range('word'));
 }
開發者ID:alvaroziqar,項目名稱:galei,代碼行數:15,代碼來源:ValidationTest.php

示例3: testRangeTypeChecks

 /**
  * Test range type checks
  *
  * @return void
  */
 public function testRangeTypeChecks()
 {
     $this->assertFalse(Validation::range('\\x028', 1, 5), 'hexish encoding fails');
     $this->assertFalse(Validation::range('0b010', 1, 5), 'binary string data fails');
     $this->assertFalse(Validation::range('0x01', 1, 5), 'hex string data fails');
     $this->assertFalse(Validation::range('0x1', 1, 5), 'hex string data fails');
     $this->assertFalse(Validation::range('\\x028', 1, 5), 'hexish encoding fails');
     $this->assertFalse(Validation::range('0b010', 1, 5), 'binary string data fails');
     $this->assertFalse(Validation::range('0x02', 1, 5), 'hex string data fails');
 }
開發者ID:nil-vn,項目名稱:goodnews,代碼行數:15,代碼來源:ValidationTest.php

示例4: testInvalidRangeWithNonNumericValue

 /**
  * @testdox range should return false to non-numerical value
  */
 public function testInvalidRangeWithNonNumericValue()
 {
     $value = 'Non numeric';
     $this->assertFalse(Validation::range($value));
 }
開發者ID:klawdyo,項目名稱:spaghettiphp,代碼行數:8,代碼來源:ValidationTest.php

示例5: checkDateRange

 /**
  * checkDateRange
  *
  * @param array $question question
  * @param string $answer answer value
  * @return array error message
  */
 public function checkDateRange($question, $answer)
 {
     $errors = array();
     if ($question['is_range'] == QuestionnairesComponent::USES_USE) {
         if (!Validation::range(strtotime($answer), strtotime($question['min']) - 1, strtotime($question['max']) + 1)) {
             if ($question['question_type_option'] == QuestionnairesComponent::TYPE_OPTION_DATE) {
                 $fmt = 'Y-m-d';
             } elseif ($question['question_type_option'] == QuestionnairesComponent::TYPE_OPTION_TIME) {
                 $fmt = 'H:i';
             } else {
                 $fmt = 'Y-m-d H:i';
             }
             $errors[] = sprintf(__d('questionnaires', 'Please enter the answer between %s and %s.', date($fmt, strtotime($question['min'])), date($fmt, strtotime($question['max']))));
         }
     }
     return $errors;
 }
開發者ID:Onasusweb,項目名稱:Questionnaires,代碼行數:24,代碼來源:QuestionnaireAnswerValidation.php

示例6: checkRangePassword

 /**
  * パスワードの確認
  * 入力フォームと登録時のバリデーションの文字數が異なるため、獨自実裝する
  * 
  * @param type $fields
  * @return boolean
  */
 function checkRangePassword($fields = array())
 {
     if (isset($this->data["TmpUser"]["id"])) {
         return true;
     } else {
         return Validation::range(mb_strlen($this->data["TmpUser"]["password"]), 5, 21);
     }
 }
開發者ID:Quang2727,項目名稱:Kaopass,代碼行數:15,代碼來源:TmpUser.php

示例7: _validateTimeRange

 /**
  * _validateDatetime 日付・時間の正當性
  *
  * @param object &$model use model
  * @param array $question 登録データに対応する項目
  * @param string $answer 登録データ
  * @return bool
  */
 protected function _validateTimeRange(&$model, $question, $answer)
 {
     if ($question['is_range'] != RegistrationsComponent::USES_USE) {
         return true;
     }
     $rangeResult = Validation::range(strtotime($answer), strtotime($question['min']) - 1, strtotime($question['max']) + 1);
     if ($rangeResult) {
         return true;
     }
     $model->validationErrors['answer_value'][] = sprintf(__d('registrations', 'Please enter the answer between %s and %s.'), date($this->_datetimeFormat[$question['question_type_option']], strtotime($question['min'])), date($this->_datetimeFormat[$question['question_type_option']], strtotime($question['max'])));
     return false;
 }
開發者ID:NetCommons3,項目名稱:Registrations,代碼行數:20,代碼來源:RegistrationAnswerDatetimeBehavior.php


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