think-validate使用场景验证报错

oscar

使用的版本是

"topthink/think-validate": "^2.0"
class MemberValidate extends Validate
{
    protected $rule =   [
        'name'  => 'require|length:3,25',
        'password' => 'require|length:8,16',
        'email' => 'require|email'
    ];

    protected $message  =   [
        'name.require' => '名称不能为空',
        'name.length'     => '名称长度在3-25个字符',
        'password.require'   => '密码不能为空',
        'password.length'  => '密码长度在8-16个字符',
        'email'        => '请输入有效的邮箱地址'
    ];

    protected $scene = [
        'register'  =>  ['name','password','email'],
        'login'  =>  ['password','email']
    ];

}

$validate  =  new MemberValidate();
//$rs  = $validate->check($data); //这样是正常的,下面加场景验证就报错。
$rs  = $validate->scene('login')->check($data);

报错信息如下:

filter_var(): Argument #3 ($options) must be of type array|int, null given
1739 2 0
2个回答

walkor 打赏

看起来是 topthink/think-validate 这个项目不支持php8

  • 暂无评论
yzh52521
  • 暂无评论
年代过于久远,无法发表回答
×
🔝