bachilli/laravel-request-rules 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

bachilli/laravel-request-rules

Composer 安装命令:

composer require bachilli/laravel-request-rules

包简介

Stop duplicating code and validations for FormRequests. This package provides reuse of FormRequest components in a generic way!

README 文档

README

Latest Version on Packagist Build Status Quality Score Total Downloads

Stop duplicating code and validations for FormRequests. This package provides reuse of FormRequest rules in a generic way!

Installation

You can install the package via composer:

composer require bachilli/laravel-request-rules

Usage

Create your main FormRequests with all your validation rules. After that, create unique FormRequests for your controller methods. There is an example of a StoreProductRequest:

public function rules()
    {
        return RequestRule::resolveRules(
            [
            'name' => 'required',
            ],
            [
                RequestRule::merge(VolumeEntityFormRequest::class, 'volumes.*', 'required|array')->only(['dimensions'])->get(),
                RequestRule::merge(ProductEntityFormRequest::class, 'products.*')->except(['price'])->get(),
            ]);
    }

The first array on resolveRules method is exclusive for your FormRequest, the second array is the composed rules, imported from other FormRequests.

Methods

There some helper methods available to use when you're importing rules. Below the description of all methods.

merge(SomeFormRequest::class, 'desired_field_name', 'optional_validations")

In the desired_field_name you can pass with the suffix .* to specify an array field.

The optional_validations are useful when you need an array field and want some validation, like required.

only(['field_name', SomeFormRequest::class])

You can import only rules if you want.

except(['field_name', SomeFormRequest::class])

You can do the opposite, importing all rules, except the specified ones.

Testing

Not implemented yet.

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email bachilli@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 10
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 7
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-02-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固