Skip to content

Commit

Permalink
bug fixed for auto set the min value for size validate. update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Dec 5, 2017
1 parent 5d98b04 commit f45cfd8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
25 changes: 22 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,31 @@
- 方便的获取错误信息,验证后的安全数据获取
- 已经内置了40多个常用的验证器[内置验证器](#built-in-validators)
- 规则设置参考自 yii 的。部分规则参考自 laravel
- 新增了独立的过滤器 `Inhere\Validate\Filter\Filtration` 用于数据过滤

支持两种规则配置方式:

- `Validation/RuleValidation` 规则配置类似于Yii: 每条规则中,允许多个字段,但只能有一个验证器。
- e.g `['tagId,userId,name,email,freeTime', 'required', ...]`(下面的示例都是这种)

e.g (下面的示例都是这种)

```php
[
['tagId,userId,name,email,freeTime', 'required', ...],
// ... ...
];
```

- `FieldValidation` 规则配置类似于Laravel: 每条规则中,只能有一个字段,但允许多个验证器。
- e.g `['field', 'required|string:5,10|...', ...]`

> 新增了独立的过滤器 `Inhere\Validate\Filter\Filtration` 用于数据过滤
e.g

```php
[
['field', 'required|string:5,10|...', ...],
// ... ...
]
```

## 项目地址

Expand Down
4 changes: 2 additions & 2 deletions src/ValidationTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -393,9 +393,9 @@ protected function prepareRule(array $rule)
case 'range':
case 'string':
case 'between':
// fixed: 当只有 max 时,自动补充一个 min
// fixed: 当只有 max 时,自动补充一个 min. PHP_INT_MIN 在 php 5 不可用
if (isset($rule['max']) && !isset($rule['min'])) {
$rule['min'] = PHP_INT_MIN;
$rule['min'] = - PHP_INT_MAX;
}
break;
}
Expand Down

0 comments on commit f45cfd8

Please sign in to comment.