<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
insolita / yii2-array-structure-validator example snippets
public function rules()
{
return [
//...
['simpleArray', ArrayStructureValidator::class,
'rules'=>[
'id'=>[[']]
]]
],
];
}
public function rules()
{
return [
//...
[['multiArray', 'some', 'attrs'], ''rules'=>[
'id'=>[['range'=>['male','female']]
]]
]
];
}
public function rules()
{
return [
//...
['complexArray', ArrayStructureValidator::class,
'rules'=>[
'user'=>[[ArrayStructureValidator::class,
'rules'=>[
'id'=>[[' 'x'=>[['
public function rules()
{
return [
//...
['conditional', ArrayStructureValidator::class,
'rules'=>[
'a'=>[['integer','min'=>0]], //will be checked on any scenario
'b'=>[
['default', 'value'=>1, 'on'=>['create']],
['integer', 'max'=>10, 'except'=>['create']],
['
public function rules()
{
return [
['array', ArrayStructureValidator::class, 'rules'=>[
'item'=>[['- Dynamic model with attributes equals value data, or value row, if used with each=>true
* $attribute - current keyName
* $index - current array index for multidimensional arrays, or null
* $baseModel - instance of initial model, where validator was attached
* $baseAttribute - name of initial attributed, where validator was attached
* access to validated value - $model->$attribute
* access to whole validated array $baseModel->$baseAttribute
* $model->addError($attribute, '[{index}][{attribute}] Error message', ['index'=>$index]);
*/
}