thinkphp5独立验证规则-编写

创建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',
    ];
}
上一篇:oracle 11g安装补丁


下一篇:STL使用小记