-
-
Notifications
You must be signed in to change notification settings - Fork 169
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
修复验证器工具类对小数的验证 #705
修复验证器工具类对小数的验证 #705
Conversation
doc/components/validation/index.md
Outdated
> | ||
> 例如,类似 `5.1` 、 `'5.1'` 、 `'5.0'` 均属于小数 | ||
> | ||
> 特殊的,类似 `5.0` 这种**小数部分为0的 `float` 值**不属于小数 |
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.
5.0 算小数吧
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.
5.0 算小数吧
我记得应该是5.0的float值转string后直接就丢失小数点了,然后第二个条件不满足。在整数那里恰好也能过,所以它满足上面提到的整数,而不满足小数的条件。
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.
我觉得这算bug了,应该修复下代码
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.
严格模式不如直接用 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.
严格模式不如直接用 php 自带的函数去验证类型,这里的代码需要修复一下,你有空看下吗
@Yurunsoft 可以的,我这周内提个PR吧
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.
@Yurunsoft
已完成以下修复
- 修复小数、整数验证函数对浮点数类型的检查
- 修复数值验证函数对整数类型或小数部分为0的浮点数类型的小数精度检查
修复数值验证函数对整数类型或小数部分为0的浮点数类型的小数精度检查
@Integer
、@Decimal
和@Number
数据类型的说明@Number
下的示例