Skip to content

Commit 821b24b

Browse files
authored
Merge pull request #34 from ijunyu/fix
fix typo
2 parents 3749f60 + 8f37c9b commit 821b24b

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

README.md

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ validate 同时支持两种规则配置方式,对应了两种规则的收集
5555
5656
## 项目地址
5757

58-
- **github** https://github.com/inhere/php-validate.git
59-
- **gitee** https://gitee.com/inhere/php-validate.git
58+
- **github** <https://github.com/inhere/php-validate.git>
59+
- **gitee** <https://gitee.com/inhere/php-validate.git>
6060

6161
> **注意:** master 分支是要求 `php7.1+` 的(推荐使用)。`1.x` 分支是支持php5的代码分支,但是基本上不再维护。
6262
@@ -70,6 +70,7 @@ composer require inhere/php-validate
7070
## 立即使用
7171

7272
<a name="how-to-use1"></a>
73+
7374
### 方式1: 直接使用类 `Validation`
7475

7576
需要快速简便的使用验证时,可直接使用 `Inhere\Validate\Validation`
@@ -101,7 +102,8 @@ class SomeController
101102
```
102103

103104
<a name="how-to-use2"></a>
104-
### 方式1: 继承类 `Validation`
105+
106+
### 方式2: 继承类 `Validation`
105107

106108
创建一个新的class,并继承 `Inhere\Validate\Validation`。用于一个(或一系列相关)请求的验证, 相当于 laravel 的 表单请求验证
107109

@@ -226,6 +228,7 @@ $db->save($safeData);
226228
```
227229

228230
<a name="how-to-use3"></a>
231+
229232
### 方式3: 使用trait `ValidationTrait`
230233

231234
创建一个新的class,并使用 Trait `Inhere\Validate\ValidationTrait`
@@ -347,8 +350,8 @@ $v = Validation::make($_POST,[
347350
class AdemoValidator extends \Inhere\Validate\Validator\AbstractValidator
348351
{
349352

350-
351-
public function validate($value, $data): bool
353+
354+
public function validate($value, $data): bool
352355
{
353356
if ($value == 1) {
354357
return true;
@@ -362,6 +365,7 @@ class AdemoValidator extends \Inhere\Validate\Validator\AbstractValidator
362365
```
363366

364367
<a name="on-in-Validation"></a>
368+
365369
## **验证前置/后置**处理
366370

367371
* 方式1: 在 `Validation`
@@ -385,7 +389,9 @@ class PageValidation extends Validation
385389
}
386390
}
387391
```
392+
388393
* 方式2: `onBeforeValidate`&`onAfterValidate`
394+
389395
```php
390396
use Inhere\Validate\Validation;
391397

@@ -398,7 +404,7 @@ $v->onBeforeValidate(function (Validation $v) {
398404
});
399405

400406
$v->onAfterValidate(function (Validation $v) {
401-
407+
402408
});
403409

404410
$v->validate();
@@ -590,7 +596,7 @@ $v->validate();
590596
- 允许同时使用多个过滤器。字符串使用 `|` 分隔,或者配置为数组。
591597
- 注意: 写在当前类里的过滤器方法必须带有后缀 `Filter`, 以防止对内部的其他的方法造成干扰
592598
- 通过类 `Filtration`,可以独立使用过滤器功能
593-
- php内置过滤器请参看 http://php.net/manual/zh/filter.filters.sanitize.php
599+
- php内置过滤器请参看 <http://php.net/manual/zh/filter.filters.sanitize.php>
594600

595601
## 场景验证
596602

@@ -639,8 +645,8 @@ $v->setSecne('update')->validate();
639645

640646
```
641647

642-
643648
<a name="built-in-filters"></a>
649+
644650
## 内置的过滤器
645651

646652
> 一些 php 内置的函数可直接使用。 e.g `trim|ucfirst` `json_decode` `md5`
@@ -671,6 +677,7 @@ $v->setSecne('update')->validate();
671677
`quotes` | 应用 `addslashes()` 转义数据 | `['content', 'string', 'filter' => 'quotes'],`
672678

673679
<a name="built-in-validators"></a>
680+
674681
## 内置的验证器
675682

676683
> `/` 分隔的验证器,表明功能是一样的,只是有不同的别名
@@ -756,6 +763,7 @@ $v->setSecne('update')->validate();
756763
### 一些补充说明
757764

758765
<a name="about-empty-value"></a>
766+
759767
#### 关于为空判断
760768

761769
字段符合下方任一条件时即为「空」
@@ -767,6 +775,7 @@ $v->setSecne('update')->validate();
767775
- 该值为没有路径的上传文件
768776

769777
<a name="about-bool-value"></a>
778+
770779
#### 关于布尔值
771780

772781
值符合下列的任意一项即认为是为bool值(不区分大小写)
@@ -978,4 +987,3 @@ phpunit
978987

979988
- [inhere/console](https://github.com/inhere/php-validate) 轻量且功能丰富的命令行应用, 控制台交互,工具库
980989
- [inhere/sroute](https://github.com/inhere/php-srouter) 轻量且快速的HTTP请求路由库
981-

0 commit comments

Comments
 (0)