Browse Source

Shorten two identical statements in compare validator (#18922)

tags/2.0.44
Toir Tuychiev 3 years ago committed by GitHub
parent
commit
3578621833
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      framework/validators/CompareValidator.php

6
framework/validators/CompareValidator.php

@ -16,7 +16,7 @@ use yii\helpers\Html;
* *
* The value being compared with can be another attribute value * The value being compared with can be another attribute value
* (specified via [[compareAttribute]]) or a constant (specified via * (specified via [[compareAttribute]]) or a constant (specified via
* [[compareValue]]. When both are specified, the latter takes * [[compareValue]]). When both are specified, the latter takes
* precedence. If neither is specified, the attribute will be compared * precedence. If neither is specified, the attribute will be compared
* with another attribute whose name is by appending "_repeat" to the source * with another attribute whose name is by appending "_repeat" to the source
* attribute name. * attribute name.
@ -105,14 +105,10 @@ class CompareValidator extends Validator
if ($this->message === null) { if ($this->message === null) {
switch ($this->operator) { switch ($this->operator) {
case '==': case '==':
$this->message = Yii::t('yii', '{attribute} must be equal to "{compareValueOrAttribute}".');
break;
case '===': case '===':
$this->message = Yii::t('yii', '{attribute} must be equal to "{compareValueOrAttribute}".'); $this->message = Yii::t('yii', '{attribute} must be equal to "{compareValueOrAttribute}".');
break; break;
case '!=': case '!=':
$this->message = Yii::t('yii', '{attribute} must not be equal to "{compareValueOrAttribute}".');
break;
case '!==': case '!==':
$this->message = Yii::t('yii', '{attribute} must not be equal to "{compareValueOrAttribute}".'); $this->message = Yii::t('yii', '{attribute} must not be equal to "{compareValueOrAttribute}".');
break; break;

Loading…
Cancel
Save