Thinkphp6笔记十三:验证器(控制器验证)

控制器单独验证

<?php
namespace appadmincontroller;
class Index extends AdminBase
{

    public function test(){

        $validate = 	hinkfacadeValidate::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

作者:狂奔的蜗牛

转载请注明出处

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

原文地址:https://www.cnblogs.com/wesky/p/12661002.html