From 8686e2cfc4a4ae8b0991af64fca2e75758fdd84d Mon Sep 17 00:00:00 2001 From: Sasha Rybkin Date: Wed, 20 Nov 2024 16:01:42 +0300 Subject: [PATCH] init --- IntegerValidator.php | 25 +++++++++++++++++++++++++ composer.json | 21 +++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 IntegerValidator.php create mode 100644 composer.json diff --git a/IntegerValidator.php b/IntegerValidator.php new file mode 100644 index 0000000..6c0319e --- /dev/null +++ b/IntegerValidator.php @@ -0,0 +1,25 @@ +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); + } + } +} diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..4caec13 --- /dev/null +++ b/composer.json @@ -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\\": "" + } + } +} \ No newline at end of file