-
Notifications
You must be signed in to change notification settings - Fork 107
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
增加DB验证器 #146
增加DB验证器 #146
Conversation
*/ | ||
public function validate(string $column, $value, ...$params): bool | ||
{ | ||
return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里怎么直接return?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里提了pr,就忘了说了,bitint长度比php的int最大值大,所以使用传统的is_int似乎不太合理,就想问一下,bitint的处理这里,因为平常使用bigint,都没有到过php处理的最大值。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我是想先用is_int 处理,如果是字符串,再用正则匹配,这里想问问你们的意见
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
建议用BCmatch 来处理bigint
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wujunze 好的,谢谢,我试一下
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
请补充一下单元测试
*/ | ||
public function validate(string $column, $value, ...$params): bool | ||
{ | ||
return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
直接return true 是不是不太合理
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
嗯,这里我会再改一下,后面会抽空把单侧补上。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK 单测很有必要👍
单测已经完善了。。另外bigint也处理了 😄 |
验证抛出的文案没法自定义? |
@huangzhhui 这里的逻辑是沿用之前DB验证器的逻辑,所以文案也是直接写死在程序里了
后面可以把上述的逻辑改一下,可以让用户注入自己的DB类型验证器。 另外就是,现在bean的逻辑似乎只能注入一个bean,使用者没有办法覆写官方使用的bean,比如 我们要不要把bean的功能再强化一下,比如设置一个level,高级别的Bean可以覆盖低级别的Bean,这样我们实例化bean的时候,就能拿到高级别的bean |
不用设定等级,直接用户定义的配置覆盖框架定义的就好了 |
* 增加DB验证器 * bigint validate * 增加bigint、tinyint、smallint Validator的单测 * 完善bigint Validator 以及对应单测 * 完善单测
* 增加DB验证器 * bigint validate * 增加bigint、tinyint、smallint Validator的单测 * 完善bigint Validator 以及对应单测 * 完善单测
* 增加DB验证器 * bigint validate * 增加bigint、tinyint、smallint Validator的单测 * 完善bigint Validator 以及对应单测 * 完善单测
FIx
2018-07-19 16:46:48 [warning] [SwoftDemoTieba] [logid:5b504ff83cf05] [spanid:0] trace[Executor.php:516,Swoft\Db\Executor::validate] 验证器不存在,beanName=DbTinyintValidator