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


PHP Validation::inList方法代碼示例

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


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

示例1: testInList

 /**
  * testInList method
  *
  * @return void
  */
 public function testInList()
 {
     $this->assertTrue(Validation::inList('one', array('one', 'two')));
     $this->assertTrue(Validation::inList('two', array('one', 'two')));
     $this->assertFalse(Validation::inList('three', array('one', 'two')));
     $this->assertFalse(Validation::inList('1one', array(0, 1, 2, 3)));
     $this->assertFalse(Validation::inList('one', array(0, 1, 2, 3)));
     $this->assertFalse(Validation::inList('2', array(1, 2, 3)));
     $this->assertTrue(Validation::inList('2', array(1, 2, 3), false));
 }
開發者ID:alvaroziqar,項目名稱:galei,代碼行數:15,代碼來源:ValidationTest.php

示例2: testInList

 /**
  * testInList method
  *
  * @return void
  */
 public function testInList()
 {
     $this->assertTrue(Validation::inList('one', array('one', 'two')));
     $this->assertTrue(Validation::inList('two', array('one', 'two')));
     $this->assertFalse(Validation::inList('three', array('one', 'two')));
     $this->assertFalse(Validation::inList('1one', array(0, 1, 2, 3)));
     $this->assertFalse(Validation::inList('one', array(0, 1, 2, 3)));
     $this->assertTrue(Validation::inList('2', array(1, 2, 3)));
     $this->assertFalse(Validation::inList('2x', array(1, 2, 3)));
     $this->assertFalse(Validation::inList(2, array('1', '2x', '3')));
     $this->assertFalse(Validation::inList('One', array('one', 'two')));
     // No hexadecimal for numbers.
     $this->assertFalse(Validation::inList('0x7B', array('ABC', '123')));
     $this->assertFalse(Validation::inList('0x7B', array('ABC', 123)));
     // case insensitive
     $this->assertTrue(Validation::inList('one', array('One', 'Two'), true));
     $this->assertTrue(Validation::inList('Two', array('one', 'two'), true));
     $this->assertFalse(Validation::inList('three', array('one', 'two'), true));
 }
開發者ID:nil-vn,項目名稱:goodnews,代碼行數:24,代碼來源:ValidationTest.php

示例3: testInList

 /**
  * testInList method
  *
  * @return void
  */
 public function testInList()
 {
     $this->assertTrue(Validation::inList('one', array('one', 'two')));
     $this->assertTrue(Validation::inList('two', array('one', 'two')));
     $this->assertFalse(Validation::inList('three', array('one', 'two')));
     $this->assertFalse(Validation::inList('1one', array(0, 1, 2, 3)));
     $this->assertFalse(Validation::inList('one', array(0, 1, 2, 3)));
     $this->assertTrue(Validation::inList('2', array(1, 2, 3)));
     $this->assertFalse(Validation::inList('2x', array(1, 2, 3)));
     $this->assertFalse(Validation::inList(2, array('1', '2x', '3')));
     $this->assertFalse(Validation::inList('One', array('one', 'two')));
     // case insensitive
     $this->assertTrue(Validation::inList('one', array('One', 'Two'), true));
     $this->assertTrue(Validation::inList('Two', array('one', 'two'), true));
     $this->assertFalse(Validation::inList('three', array('one', 'two'), true));
 }
開發者ID:dudasc,項目名稱:site-fescjj,代碼行數:21,代碼來源:ValidationTest.php

示例4: testInvalidInList

 /**
  * @testdox inList should return false to element not within the list
  */
 public function testInvalidInList()
 {
     $value = 'PHP';
     $list = array('Spaghetti', 'Framework');
     $this->assertFalse(Validation::inList($value, $list));
 }
開發者ID:klawdyo,項目名稱:spaghettiphp,代碼行數:9,代碼來源:ValidationTest.php

示例5: testInList

 /**
  * testInList method
  *
  * @access public
  * @return void
  */
 function testInList()
 {
     $this->assertTrue(Validation::inList('one', array('one', 'two')));
     $this->assertTrue(Validation::inList('two', array('one', 'two')));
     $this->assertFalse(Validation::inList('three', array('one', 'two')));
 }
開發者ID:evrard,項目名稱:cakephp2x,代碼行數:12,代碼來源:validation.test.php

