/** * @inheritdoc */ public function rules() { return [[['attribute_1', 'attribute_2'], 'required'], [['attribute_1', 'attribute_2'], 'string', 'max' => 255], [['attribute_2'], AttributeIndexValidator::className(), 'on' => 'validatorWithFilterClosure', 'filter' => function ($query) { $query->andWhere(['attribute_1' => $this->attribute_1]); }], [['attribute_2'], AttributeIndexValidator::className(), 'on' => 'validatorWithFilterArray', 'filter' => ['attribute_1' => 'test']], [['attribute_2'], 'unique', 'filter' => function ($query) { $query->andWhere(['attribute_1' => $this->attribute_1]); }]]; }
/** * @inheritdoc */ public function rules() { return [[['attribute'], AttributeIndexValidator::className(), 'on' => 'validator'], [['attribute'], AttributeIndexValidator::className(), 'startIndex' => 2, 'on' => 'validatorWithCustomStartIndex'], [['attribute'], AttributeIndexValidator::className(), 'separator' => '%', 'on' => 'validatorWithCustomSeparator'], [['attribute'], AttributeIndexValidator::className(), 'separator' => '', 'on' => 'validatorWithEmptySeparator'], [['attribute'], 'required'], [['attribute'], 'unique'], [['attribute'], 'string', 'max' => 255]]; }