dev-master
9999999-dev https://github.com/matrozov/yii2-eachKeyValue-validatorKeyValue validator for Yii2
MIT
The Requires
- php >=5.6.0
The Development Requires
by Oleg Matrozov
yii2 validator key-value yii2-extension each
KeyValue validator for Yii2
This extension provides the simple key-value validation for Yii framework 2.0., (*1)
For license information check the LICENSE-file., (*2)
The preferred way to install this extension is through composer., (*4)
Either run, (*5)
php composer.phar require --prefer-dist matrozov/yii2-each-key-value-validator
or add, (*6)
"matrozov/yii2-each-key-value-validator": "dev-master"
to the require section of your composer.json., (*7)
class MyClass extends \yii\base\Model { public $data; public function rules() { return [ [['data'], EachKeyValueValidator::class, 'rules' => [ [['key', 'value'], 'string'], // Validate, what key and value must be string. ]], ]; } } $model = new MyModel(); $model->data = [ 'myKey' => 2, ]; $model->validate(); print_r($model->errors);
You got error: Data:value must be a string
!, (*8)
You can assign variable validation for key
and value
pseudo-field., (*9)
KeyValue validator for Yii2
MIT
yii2 validator key-value yii2-extension each