一、独立验证
//独立验证
class Banner
{
public function getBanner($id)
{
$data = [
'name'=> 'vandvfdvfdvdvfdf',
'email' => 'vfafdaaqq.com'
];
$validate = new Validate([
'name' => 'require|max:10', //验证name长度不得大于10
'email' =>'email' //tp5内置邮箱验证器规则
]);
$result = $validate->batch()->check($data); //验证$data数组
var_dump($validate->getError()) ; //输出$data数组错误信息
}
}
二、构建验证层
建立validate验证层 定义 id验证器类 IDMustBePostiveInt.php
IDMustBePostiveInt.php
<?php
/**
* Created by PhpStorm.
* User: admin
* Date: 2018/6/9
* Time: 20: