Download the PHP package guirong/laravel-validate without Composer

On this page you can find all versions of the php package guirong/laravel-validate. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-validate

PHP Validate

Php Version GitHub tag (latest by date) Coverage Status GitHub all releases

Laravel 验证器以及验证场景的使用。

项目地址

注意:

  • 版本要求 php >= 5.6.0

    安装

使用

创建地址簿验证器 \App\Http\Requests\AddressRequest

AddressRequest 验证器:

写入内容

接下来在控制器内使用

创建地址簿控制器 \App\Http\Controllers\AddressController

AddressController 控制器:

验证器的调用方式有三种,分别以地址簿的 新增,编辑,删除 三种场景演示:

新增

控制器AddressControllercreate方法注入依赖时,自动绑定验证器AddressRequest中的同名 create 场景进行校验

编辑

控制器AddressControlleredit 方法中,指定验证器AddressRequest中的 update 场景进行校验

验证器AddressRequest 关闭自动校验, autoValidate 修改为 false,

注意:关闭自动校验后,新增中的函数场景自动绑定和 删除 中的路由场景绑定将会失效

删除

定义路由,指定校验场景为 delete , 在控制器AddressControllerdel方法注入依赖时,将自动绑定验证器AddressRequest中的 delete 场景进行校验

app\Providers\AppServiceProvider.php boot 下面添加 scene(场景方法)

来看看这里的路由怎么写的吧

添加路由

route\api.php 内添加

自定义验证规则

方法1、遵循laravel框架内置能力,使用扩展

注册自定义验证规则的方式是使用 Validator 门面上的 extend 方法。我们在某个服务提供者(如 AppServiceProvider)中使用该方法注册一个自定义验证规则:

自定义验证器闭包接收四个参数:要验证的属性名称、属性值、传递给规则的参数数组以及 Validator 实例。

\App\Http\Requests\AddressResuest 验证器内使用

方法2、基于laravel框架内置能力,扩展自定义的验证函数 validate{Method}

扩展自定义验证规则的方式是使用 Validator 验证器上的 addExtension 方法。我们通过引入 CustomExtensionsTrait 特性中的 addCustomExtensions 函数,可在 Validator 验证器内部自动加载自定义验证函数,自定义验证函数命名须符合 validate{Method} 格式,并返回一个闭包

测试

License

MIT

我的其他项目

guirong/cli-message github

一个简单易用的,命令行输出样式工具库

guirong/php-router github

轻量且快速的路由库

guirong/php-closure github

闭包的序列化和反序列化类库

guirong/php-validate github

一个轻量级且功能丰富的验证和过滤库

guirong/php-event github

一个简洁小巧的php事件监听器

guirong/php-shell github

一个基于psysh shell的命令行交互模式依赖包


All versions of laravel-validate with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package guirong/laravel-validate contains the following files

Loading the files please wait ....