summaryrefslogtreecommitdiff
path: root/framework/Web/UI/WebControls/TCompareValidator.php
diff options
context:
space:
mode:
authorxue <>2006-09-04 19:15:47 +0000
committerxue <>2006-09-04 19:15:47 +0000
commit56fee292c37e162c03fab9eeadd6a8b9ab85c251 (patch)
tree923510b93c707868098ae4e5f404eb3766a59553 /framework/Web/UI/WebControls/TCompareValidator.php
parentb107cad91733d4a2a80f42cdbaab41a4f7b41c9d (diff)
merge from 3.0 branch till 1387
Diffstat (limited to 'framework/Web/UI/WebControls/TCompareValidator.php')
-rw-r--r--framework/Web/UI/WebControls/TCompareValidator.php69
1 files changed, 49 insertions, 20 deletions
diff --git a/framework/Web/UI/WebControls/TCompareValidator.php b/framework/Web/UI/WebControls/TCompareValidator.php
index 93664b2e..2b1028ef 100644
--- a/framework/Web/UI/WebControls/TCompareValidator.php
+++ b/framework/Web/UI/WebControls/TCompareValidator.php
@@ -57,21 +57,21 @@ class TCompareValidator extends TBaseValidator
}
/**
- * @return string the data type that the values being compared are converted to before the comparison is made. Defaults to String.
+ * @return TValidationDataType the data type that the values being compared are converted to before the comparison is made. Defaults to TValidationDataType::String.
*/
public function getDataType()
{
- return $this->getViewState('DataType','String');
+ return $this->getViewState('DataType',TValidationDataType::String);
}
/**
- * Sets the data type (Integer, Float, Date, String) that the values being
+ * Sets the data type that the values being
* compared are converted to before the comparison is made.
- * @param string the data type
+ * @param TValidationDataType the data type
*/
public function setDataType($value)
{
- $this->setViewState('DataType',TPropertyValue::ensureEnum($value,'Integer','Float','Date','String'),'String');
+ $this->setViewState('DataType',TPropertyValue::ensureEnum($value,'TValidationDataType'),TValidationDataType::String);
}
/**
@@ -109,20 +109,20 @@ class TCompareValidator extends TBaseValidator
}
/**
- * @return string the comparison operation to perform (Equal, NotEqual, GreaterThan, GreaterThanEqual, LessThan, LessThanEqual). Defaults to Equal.
+ * @return TValidationCompareOperator the comparison operation to perform. Defaults to TValidationCompareOperator::Equal.
*/
public function getOperator()
{
- return $this->getViewState('Operator','Equal');
+ return $this->getViewState('Operator',TValidationCompareOperator::Equal);
}
/**
- * Sets the comparison operation to perform (Equal, NotEqual, GreaterThan, GreaterThanEqual, LessThan, LessThanEqual)
- * @param string the comparison operation
+ * Sets the comparison operation to perform
+ * @param TValidationCompareOperator the comparison operation
*/
public function setOperator($value)
{
- $this->setViewState('Operator',TPropertyValue::ensureEnum($value,'Equal','NotEqual','GreaterThan','GreaterThanEqual','LessThan','LessThanEqual'),'Equal');
+ $this->setViewState('Operator',TPropertyValue::ensureEnum($value,'TValidationCompareOperator'),TValidationCompareOperator::Equal);
}
/**
@@ -167,17 +167,17 @@ class TCompareValidator extends TBaseValidator
$values = $this->getComparisonValues($value, $value2);
switch($this->getOperator())
{
- case 'Equal':
+ case TValidationCompareOperator::Equal:
return $values[0] == $values[1];
- case 'NotEqual':
+ case TValidationCompareOperator::NotEqual:
return $values[0] != $values[1];
- case 'GreaterThan':
+ case TValidationCompareOperator::GreaterThan:
return $values[0] > $values[1];
- case 'GreaterThanEqual':
+ case TValidationCompareOperator::GreaterThanEqual:
return $values[0] >= $values[1];
- case 'LessThan':
+ case TValidationCompareOperator::LessThan:
return $values[0] < $values[1];
- case 'LessThanEqual':
+ case TValidationCompareOperator::LessThanEqual:
return $values[0] <= $values[1];
}
@@ -194,11 +194,11 @@ class TCompareValidator extends TBaseValidator
{
switch($this->getDataType())
{
- case 'Integer':
+ case TValidationDataType::Integer:
return array(intval($value1), intval($value2));
- case 'Float':
+ case TValidationDataType::Float:
return array(floatval($value1), floatval($value2));
- case 'Date':
+ case TValidationDataType::Date:
$dateFormat = $this->getDateFormat();
if($dateFormat!=='')
{
@@ -225,7 +225,7 @@ class TCompareValidator extends TBaseValidator
}
if(($value=$this->getValueToCompare())!=='')
$options['ValueToCompare']=$value;
- if(($operator=$this->getOperator())!=='Equal')
+ if(($operator=$this->getOperator())!==TValidationCompareOperator::Equal)
$options['Operator']=$operator;
$options['DataType']=$this->getDataType();
if(($dateFormat=$this->getDateFormat())!=='')
@@ -234,4 +234,33 @@ class TCompareValidator extends TBaseValidator
}
}
+
+/**
+ * TValidationCompareOperator class.
+ * TValidationCompareOperator defines the enumerable type for the comparison operations
+ * that {@link TCompareValidator} can perform validation with.
+ *
+ * The following enumerable values are defined:
+ * - Equal
+ * - NotEqual
+ * - GreaterThan
+ * - GreaterThanEqual
+ * - LessThan
+ * - LessThanEqual
+ *
+ * @author Qiang Xue <qiang.xue@gmail.com>
+ * @version $Revision: $ $Date: $
+ * @package System.Web.UI.WebControls
+ * @since 3.0.4
+ */
+class TValidationCompareOperator extends TEnumerable
+{
+ const Equal='Equal';
+ const NotEqual='NotEqual';
+ const GreaterThan='GreaterThan';
+ const GreaterThanEqual='GreaterThanEqual';
+ const LessThan='LessThan';
+ const LessThanEqual='LessThanEqual';
+}
+
?> \ No newline at end of file