26 lines
		
	
	
		
			530 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			26 lines
		
	
	
		
			530 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
namespace dominion\validators;
 | 
						|
 | 
						|
use Yii;
 | 
						|
use yii\validators\Validator;
 | 
						|
 | 
						|
 | 
						|
class IntegerValidator extends Validator
 | 
						|
{
 | 
						|
    public function init()
 | 
						|
    {
 | 
						|
        parent::init();
 | 
						|
        if ($this->message === null) {
 | 
						|
            $this->message = Yii::t('yii', '{attribute} must be an integer.');
 | 
						|
        }
 | 
						|
    }
 | 
						|
 | 
						|
    public function validateAttribute($model, $attribute)
 | 
						|
    {
 | 
						|
        if (!is_int($model->$attribute)) {
 | 
						|
            $this->addError($model, $attribute, $this->message);
 | 
						|
        }
 | 
						|
    }
 | 
						|
}
 |