thedavefulton/laravel-exclusive-validation-rules 问题修复 & 功能扩展

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

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

thedavefulton/laravel-exclusive-validation-rules

Composer 安装命令:

composer require thedavefulton/laravel-exclusive-validation-rules

包简介

Two additional validation rules for use with the Laravel framework

README 文档

README

Latest Version on Packagist Build Status Quality Score Total Downloads

This package was born out of a need to ensure that for a set of inputs exactly 1 was received. Using existing validation rules could ensure that at least 1 or no more than 1 would be received, but there wasn't a succinct way of guaranteeing exactly one.

As such, two rules were implemented. The first, require_exclusive, ensures that exactly 1 of the inputs will be present. The second, optional_exclusive, allows for none of the inputs to be present but if any are present there must be exactly 1.

Installation

You can install the package via composer:

composer require thedavefulton/laravel-exclusive-validation-rules

The package is configured to use Laravel's automatic discovery. However, you can manually register the service provider in the app/config.php file:

'providers' => [
    // Other Service Providers

    Thedavefulton\ExclusiveValidationRulesServiceProvider::class,
],

Usage

These rules may be used like any standard validation rule.

$attributes= $request->validate([
    'input1' => 'required_exclusive:input2',
    'input2' => 'required_exclusive:input1',
]);

$attributes= $request->validate([
    'input1' => 'optional_exclusive:input2',
    'input2' => 'optional_exclusive:input1',
]);

They can also be extended to n inputs

$attributes= $request->validate([
    'input1' => 'required_exclusive:input2,input3,input4',
    'input2' => 'required_exclusive:input1,input3,input4',
    'input3' => 'required_exclusive:input1,input2,input4',
    'input4' => 'required_exclusive:input1,input2,input3',
]);

Testing

composer test

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 thedave@thedavefulton.com instead of using the issue tracker.

Credits

License

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

Laravel Package Boilerplate

This package was generated using the Laravel Package Boilerplate.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-08-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固