修复错误的验证规则

This commit is contained in:
Chenx221 2024-02-10 12:00:16 +08:00
parent eb6cf82904
commit 068af76756

View File

@ -42,10 +42,10 @@ class User extends \yii\db\ActiveRecord implements IdentityInterface
public function rules()
{
return [
[['username', 'password', 'password2'], 'required', 'on' => 'login'],
[['username', 'password'], 'required', 'on' => 'login'],
[['username', 'password', 'email', 'password2'], 'required', 'on' => 'register'],
['username', 'string', 'min' => 3, 'max' => 12],
['password', 'string', 'min' => 6, 'max' => 12],
['password', 'string', 'min' => 6, 'max' => 24],
['password2', 'compare', 'compareAttribute' => 'password', 'on' => 'register'],
['email', 'email', 'on' => 'register'],
['username', 'unique', 'on' => 'register'],