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

修复验证器工具类对小数的验证 #705

Merged
merged 6 commits into from
Jul 31, 2024

Conversation

Eno-CN
Copy link
Member

@Eno-CN Eno-CN commented Jun 29, 2024

  • 补充文档验证器注解 @Integer@Decimal@Number 数据类型的说明
  • 修正文档验证器注解 @Number 下的示例

>
> 例如,类似 `5.1` 、 `'5.1'` 、 `'5.0'` 均属于小数
>
> 特殊的,类似 `5.0` 这种**小数部分为0的 `float` 值**不属于小数
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5.0 算小数吧

Copy link
Member Author

@Eno-CN Eno-CN Jul 1, 2024

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后直接就丢失小数点了,然后第二个条件不满足。在整数那里恰好也能过,所以它满足上面提到的整数,而不满足小数的条件。

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我觉得这算bug了,应该修复下代码

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

整数和小数这两个的判断都有涉及这个问题,我觉得如果能严格判断数据类型就更好了,比如再给个严格模式的选项。

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

严格模式不如直接用 php 自带的函数去验证类型,这里的代码需要修复一下,你有空看下吗

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

严格模式不如直接用 php 自带的函数去验证类型,这里的代码需要修复一下,你有空看下吗

@Yurunsoft 可以的,我这周内提个PR吧

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Yurunsoft
已完成以下修复

  1. 修复小数、整数验证函数对浮点数类型的检查
  2. 修复数值验证函数对整数类型或小数部分为0的浮点数类型的小数精度检查

@Yurunsoft Yurunsoft added bug Something isn't working document Document problem labels Jul 31, 2024
@Yurunsoft Yurunsoft changed the title 补充文档验证器注解@Integer、@Decimal和@Number数据类型的说明 修复验证器工具类对小数的验证 Jul 31, 2024
@Yurunsoft Yurunsoft merged commit 56327e3 into imiphp:2.1 Jul 31, 2024
26 of 27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working document Document problem
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants