TestValidate 类未找到,报错,代码我是照抄的,麻烦老师帮我指正一下具体错误的地方,谢谢
Banner.php
<?php
namespace app\api\controller\v1;
use think\Validate;
class Banner
{
/*
* 获取指定id的banner信息
* @url /banner/:id
* @http GET
* @id banner的id号
* */
public function getbanner($id)
{
$data = [
'name' => 'vendorooooooooooooo',
'email' => 'vendorqq.com'
];
// $validate=new validate([
// 'name'=>'require|max:10',
// 'email'=>'email'
// ]);
$validate = new TestValidate();
$result = $validate->batch()
->check($data);
var_dump($validate->getError());
}
}
?>
TestValidate.php
<?php
/**
* Created by PhpStorm.
* User: john
* Date: 2018/3/17
* Time: 9:52
*/
namespace app\api\validate;
use think\Validate;
class TestValidate extends Validate
{
protected $rule = [
'name' => 'require|max:10',
'email' => 'email'
];
}
?>