Skip to content

Commit eaa2f15

Browse files
committed
update readme. bug fixed for string len vaidate
1 parent 02c4224 commit eaa2f15

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ public function get(string $key, $default = null)
572572
`url` | URL 过滤,移除所有不符合 URL 的字符 | `['field', 'url', 'filter' => 'url'],`
573573
`email` | email 过滤,移除所有不符合 email 的字符 | `['field', 'email', 'filter' => 'email'],`
574574
`encoded` | 去除 URL 编码不需要的字符,与 `urlencode()` 函数很类似 | `['imgUrl', 'url', 'filter' => 'encoded'],`
575-
`specialChars` | 相当于使用 `htmlspecialchars()` 转义数据 | `['content', 'string', 'filter' => 'specialChars'],`
575+
`escape/specialChars` | 相当于使用 `htmlspecialchars()` 转义数据 | `['content', 'string', 'filter' => 'specialChars'],`
576576
`quotes` | 应用 `addslashes()` 转义数据 | `['content', 'string', 'filter' => 'quotes'],`
577577

578578
<a name="built-in-validators"></a>

src/Filter/FilterList.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ public static function encoded($var, $flags = 0)
182182
}
183183

184184
/**
185-
* 应用 addslashes() 转义数据
185+
* 应用 addslashes() 转义数据
186186
* @param string $var
187187
* @return string
188188
*/
@@ -192,7 +192,7 @@ public static function quotes($var)
192192
}
193193

194194
/**
195-
* HTML 转义字符 '"<>& 以及 ASCII 值小于 32 的字符。
195+
* like htmlspecialchars(), HTML 转义字符 '"<>& 以及 ASCII 值小于 32 的字符。
196196
* @param string $var
197197
* @param int $flags 标志
198198
* FILTER_FLAG_STRIP_LOW - 去除 ASCII 值在 32 以下的字符
@@ -210,6 +210,16 @@ public static function specialChars($var, $flags = 0)
210210
return filter_var($var, FILTER_SANITIZE_SPECIAL_CHARS, $settings);
211211
}
212212

213+
/**
214+
* @param $var
215+
* @param int $flags
216+
* @return string
217+
*/
218+
public static function escape($var, $flags = 0)
219+
{
220+
return self::specialChars($var, $flags);
221+
}
222+
213223
/**
214224
* HTML 转义字符 '"<>& 以及 ASCII 值小于 32 的字符。
215225
* @param string $var

src/ValidatorList.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ public static function alphaDash($val)
217217
public static function size($val, $min = null, $max = null)
218218
{
219219
$options = [];
220-
if (is_numeric($val)) {
220+
if (\is_int($val)) {
221221
$val = (int)$val;
222222
} elseif (\is_string($val)) {
223223
$val = Helper::strlen(trim($val));

0 commit comments

Comments
 (0)