[feat] 更新浮点数逻辑

This commit is contained in:
Keeko 2022-03-11 16:51:55 +08:00
parent 043137e964
commit 03471b0036
2 changed files with 4 additions and 3 deletions

View File

@ -439,7 +439,7 @@ vscode应用商店中搜索"**any-rule**".
### 浮点数 ### 浮点数
```javascript ```javascript
/^(-?\d+)(\.\d+)?$/ /^(-?[1-9]\d*\.\d+|-?0\.\d*[1-9]\d*|0\.0+)$/
``` ```
### email(支持中文邮箱) ### email(支持中文邮箱)

View File

@ -392,8 +392,9 @@ module.exports = [{
}, },
{ {
title: '浮点数', title: '浮点数',
rule: /^(-?\d+)(\.\d+)?$/, rule: /^(-?[1-9]\d*\.\d+|-?0\.\d*[1-9]\d*|0\.0+)$/,
examples: [1.5] examples: ["1.23", "-1.01", "0.00"]
// allow "1.23", allow "-0.1", allow "0.00", ban "-0.00", allow "2.0", ban "2."
}, },
{ {
title: 'email(支持中文邮箱)', title: 'email(支持中文邮箱)',