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


PHP Validation::comparison方法代码示例

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


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

示例1: field_comparison

 function field_comparison($check1, $operator, $field2)
 {
     foreach ($check1 as $key => $value1) {
         $value2 = $this->data[$this->alias][$field2];
         if (!Validation::comparison($value1, $operator, $value2)) {
             return false;
         }
     }
     return true;
 }
开发者ID:ivanbautsita,项目名称:gestion-escolar-campus-virtuales,代码行数:10,代码来源:ClassLesson.php

示例2: compareWithField

 public function compareWithField($validationFields = array(), $operator = null, $compareFieldName = '')
 {
     if (!isset($this->data[$this->name][$compareFieldName])) {
         throw new CakeException(sprintf('Can\'t compare to the non-existing field "%s" of model %s.'), $compareFieldName, $this->name);
     }
     $compareTo = $this->data[$this->name][$compareFieldName];
     foreach ($validationFields as $key => $value) {
         if (!Validation::comparison($value, $operator, $compareTo)) {
             return false;
         }
     }
     return true;
 }
开发者ID:array-pop-tarts,项目名称:club-gl-cake,代码行数:13,代码来源:AppModel.php

示例3: testComparisonAsArray

 /**
  * testComparisonAsArray method
  *
  * @return void
  */
 public function testComparisonAsArray()
 {
     $this->assertTrue(Validation::comparison(array('check1' => 7, 'operator' => 'is greater', 'check2' => 6)));
     $this->assertTrue(Validation::comparison(array('check1' => 7, 'operator' => '>', 'check2' => 6)));
     $this->assertTrue(Validation::comparison(array('check1' => 6, 'operator' => 'is less', 'check2' => 7)));
     $this->assertTrue(Validation::comparison(array('check1' => 6, 'operator' => '<', 'check2' => 7)));
     $this->assertTrue(Validation::comparison(array('check1' => 7, 'operator' => 'greater or equal', 'check2' => 7)));
     $this->assertTrue(Validation::comparison(array('check1' => 7, 'operator' => '>=', 'check2' => 7)));
     $this->assertTrue(Validation::comparison(array('check1' => 7, 'operator' => 'greater or equal', 'check2' => 6)));
     $this->assertTrue(Validation::comparison(array('check1' => 7, 'operator' => '>=', 'check2' => 6)));
     $this->assertTrue(Validation::comparison(array('check1' => 6, 'operator' => 'less or equal', 'check2' => 7)));
     $this->assertTrue(Validation::comparison(array('check1' => 6, 'operator' => '<=', 'check2' => 7)));
     $this->assertTrue(Validation::comparison(array('check1' => 7, 'operator' => 'equal to', 'check2' => 7)));
     $this->assertTrue(Validation::comparison(array('check1' => 7, 'operator' => '==', 'check2' => 7)));
     $this->assertTrue(Validation::comparison(array('check1' => 7, 'operator' => 'not equal', 'check2' => 6)));
     $this->assertTrue(Validation::comparison(array('check1' => 7, 'operator' => '!=', 'check2' => 6)));
     $this->assertFalse(Validation::comparison(array('check1' => 6, 'operator' => 'is greater', 'check2' => 7)));
     $this->assertFalse(Validation::comparison(array('check1' => 6, 'operator' => '>', 'check2' => 7)));
     $this->assertFalse(Validation::comparison(array('check1' => 7, 'operator' => 'is less', 'check2' => 6)));
     $this->assertFalse(Validation::comparison(array('check1' => 7, 'operator' => '<', 'check2' => 6)));
     $this->assertFalse(Validation::comparison(array('check1' => 6, 'operator' => 'greater or equal', 'check2' => 7)));
     $this->assertFalse(Validation::comparison(array('check1' => 6, 'operator' => '>=', 'check2' => 7)));
     $this->assertFalse(Validation::comparison(array('check1' => 6, 'operator' => 'greater or equal', 'check2' => 7)));
     $this->assertFalse(Validation::comparison(array('check1' => 6, 'operator' => '>=', 'check2' => 7)));
     $this->assertFalse(Validation::comparison(array('check1' => 7, 'operator' => 'less or equal', 'check2' => 6)));
     $this->assertFalse(Validation::comparison(array('check1' => 7, 'operator' => '<=', 'check2' => 6)));
     $this->assertFalse(Validation::comparison(array('check1' => 7, 'operator' => 'equal to', 'check2' => 6)));
     $this->assertFalse(Validation::comparison(array('check1' => 7, 'operator' => '==', 'check2' => 6)));
     $this->assertFalse(Validation::comparison(array('check1' => 7, 'operator' => 'not equal', 'check2' => 7)));
     $this->assertFalse(Validation::comparison(array('check1' => 7, 'operator' => '!=', 'check2' => 7)));
 }
开发者ID:alvaroziqar,项目名称:galei,代码行数:36,代码来源:ValidationTest.php

