예제 #1
0
 public function rules()
 {
     $rules = ArrayHelper::merge(parent::rules(), [[['tableName'], 'match', 'pattern' => '/^(\\w+\\.)?([\\w\\*]+)$/', 'message' => 'Only word characters, and optionally an asterisk and/or a dot are allowed.'], [['fields'], MultipleModelValidator::className(), 'baseModel' => Field::className()], [['autoCreateTable', 'useTablePrefix', 'tableNameRequired', 'dropIfExists'], 'boolean'], [['migrationPath', 'migrationCreate', 'migrationName'], 'safe'], [['primaryKeyName', 'fileName'], 'string', 'max' => 20], [['fields'], 'default', 'value' => [new Field(['type' => Schema::TYPE_PK, 'name' => $this->primaryKeyName])]], [['fields'], 'safe']]);
     if ($this->tableNameRequired || $this->autoCreateTable) {
         $rules[] = ['tableName', 'required'];
     }
     return $rules;
 }
예제 #2
0
 public function rules()
 {
     $rules = ArrayHelper::merge(parent::rules(), [[['tableName'], 'required'], [['tableName'], 'match', 'pattern' => '/^(\\w+\\.)?([\\w\\*]+)$/', 'message' => 'Only word characters, and optionally an asterisk and/or a dot are allowed.'], [['fields'], MultipleModelValidator::className(), 'baseModel' => Field::className()], [['useTablePrefix'], 'boolean'], [['migrationPath', 'migrationName'], 'safe']]);
     return $rules;
 }
예제 #3
0
 /**
  * @inheritdoc
  */
 public function rules()
 {
     $rules = ArrayHelper::merge(parent::rules(), []);
     foreach ($rules as $index => &$_next) {
         if ($_next[1] == 'required' && is_array($_next[0])) {
             if (($key = array_search('tableName', $_next[0])) !== false) {
                 unset($_next[0][$key]);
             }
         } else {
             if ($_next[0] == 'tableName') {
                 unset($rules[$index]);
             }
         }
     }
     $rules[] = [['tableName'], 'tableNameValidate', 'skipOnEmpty' => false, 'skipOnError' => false];
     $rules[] = [['behaviorModels'], MultipleModelValidator::className(), 'baseModel' => Behaviors::className()];
     $rules[] = [['createTable'], 'boolean'];
     $rules[] = [['tableBuilder', 'customBehaviors'], 'safe'];
     return $rules;
 }
예제 #4
0
 public function rules()
 {
     return ArrayHelper::merge(parent::rules(), [[['columns'], MultipleModelValidator::className(), 'baseModel' => WidgetsCrud::className(), 'skipOnEmpty' => true], [['baseControllerFrontendClass', 'baseControllerBackendClass'], 'filter', 'filter' => 'trim'], [['baseControllerFrontendClass', 'baseControllerBackendClass'], 'required'], [['baseControllerFrontendClass', 'baseControllerBackendClass'], 'match', 'pattern' => '/^[\\w\\\\]*$/', 'message' => 'Only word characters and backslashes are allowed.'], [['baseControllerFrontendClass', 'baseControllerBackendClass'], 'validateClass', 'params' => ['extends' => Controller::className()]], [['baseControllerFrontendClass', 'baseControllerBackendClass'], 'match', 'pattern' => '/Controller$/', 'message' => 'Controller class name must be suffixed with "Controller".'], [['baseControllerFrontendClass', 'baseControllerBackendClass'], 'match', 'pattern' => '/(^|\\\\)[A-Z][^\\\\]+Controller$/', 'message' => 'Controller class name must start with an uppercase letter.']]);
 }