Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

多因子验证bug #3071

Open
LonelySally opened this issue Sep 25, 2024 · 0 comments
Open

多因子验证bug #3071

LonelySally opened this issue Sep 25, 2024 · 0 comments
Labels

Comments

@LonelySally
Copy link

LonelySally commented Sep 25, 2024

所属功能组件

验证器(Validate)

ThinkPHP 版本

8.0.x-dev

操作系统

centos

错误信息

多因子校验未对元数据进行有序数组验证.
多因子校验子数据时require规则无效.

//router
Route::post('/index', 'Index/index')->validate([
            'coupons' => 'require|min:1',
            'coupons.*.goods_id' => 'require|gt:0',
            'coupons.*.par_price' => 'require|egt:0',
            'coupons.*.expiry_datetime' => 'require|egt:0',
]);

//request  application/json;

path /index

//参数1 实际请求验证通过,预期应不通过,因为goods_id par_price expiry_datetime 三项均为必填且coupons并非为有序数组
{
    "coupons": 
        {
            "a": 1
        }
    ,
}

//参数2 实际请求验证通过,预期应不通过,因为goods_id  expiry_datetime 两项为必填
{
    "coupons": [
        {
            "par_price": 1
        }
    ]
}


其它说明

增加多因子验证 user..id user.ids.

  • 'coupons.*.goods_id' => 'require|gt:0', 这里的require只对值做了验证并未针对key是否存在做判断,即缺少isset($value[$i]['goods_id'])==true的验证
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant