```
~~~
<?php
namespace app\api\controller\v1;
use think\Validate;
class Banner{
//获取指定id的banner信息
public function getBanner($id)
{
//1.独立验证
//验证数据
$data=[
'name'=>'vendor111111',
'email'=>'vendorqq.com'
];
//验证规则
$validate =new Validate([
'name'=>'require|max:10',
'email'=>'email'
]);
//执行验证//加上batch为批量验证
$result=$validate->batch()->check($data);
var_dump($validate->getError());
}
}
~~~
```
结果:
![](https://box.kancloud.cn/43daad40430911d04d643c1805108e14_1329x603.png)