PHP code example of petrabarus / yii2-switchcasevalidator
1. Go to this page and download the library: Download petrabarus/yii2-switchcasevalidator library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
petrabarus / yii2-switchcasevalidator example snippets
//Assuming the model has attribute case, field1, and field2.
//Each rule group will be validated when the case attribute match the cases.
public function rules() {
['case', PetraBarus\Yii2\SwitchCaseValidator\Validator::class,
//For PHP 5.4, you can use PetraBarus\Yii2\SwitchCaseValidator\Validator::className() or
// string 'PetraBarus\Yii2\SwitchCaseValidator\Validator'
'cases' => [
1 => [
['field1', 'lue' => 'Value 4'],
]
]
}
php composer.phar