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