Download the PHP package lazyu/validate without Composer
On this page you can find all versions of the php package lazyu/validate. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download lazyu/validate
More information about lazyu/validate
Files in lazyu/validate
Download lazyu/validate
More information about lazyu/validate
Files in lazyu/validate
Vendor lazyu
Package validate
Short Description 一个适用于laravel的验证器
License MIT
Homepage https://github.com/lazy/validate
Package validate
Short Description 一个适用于laravel的验证器
License MIT
Homepage https://github.com/lazy/validate
Please rate this library. Is it a good library?
Informations about the package validate
Laravel 多场景验证器
安装
您可以通过composer安装软件包:
使用
接下来我们来验证一个文章的提交信息,首先我们新建一个文章验证类 ArticleValidate.php 并填充一些内容
如上所示,在这个类中我们定义了验证规则 rule,自定义验证信息 message,以及验证场景 scene
非场景验证
我们只需要定义好规则
check 方法中总共有四个参数,第一个要验证的数据,第二个验证规则,第三个自定义错误信息,第四个验证场景,其中 2,3,4 非必传。 如果验证未通过我们调用 getError() 方法来输出错误信息,getError()暂不支持返回所有验证错误信息 。
场景验证
我们需要提前在验证类中定义好验证场景 如下,支持使用字符串或数组,使用字符串时,要验证的字段需用 , 隔开
然后在我们的控制器进行数据验证
控制器内验证
当然我们也允许你不创建验证类来验证数据
All versions of validate with dependencies
PHP Build Version
Package Version
Requires
php Version
>=7.2
The package lazyu/validate contains the following files
Loading the files please wait ....