public function profileRules()
    {
        return [
            [['username', 'password', 'email'], 'required', 'on' => self::SCENARIO_CREATE],

            ['username', 'match', 'pattern' => '/^[A-Za-z][A-Za-z0-9\-\.\ ]+$/i',
                'message' => Yii::t($this->tcModule, 'Only latin letters, digits, hyphen, points and blanks begin with letter')
            ],
            ['username', 'string', 'min' => $this->minUsernameLength, 'max' => $this->maxUsernameLength],

            ['password', 'string', 'min' => $this->minPasswordLength, 'max' => $this->maxPasswordLength],

            ['email', 'string', 'max' => 255],
            ['email', 'email'],
        ];
    }
public function profileRules()
    {
        return [
            [['username', 'password', 'email'], 'required', 'on' => self::SCENARIO_CREATE],

            ['username', 'match', 'pattern' => '/^[A-Za-z][A-Za-z0-9\-\.\ ]+$/i',
                'message' => Yii::t($this->tcModule, 'Only latin letters, digits, hyphen, points and blanks begin with letter')
            ],
            ['username', 'string', 'min' => $this->minUsernameLength, 'max' => $this->maxUsernameLength],

            ['password', 'string', 'min' => $this->minPasswordLength, 'max' => $this->maxPasswordLength],

            ['email', 'string', 'max' => 255],
            ['email', 'email'],
        ];
    }
public function profileRules ( ) { return [ [ [ 'username' , 'password' , 'email' ] , 'required' , 'on' => self :: SCENARIO_CREATE ] , [ 'username' , 'match' , 'pattern' => '/^[A-Za-z][A-Za-z0-9\-\.\ ]+$/i' , 'message' => Yii :: t ( $ this -> tcModule , 'Only latin letters, digits, hyphen, points and blanks begin with letter' ) ] , [ 'username' , 'string' , 'min' => $ this -> minUsernameLength , 'max' => $ this -> maxUsernameLength ] , [ 'password' , 'string' , 'min' => $ this -> minPasswordLength , 'max' => $ this -> maxPasswordLength ] , [ 'email' , 'string' , 'max' => 255 ] , [ 'email' , 'email' ] , ] ; }
Part of rules for common use with ProfileForm.
Rules with fields length, patterns be best in single place.
Part of rules for common use with ProfileForm . Rules with fields length patterns be best in single place .