创建base.php
protected function isPositiveInteger($value, $rule='', $data='', $field='')
{
$request = Request::instance();
$param = $request->param();//获取全部请求的参数
if (is_numeric($value) && is_int($value + 0) && ($value + 0) > 0) {
return true;
}
return $field . '必须是正整数';
}
validate中创建IDmustINt.php
继承 Base
class IDMustBePositiveInt extends BaseValidate
{
protected $rule = [
'id' => 'require|isPositiveInteger',
];
}