Skip to content

Commit 831625e

Browse files
committed
update readme, bug fixed
1 parent c027d64 commit 831625e

File tree

4 files changed

+10
-23
lines changed

4 files changed

+10
-23
lines changed

README.md

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#php-validate
1+
# php-validate
22

3-
> a simple validate library of the php
3+
> a simple validate library of the php. the is for php5 branch.
44
55
### Install
66

@@ -11,22 +11,11 @@ edit `composer.json`
1111
_require_ add
1212

1313
```
14-
"inhere/php-validate": "dev-master",
15-
```
16-
17-
_repositories_ add
18-
19-
```
20-
"repositories": [
21-
{
22-
"type": "git",
23-
"url": "https://git.oschina.net/inhere/php-validate"
24-
}
25-
]
14+
"inhere/php-validate": "dev-php5",
2615
```
2716

2817
run: `composer update`
2918

3019
### Document
3120

32-
See [document](document.md)
21+
See [document](document.md)

src/StrainerList.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ public static function inputMulti($type, array $filters=[])
3030
*/
3131
public static function trim($var)
3232
{
33-
return is_array($var) ? array_walk_recursive(function($val)
33+
return is_array($var) ? array_walk_recursive($var, function(&$val)
3434
{
35-
return trim((string)$val);
36-
}, $var) : trim((string)$var);
35+
$val = trim((string)$val);
36+
}) : trim((string)$var);
3737
}
3838

3939
/**

src/ValidationTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,10 @@ public function validate(array $onlyChecked = [], $hasErrorStop=false)
171171
$skipOnEmpty = isset($rule['skipOnEmpty']) ? $rule['skipOnEmpty'] : true;
172172

173173
// 如何判断属性为空 默认使用 empty($data[$attr]). 也可自定义
174+
$isEmpty = [ ValidatorList::class, 'isEmpty'];
175+
174176
if ( isset($rule['isEmpty']) && $rule['isEmpty'] instanceof \Closure ) {
175177
$isEmpty = $rule['isEmpty'];
176-
} else {
177-
$isEmpty = [ ValidatorList::class, 'isEmpty'];
178178
}
179179

180180
// 自定义当前验证的错误提示消息

src/ValidatorList.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ public static function dirName($dir)
549549
* @param array $filter 过滤/验证器 {@link http://php.net/manual/zh/filter.filters.php}
550550
* @param array $options 一个选项的关联数组,或者按位区分的标示。
551551
* 如果过滤器接受选项,可以通过数组的 "flags" 位去提供这些标示。
552-
* @return mixed 如果成功的话返回所请求的变量。
552+
* 如果成功的话返回所请求的变量。
553553
* 如果成功的话返回所请求的变量。
554554
* 如果过滤失败则返回 FALSE ,
555555
* 如果 varName 不存在的话则返回 NULL 。
@@ -579,7 +579,6 @@ public static function multi(array $data, array $filters=[])
579579
* options 用于指明任何想要用于过滤器的选项。
580580
* 参考下面的例子来更好的理解这段说明。
581581
* @param bool $addEmpty 在返回值中添加 NULL 作为不存在的键。
582-
* @return mixed
583582
* 如果成功的话返回一个所请求的变量的数组,
584583
* 如果失败的话返回 FALSE 。
585584
* 对于数组的值,
@@ -596,7 +595,6 @@ public static function inputMulti($type, $definition, $addEmpty=true)
596595
* 检查变量名是否存在
597596
* @param int $type One of INPUT_GET, INPUT_POST, INPUT_COOKIE, INPUT_SERVER, or INPUT_ENV. 要检查的输入数据
598597
* @param string $varName Name of a variable to check. 要检查的变量名
599-
* @return bool
600598
*/
601599
public static function inputHasVar($type, $varName)
602600
{

0 commit comments

Comments
 (0)