Skip to content

Commit

Permalink
Merge pull request #30 from lovejc1314/2.x
Browse files Browse the repository at this point in the history
Update README.md
  • Loading branch information
Player626 authored Apr 15, 2021
2 parents 6a8e86b + 0839301 commit a1a107e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ class CustomValidator extends \EasySwoole\Validate\Functions\AbstractValidateFun
$data = ['mobile' => '12312345678'];
$validate = new \EasySwoole\Validate\Validate();
// 先添加function 第一个参数为类 第二个参数 是否覆盖 当存在相同名字的验证规则 参数true会替换掉
$validate->addFunction(new \EasySwoole\Validate\tests\CustomValidator(),false);
$validate->addFunction(new CustomValidator(),false);
// 自定义错误消息示例
$validate->addColumn('mobile')->required('手机号不能为空')->callUserRule(new \EasySwoole\Validate\tests\CustomValidator(), '手机号格式不正确');
$validate->addColumn('mobile')->required('手机号不能为空')->callUserRule(new CustomValidator(), '手机号格式不正确');
$bool = $validate->validate($data); // 验证结果
if ($bool) {
var_dump("验证通过");
Expand All @@ -107,7 +107,7 @@ if ($bool) {

$validate = new \EasySwoole\Validate\Validate();
// * 可以放在任意位置 且有多个
$validate->addColumn('*.a')->required()->notEmpty()->max(1,10);
$validate->addColumn('*.a')->required()->notEmpty()->between(1,10);
$bool = $validate->validate([
'a' => ['a' => 2],
'b' => ['a' => 11]
Expand Down Expand Up @@ -172,4 +172,4 @@ if ($bool) {
*/
```

> 暂不支持 `inArray`,`notInArray`,`func`,`callUserRule`,`allowFile`,`allowFileType`等规则.
> 暂不支持 `inArray`,`notInArray`,`func`,`callUserRule`,`allowFile`,`allowFileType`等规则.

0 comments on commit a1a107e

Please sign in to comment.