控制器单独验证

<?php
namespace app\admin\controller;
class Index extends AdminBase
{

    public function test(){

        $validate = \think\facade\Validate::rule([
            'name'  => 'require|max:25',
            'email' => 'email',
            'age' => 'require',
        ]);

        $data = [
            'name'  => '3333',
            'email' => 'thinkphp@qq.com',
            'age' => ''
        ];

        if (!$validate->check($data)) {
            print_r($validate->getError());
            dump($validate->getError());
        }

    }

}

 

 

************************************************

Thinkphp高级交QQ流群:101766150

作者:狂奔的蜗牛

转载请注明出处

************************************************

相关文章:

  • 2022-12-23
  • 2021-09-05
  • 2021-11-24
  • 2021-12-28
  • 2022-12-23
  • 2022-12-23
  • 2021-05-18
  • 2022-12-23
猜你喜欢
  • 2021-08-28
  • 2021-10-16
  • 2022-12-23
  • 2022-12-23
  • 2022-02-07
  • 2020-04-21
  • 2021-10-19
相关资源
相似解决方案