Skip to content

Commit e0789b8

Browse files
committed
XandValidator
1 parent fbce8cd commit e0789b8

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/XandValidator.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@
33
namespace thtmorais\validators;
44

55
use Yii;
6-
use yii\validators\Validator;
7-
use yii\i18n\PhpMessageSource;
86

97
/**
108
* Class XandValidator
119
* @package thtmorais\validators
1210
*/
13-
class XandValidator extends Validator
11+
class XandValidator extends \yii\validators\Validator
1412
{
1513
/**
1614
* @var array
@@ -24,11 +22,11 @@ public function init()
2422
{
2523
parent::init();
2624

27-
Yii::setAlias('@thtmorais/yii2-validators', dirname(__DIR__));
25+
Yii::setAlias('@validators', dirname(__DIR__));
2826

29-
Yii::$app->i18n->translations['thtmorais/yii2-validators'] = [
30-
'class' => PhpMessageSource::class,
31-
'basePath' => '@thtmorais/yii2-validators/src/messages'
27+
Yii::$app->i18n->translations['validators'] = [
28+
'class' => '\yii\i18n\PhpMessageSource',
29+
'basePath' => '@validators/src/messages'
3230
];
3331
}
3432

@@ -50,10 +48,10 @@ public function validateAttribute($model, $attribute)
5048
}));
5149

5250
if ($filledCount != 0 && $filledCount != count($this->fields)) {
53-
$this->addError($model, $attribute, Yii::t('thtmorais/yii2-validators', 'All or none of the specified fields must be filled.'));
51+
$this->addError($model, $attribute, Yii::t('validators', 'All or none of the specified fields must be filled.'));
5452

5553
foreach ($this->fields as $field) {
56-
$this->addError($model, $field, Yii::t('thtmorais/yii2-validators', 'All or none of the specified fields must be filled.'));
54+
$this->addError($model, $field, Yii::t('validators', 'All or none of the specified fields must be filled.'));
5755
}
5856
}
5957
}

0 commit comments

Comments
 (0)