Mitesh Shah
Mitesh Shah

Reputation: 123

Yii2 - facing issue with default password length validation

In my signup form model ,i have not added Minimum Password length validator. but still i am getting it as validation error. can anyone help to solve this . how to stop that validation execution even though i have not added it in rules array. below is my code.

    <?php

namespace app\models;

use app\models\User;
use yii\base\Model;
use Yii;

/**
 * Signup form
 */
class SignupForm extends Model {

    public $username;
    public $email;
    public $password;
    public $password_repeat;
    public $unit_id;
    public $timezone;

    /**
     * @inheritdoc
     */
    public function rules() {
        $array_rule = [
            ['username', 'filter', 'filter' => 'trim'],
            ['username', 'required'],
            ['username', 'unique', 'targetClass' => '\app\models\User', 'message' => 'This username has already been taken.'],
            ['username', 'string', 'min' => 2, 'max' => 255],
            ['unit_id', 'integer'],
            ['email', 'filter', 'filter' => 'trim'],
            ['email', 'required'],
            ['email', 'email'],
            ['email', 'string', 'max' => 255],
            ['email', 'unique', 'targetClass' => '\app\models\User', 'message' => 'This email address has already been taken.'],
           ];
return $array_rule;
    }

public function signup() {
        if (!$this->validate()) {
            print_r($this->getErrors());
        }
}
}?>

Upvotes: 3

Views: 1504

Answers (1)

zakrzu
zakrzu

Reputation: 595

You must add rules for password field, then could be loaded via $model->load

so add to rules array:

['password','safe'] or ['passwprd','string','min'=>5,'mix'=>50];

Upvotes: 1

Related Questions