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

支持复杂验证条件,以及条件动态参数问题 #2893

Open
wants to merge 2 commits into
base: 8.0
Choose a base branch
from

Conversation

cainiaoer
Copy link

条件动态参数验证方式

protected $rule =   [
        'nickname'  => 'require|max:20|unique:member,is_del=0&is_hid'
];

验证

$validate=new \app\validate\Member;
$data['is_hid']=1;
$check_result=$validate->check($data);

最终验证member用户表中是否含有is_del为0,is_hid为1,与输入昵称重复的用户

条件动态参数验证方式
```
protected $rule =   [
        'nickname'  => 'require|max:20|unique:member,is_del=0&is_hid'
];
```
验证
```
$validate=new \app\validate\Member;
$data['is_hid']=1;
$check_result=$validate->check($data);
```
最终验证member用户表中是否含有`is_del`为0,`is_hid`为1,与输入昵称重复的用户
@axguowen
Copy link

axguowen commented Jun 8, 2023

it's a good idea

@cainiaoer
Copy link
Author

https://www.kancloud.cn/manual/thinkphp6_0/1037629
主要是修复这块儿问题
image

@yuanzhihai
Copy link
Contributor

 elseif (strpos( $key,'=' )) {
        parse_str( $key,$map );
}

少了一个判断 加上就好了

更新上次提交代码中的strpos为str_contains
@big-dream big-dream linked an issue Mar 6, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

验证器unique复杂条件验证的问题
3 participants