Skip to content

Commit

Permalink
Added an error mesage
Browse files Browse the repository at this point in the history
  • Loading branch information
elvenpath committed Mar 15, 2016
1 parent fe3bac2 commit 234ffbe
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions EuVatValidator.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?php
namespace elvenpath\yii2_eu_vatvalidator;

use \SoapClient;
use \Exception;
use \yii\validators\Validator;
use Exception;
use SoapClient;
use Yii;
use yii\validators\Validator;

/**
* Class EuVatValidator
Expand Down Expand Up @@ -51,7 +52,8 @@ public function validateAttribute($model, $attribute)
/** @noinspection PhpUndefinedMethodInspection */
$rs = $this->client->checkVat(['countryCode' => $this->country_code, 'vatNumber' => $model->$attribute]);
if (!$rs->valid) {
$this->addError($model, $attribute, $this->message);
$this->addError($model, $attribute,
$this->message ? $this->message : Yii::t('yii', '{attribute} is invalid.'));
} else {
if ($this->populate_model) {
$this->model_name_attribute = $this->cleanUpString($rs->name);
Expand Down

0 comments on commit 234ffbe

Please sign in to comment.