2017 © Pedro Peláez
 

extension yii2-each-key-value-validator

KeyValue validator for Yii2

image

matrozov/yii2-each-key-value-validator

KeyValue validator for Yii2

  • Wednesday, July 4, 2018
  • by matrozov
  • Repository
  • 1 Watchers
  • 0 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

yii2-each-key-value-validator

This extension provides the simple key-value validation for Yii framework 2.0., (*1)

For license information check the LICENSE-file., (*2)

Latest Stable Version Total Downloads License, (*3)

Installation

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)

Usage

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)

The Versions

04/07 2018

dev-master

9999999-dev https://github.com/matrozov/yii2-eachKeyValue-validator

KeyValue validator for Yii2

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

by Oleg Matrozov

yii2 validator key-value yii2-extension each