示例6: checkMatrixAnswerInList

 /**
  * checkMatrixAnswerInList
  *
  * @param object &$model use model
  * @param string $answers answer value
  * @param int $list choice list ( choice key list)
  * @return bool
  */
 public function checkMatrixAnswerInList(&$model, $answers, $list)
 {
     $ret = true;
     foreach ($answers as $matrixRowId => $matrixColAns) {
         if (!Validation::inList(strval($matrixRowId), $list)) {
             $ret = false;
             $model->validationErrors['answer_value'][] = __d('registrations', 'Invalid choice');
         }
         $choiceIds = array_keys($matrixColAns);
         foreach ($choiceIds as $choiceId) {
             if ($choiceId != '' && !Validation::inList(strval($choiceId), $list)) {
                 $ret = false;
                 $model->validationErrors['answer_value'][] = __d('registrations', 'Invalid choice');
             }
         }
     }
     return $ret;
 }
開發者ID:NetCommons3,項目名稱:Registrations,代碼行數:26,代碼來源:RegistrationAnswerMatrixSingleChoiceBehavior.php

示例7: checkMatrixAnswerInList

 /**
  * checkMatrixAnswerInList
  *
  * @param array $question question
  * @param string $answers answer value
  * @param int $list choice list ( choice origin_id list)
  * @return array error message
  */
 public function checkMatrixAnswerInList($question, $answers, $list)
 {
     $errors = array();
     foreach ($answers as $matrixRowId => $matrixColAns) {
         if (!Validation::inList(strval($matrixRowId), $list)) {
             $errors[] = __d('questionnaires', 'Invalid choice');
         }
         $choiceIds = array_keys($matrixColAns);
         foreach ($choiceIds as $choiceId) {
             if ($choiceId != '' && !Validation::inList(strval($choiceId), $list)) {
                 $errors[] = __d('questionnaires', 'Invalid choice');
             }
         }
     }
     return $errors;
 }
開發者ID:Onasusweb,項目名稱:Questionnaires,代碼行數:24,代碼來源:QuestionnaireAnswerValidation.php

示例8: testInvalidInList

 public function testInvalidInList()
 {
     $value = "PHP";
     $list = array("Spaghetti", "Framework");
     $this->assertFalse(Validation::inList($value, $list));
 }
開發者ID:vfeitoza,項目名稱:spaghettiphp,代碼行數:6,代碼來源:validation.test.php

示例9: answerChoiceValidation

 /**
  * answerValidation 登録內容の正當性
  *
  * @param object &$model use model
  * @param array $data Validation対象データ
  * @param array $question 登録データに対応する項目
  * @param array $allAnswers 入力された登録すべて
  * @return bool
  */
 public function answerChoiceValidation(&$model, $data, $question, $allAnswers)
 {
     if (!in_array($question['question_type'], $this->_choiceValidateType)) {
         return true;
     }
     if (!isset($model->data['RegistrationAnswer']['answer_values'])) {
         return true;
     }
     // 項目に設定されている選択肢を配列にまとめる
     $list = Hash::combine($question['RegistrationChoice'], '{n}.id', '{n}.key');
     $ret = true;
     // 選択された選択肢IDすべてについて調査する
     $choiceIds = array_keys($model->data['RegistrationAnswer']['answer_values']);
     foreach ($choiceIds as $choiceId) {
         // 選択されたIDは、ちゃんと用意されている選択肢の中のひとつであるか
         if ($choiceId != '' && !Validation::inList(strval($choiceId), $list)) {
             $ret = false;
             $model->validationErrors['answer_value'][] = __d('registrations', 'Invalid choice');
         }
         // チェックされている選択肢が「その他」の項目である場合は
         $choice = Hash::extract($question['RegistrationChoice'], '{n}[key=' . $choiceId . ']');
         if ($choice && $choice[0]['other_choice_type'] != RegistrationsComponent::OTHER_CHOICE_TYPE_NO_OTHER_FILED) {
             // 具體的なテキストが書かれていないといけない
             if (empty($model->data['RegistrationAnswer']['other_answer_value'])) {
                 $ret = false;
                 $model->validationErrors['answer_value'][] = __d('registrations', 'Please enter something, if you chose the other item');
             }
         }
     }
     return $ret;
 }
開發者ID:NetCommons3,項目名稱:Registrations,代碼行數:40,代碼來源:RegistrationAnswerSingleListBehavior.php

示例10: notInListFromConfigure

 /**
  * notInListFromConfigure
  * jpn: Configure::write()で設定されているarray()からnotInListを生成
  *
  */
 public function notInListFromConfigure(Model $model, $field, $listname)
 {
     $value = array_shift($field);
     $list = Configure::read($listname);
     if ($list !== array_values($list)) {
         // jpn: selectのoptionsにそのまま設置するような連想配列を想定
         $list = array_keys($list);
     }
     foreach ($list as $k => $v) {
         $list[$k] = (string) $v;
     }
     return !Validation::inList($value, $list);
 }
開發者ID:k1low,項目名稱:yav,代碼行數:18,代碼來源:AdditionalValidationRulesBehavior.php


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