示例4: applyConditions

 /**
  *	Retorna o texto já aplicadas as suas condições
  *	
  *	@param	string	$col a coluna que será comparada
  *	@param	array	$conditions array com as condições
  *	@param integer	$row	O número da linha no array de dados
  *	@return string	O texto formatado e aplicado as condições
  */
 private function applyConditions($col, $conditions, $row)
 {
     //valor dessa linha e desse campo
     $curValue = $this->data[$row][$col];
     foreach ($conditions as $key => $cond) {
         $params = $conditions[$key];
         //Se for acima da versão 0.2
         //if((SPAGHETTI_VERSION >= 0.2)):
         $comparison = Validation::comparison($curValue, $params['operator'], $params['comparator']);
         //Se for a versão 0.1, não suportará operadores de comparação
         //else:
         //	$comparison = $curValue == $params['comparator'];
         //endif;
         //Se a comparação foi promissora
         if ($comparison) {
             //Se existir um label
             //$alt   = isset($params['alt'])   ? $params['alt'] : '';
             $label = isset($params['label']) ? $this->isImage($params['label'], $params) : $curValue;
             //Se um link foi definido
             $return = isset($params['href']) ? $this->link($label, $params['href']) : $label;
             //Se uma class de linha tiver definida
             if (isset($params['rowClass'])) {
                 $this->rowClass[$row] = array_unset($params, 'rowClass');
                 //$this->rowClass[$row] = $params['rowClass'];
             }
             //Se uma classe de célula estiver definida
             if (isset($params['cellClass'])) {
                 $this->cellClass[$col][$row] = array_unset($params, 'cellClass');
                 //					$this->cellClass[$col][$row] = $params['cellClass'];
             }
             $matched = true;
             break;
         }
     }
     //Se após o foreach achou-se o valor
     if ($matched === true) {
         return $this->extract($return, $row);
     } else {
         return $curValue;
     }
 }
开发者ID:klawdyo,项目名称:spaghetti-lib,代码行数:49,代码来源:XgridHelper.php

示例5: testInvalidComparison

 /**
  * @testdox valid should return false to number equal other number
  */
 public function testInvalidComparison()
 {
     $value1 = 3.14;
     $value2 = 42;
     $this->assertFalse(Validation::comparison($value1, 'equal', $value2));
 }
开发者ID:klawdyo,项目名称:spaghettiphp,代码行数:9,代码来源:ValidationTest.php

示例6: testComparisonTypeChecks

 /**
  * Test comparison casting values before comparisons.
  *
  * @return void
  */
 public function testComparisonTypeChecks()
 {
     $this->assertFalse(Validation::comparison('\\x028', '>=', 1), 'hexish encoding fails');
     $this->assertFalse(Validation::comparison('0b010', '>=', 1), 'binary string data fails');
     $this->assertFalse(Validation::comparison('0x01', '>=', 1), 'hex string data fails');
     $this->assertFalse(Validation::comparison('0x1', '>=', 1), 'hex string data fails');
     $this->assertFalse(Validation::comparison('\\x028', '>=', 1.5), 'hexish encoding fails');
     $this->assertFalse(Validation::comparison('0b010', '>=', 1.5), 'binary string data fails');
     $this->assertFalse(Validation::comparison('0x02', '>=', 1.5), 'hex string data fails');
 }
开发者ID:mrbadao,项目名称:api-official,代码行数:15,代码来源:ValidationTest.php

示例7: validateImageSize

 /**
  * Image size validation method
  *
  * @param mixed $check
  * @param array $options is an array with key width or height and a value of array
  *    with two options, operator and value. For example:
  *    array('height' => array('==', 100)) will only be true if the image has a
  *    height of exactly 100px. See the CakePHP core class and method
  *    Validation::comparison for all operators.
  * @return boolean true
  * @see Validation::comparison()
  * @throws \InvalidArgumentException
  */
 public function validateImageSize($check, $options)
 {
     if (!isset($options['height']) && !isset($options['width'])) {
         throw new \InvalidArgumentException(__d('file_storage', 'Invalid image size validation parameters'));
     }
     if (is_string($check)) {
         $imageFile = $check;
     } else {
         $check = array_values($check);
         $check = $check[0];
         if (is_array($check) && isset($check['tmp_name'])) {
             $imageFile = $check['tmp_name'];
         } else {
             $imageFile = $check;
         }
     }
     $imageSizes = $this->getImageSize($imageFile);
     if (isset($options['height'])) {
         $height = Validation::comparison($imageSizes[1], $options['height'][0], $options['height'][1]);
     } else {
         $height = true;
     }
     if (isset($options['width'])) {
         $width = Validation::comparison($imageSizes[0], $options['width'][0], $options['width'][1]);
     } else {
         $width = true;
     }
     if ($height === false || $width === false) {
         return false;
     }
     return true;
 }
开发者ID:arourke,项目名称:cakephp-file-storage,代码行数:45,代码来源:ImageStorage.php

示例8: checkDateComp

 /**
  * Used to compare 2 datetime values.
  *
  * @param object &$model use model
  * @param string|array $check datetime string
  * @param string $operator Can be either a word or operand
  *	is greater >, is less <, greater or equal >=
  *	less or equal <=, is less <, equal to ==, not equal !=
  * @param string $compare compare datetime string
  * @return bool Success
  */
 public function checkDateComp(&$model, $check, $operator, $compare)
 {
     // 比較対象がないので比較する必要なし
     if (Validation::blank($model->data['Registration'][$compare])) {
         return true;
     }
     $check2 = strtotime($model->data['Registration'][$compare]);
     foreach ($check as $val) {
         if (Validation::blank($val)) {
             continue;
         }
         $check1 = strtotime($val);
         $ret = Validation::comparison($check1, $operator, $check2);
         if (!$ret) {
             return false;
         }
     }
     return true;
 }
开发者ID:NetCommons3,项目名称:Registrations,代码行数:30,代码来源:RegistrationValidateBehavior.php


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