关于探讨 think-validate 验证器
# 前因
自己比较懒 不想一直使用创建类的方法 以及手动使用规则验证 所以写了一个中间件来按照格式自动调用验证器 而且之前也使用过thinkphp的验证器validate',$controller);
$validate = str_replace('Controller','',$validate);
//验证器如果不存在ValidateException($validate_object->getError());
}
}catch (ValidateException $e){
//错误返回格式可以自定义',
'id.integer' => 'id必须为整数',
'title.require' => '标题不能为空',
'title.max' =>'标题最多不能超过255个字符',
'title.min' => '标题最少不能少于1个字符',
];
public $scene = [
'