ljsystem/laravel-prohibited 问题修复 & 功能扩展

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

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

ljsystem/laravel-prohibited

Composer 安装命令:

composer require ljsystem/laravel-prohibited

包简介

Adds prohibited form request validations to your Laravel application.

README 文档

README

This package adds seven new form request validations to your Laravel application that allows you to prohibit fields the same way as you usually require them.

Installation

You can install this package via composer using this command:

composer require ljsystem/laravel-prohibited

The package will automatically register itself.

Usage

After installing the package you can use the new rules the same way you would use Laravels official validation rules.

$request->validate([
    'vehicle' => 'required|string|in:car,van,truck,bus,motorcycle',
    'speeding' => 'prohibited',
    'convertible' => 'prohibited_if:vehicle,motorcycle|integer',
    'helmet' => 'prohibited_unless:vehicle,motorcycle|bool',
    'hat' => 'prohibited_with:helmet,convertible|bool',
    'sunglasses' => 'prohibited_with_all:helmet,helmet_has_visor|bool',
    'helmet_has_visor' => 'prohibited_without:helmet|bool',
    'helmet_visor_color' => 'prohibited_without_all:helmet,helmet_has_visor|string|in:clear,tinted',
]);

Available Validation Rules

prohibited

The field under validation must not be present in the input data, regardless of it's value.

prohibited_if:anotherfield,value...

The field under validation must not be present if the anotherfield field is equal to any value.

prohibited_unless:anotherfield,value,...

The field under validation must note be present unless the anotherfield field is equal to any value.

prohibited_with:foo,bar,...

The field under validation must not be present only if any of the other specified fields are present.

prohibited_with_all:foo,bar,...

The field under validation must not be present only if all of the other specified fields are present.

prohibited_without:foo,bar,...

The field under validation must not be present only when any of the other specified fields are not present.

prohibited_without_all:foo,bar,...

The field under validation must not be present only when all of the other specified fields are not present.

Localization

The package comes with English and Swedish translations out of the box. If you wish to add translations for your own language you publish the translations to your applications resource directory by running the following command:

php artisan vendor:publish --provider="Ljsystem\Prohibited\ProhibitedServiceProvider"

This will result in the following file structure:

.
└── resources
    └── lang
        └── vendor
            └── prohibited
                ├── en
                │   └── validation.php
                └── sv
                    └── validation.php

You can now copy either the English or Swedish validation.php and translate it into your prefered language. Feel free to create a Pull Request if you would like to get your translations included in the package.

Testing

You can run the tests with:

vendor/bin/phpunit

Contributing

Please see CONTRIBUTING for details.

License

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

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固