init
This commit is contained in:
		
							
								
								
									
										25
									
								
								IntegerValidator.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								IntegerValidator.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,25 @@
 | 
				
			|||||||
 | 
					<?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);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										21
									
								
								composer.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								composer.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,21 @@
 | 
				
			|||||||
 | 
					{
 | 
				
			||||||
 | 
					    "name": "dominion/validators",
 | 
				
			||||||
 | 
					    "description": "Функционал для работы с validators",
 | 
				
			||||||
 | 
					    "type": "yii2-extension",
 | 
				
			||||||
 | 
					    "keywords": ["yii2","extension"],
 | 
				
			||||||
 | 
					    "license": "MIT",
 | 
				
			||||||
 | 
					    "authors": [
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "Rybkin Sasha",
 | 
				
			||||||
 | 
					            "email": "ribkin@dominion.ru"
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    ],
 | 
				
			||||||
 | 
					    "require": {
 | 
				
			||||||
 | 
					        "yiisoft/yii2": "~2.0.0"
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    "autoload": {
 | 
				
			||||||
 | 
					        "psr-4": {
 | 
				
			||||||
 | 
					            "dominion\\validators\\": ""
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user