From 92c944981f559a46693429d092523e0585bc85f9 Mon Sep 17 00:00:00 2001 From: kuangweijian <867034892@qq.com> Date: Mon, 28 Mar 2022 12:08:02 +0800 Subject: [PATCH] =?UTF-8?q?=E7=8B=AC=E7=AB=8B=E9=AA=8C=E8=AF=81=E5=99=A8?= =?UTF-8?q?=E6=94=BE=E5=9C=A8rules=E4=B8=AD=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/my-validator.php | 25 ------------------------- src/UserInput.php | 2 ++ 2 files changed, 2 insertions(+), 25 deletions(-) delete mode 100644 examples/my-validator.php diff --git a/examples/my-validator.php b/examples/my-validator.php deleted file mode 100644 index 125d05e..0000000 --- a/examples/my-validator.php +++ /dev/null @@ -1,25 +0,0 @@ -'login']); - $inputDate=[ - "name" => "kuangweijian", - "password" => "123456546", - ]; - $model->setAttributes($inputDate); - - //使用独立验证器 - $validator = new MyValidator(); - if($validator->validateAttribute($model, "name")){ - echo "login succ".PHP_EOL; - }else{ - echo "login failed".PHP_EOL; - print_r($model->getErrors()); - } -?> \ No newline at end of file diff --git a/src/UserInput.php b/src/UserInput.php index 2fa1f4d..7d3a702 100644 --- a/src/UserInput.php +++ b/src/UserInput.php @@ -3,6 +3,7 @@ use yii\base\Model; use yii\validators\Validator; + use Wiggins\MyProject\MyValidator; /** * UserInput类是用于用户登录或注册场景中输入数据 @@ -69,6 +70,7 @@ ['pwdConfirm','compare','compareAttribute'=>'password','message'=>'两次密码必须一致'], [['name','email','password','pwdConfirm'],'required','on'=>'register'], [['name','password'],'required','on'=>'login'], + [['name'],'Wiggins\MyProject\MyValidator'], ]; } }