Skip to content
Browse files

more on #1621 make server and client message the same

and DRY! :)
  • Loading branch information...
1 parent be6b035 commit 05a9123aabb95e38f24783936b1860587b6ecb95 @cebe cebe committed
Showing with 2 additions and 18 deletions.
  1. +2 −18 framework/validators/CCompareValidator.php
View
20 framework/validators/CCompareValidator.php
@@ -97,49 +97,33 @@ protected function validateAttribute($object,$attribute)
case '=':
case '==':
if(($this->strict && $value!==$compareValue) || (!$this->strict && $value!=$compareValue))
- {
$message=$this->message!==null?$this->message:Yii::t('yii','{attribute} must be repeated exactly.');
- $this->addError($object,$attribute,$message,array('{compareAttribute}'=>$compareTo));
- }
break;
case '!=':
if(($this->strict && $value===$compareValue) || (!$this->strict && $value==$compareValue))
- {
$message=$this->message!==null?$this->message:Yii::t('yii','{attribute} must not be equal to "{compareValue}".');
- $this->addError($object,$attribute,$message,array('{compareAttribute}'=>$compareTo,'{compareValue}'=>$compareValue));
- }
break;
case '>':
if($value<=$compareValue)
- {
$message=$this->message!==null?$this->message:Yii::t('yii','{attribute} must be greater than "{compareValue}".');
- $this->addError($object,$attribute,$message,array('{compareAttribute}'=>$compareTo,'{compareValue}'=>$compareValue));
- }
break;
case '>=':
if($value<$compareValue)
- {
$message=$this->message!==null?$this->message:Yii::t('yii','{attribute} must be greater than or equal to "{compareValue}".');
- $this->addError($object,$attribute,$message,array('{compareAttribute}'=>$compareTo,'{compareValue}'=>$compareValue));
- }
break;
case '<':
if($value>=$compareValue)
- {
$message=$this->message!==null?$this->message:Yii::t('yii','{attribute} must be less than "{compareValue}".');
- $this->addError($object,$attribute,$message,array('{compareAttribute}'=>$compareTo,'{compareValue}'=>$compareValue));
- }
break;
case '<=':
if($value>$compareValue)
- {
$message=$this->message!==null?$this->message:Yii::t('yii','{attribute} must be less than or equal to "{compareValue}".');
- $this->addError($object,$attribute,$message,array('{compareAttribute}'=>$compareTo,'{compareValue}'=>$compareValue));
- }
break;
default:
throw new CException(Yii::t('yii','Invalid operator "{operator}".',array('{operator}'=>$this->operator)));
}
+ if(!empty($message))
+ $this->addError($object,$attribute,$message,array('{compareAttribute}'=>$compareTo,'{compareValue}'=>$compareValue));
}
/**

0 comments on commit 05a9123

Please sign in to comment.
Something went wrong with that request. Please try again.