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

requiredIf 规则实现有错误 #2

Closed
nemoTyrant opened this issue Apr 28, 2018 · 4 comments
Closed

requiredIf 规则实现有错误 #2

nemoTyrant opened this issue Apr 28, 2018 · 4 comments
Labels

Comments

@nemoTyrant
Copy link

nemoTyrant commented Apr 28, 2018

requiredIf 的规则应该是: 另一个字段等于某值时,本字段必须; 如果不等于,则不应该检查本字段。

但是在我使用的 v2.4.11 版本中,无论另一个字段是否等于某值,本字段都必须。
原因是 UserAndContextValidatorsTrait.php 178行 判断另一字段不在匹配值中时直接返回了false。

假设改为return true让程序暂时正常进行

另外一个问题是,如果本字段不存在,在getSafeData()的时候会返回一个值为null的字段,我认为不应该返回这个字段。

@inhere inhere added the bug label Apr 28, 2018
@inhere
Copy link
Owner

inhere commented Apr 28, 2018

这样看来 required* 的好像都有点问题,今天晚上回去修复下。

你有兴趣的话可以发个 PR 修复下

我其实很少用 required* 的规则,有点绕脑袋。

我用 required + when 来做类似的验证,用习惯了

@inhere
Copy link
Owner

inhere commented Apr 28, 2018

已经修复,可以更新试下。 v2.4.12

@nemoTyrant
Copy link
Author

好的。你这个项目功能很强大,不知道为啥星这么少,还好我发现了这块宝。我会持续关注的,看看还能不能发现别的问题。哈哈!

@inhere
Copy link
Owner

inhere commented Apr 28, 2018

O(∩_∩)O哈哈~ 感谢关注。 有问题欢迎提出来,更欢迎提PR 😄

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

2 participants