arandilopez/laravel-profane
Composer 安装命令:
composer require arandilopez/laravel-profane
包简介
Laravel Profanity Valitador
README 文档
README
I made this package to perform a validation for swearwords using Laravel validation service.
Installation
Install via composer
composer require arandilopez/laravel-profane
Configuration
Add the ProfaneServiceProvider class in your config/app.php file.
<?php return [ // ... 'providers' => [ // ... LaravelProfane\ProfaneServiceProvider::class, ]; // ... ];
Publish vendor lang files if you need to replace by your own.
php artisan vendor:publish
Usage
This package register a custom validator. You can use in your controller's validate function.
<?php // ... class MyController extends Controller { public function store(Request $request) { $this->validate($request, [ 'username' => 'required|profane' ]); // ... } }
The validator will load the default locale in your config/app.php file configuration which by is en. If your locale is not supported, please post an issue for this project
If you want to use others dictionaries you can pass them as parameters in the validator.
<?php // ... class MyController extends Controller { public function store(Request $request) { $this->validate($request, [ 'username' => 'required|profane:es,en' ]); // ... } }
You can also send as parameter a path of a file which is a dictionary in order to replace the default dictionary or add a new non supported locale.
<?php // ... class MyController extends Controller { public function store(Request $request) { $this->validate($request, [ 'username' => 'required|profane:es,en,'.resource_path('lang/fr/dict.php') ]); // ... } }
Strict validation
Now you can strictly validate the exact profane word in the content.
<?php // ... class MyController extends Controller { public function store(Request $request) { $this->validate($request, [ 'username' => 'required|strictly_profane:es,en' ]); // ... } }
This fixes known issues when you get a error in validation for words like class or analysis, as they include ass and anal respectively, but fails the validation for content like sucker69.
Getting Help
If you're stuck getting something to work, or need to report a bug, please post an issue in the Github Issues for this project.
Contributing
If you're interesting in contributing code to this project, clone it by running:
git clone git@github.com:arandilopez/laravel-profane.git
Please read the CONTRIBUTING file.
Pull requests are welcome, but please make sure you provide unit tests to cover your changes. You can help to add and support more locales!
Thanks to @dorianneto for his contributions.
Supported Locales
- English ( provided by @arandilopez )
- Spanish ( provided by @arandilopez and @xDidier901)
- Italian ( provided by @aletundo )
- Brazilian Portuguese ( provided by @ianrodriguesbr and @LeonardoTeixeira)
- Traditional Chinese ( provided by @Nationalcat )
- Slovak ( provided by @kotass )
- Dutch (Netherlands) ( provided by @Cannonb4ll and @WouterVanmulken)
- Greek ( provided by @siokas )
- Malayalam ( provided by @abinodh )
- Russian ( provided by @alex2sat )
- Serbian ( provided by @Djuki )
- Filipino ( provided by @credocleo )
- Romanian ( provided by @rchioreanu )
- Indonesian ( provided by @rizasaputra )
License
This project is open-sourced software licensed under the MIT license.
arandilopez/laravel-profane 适用场景与选型建议
arandilopez/laravel-profane 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 227.83k 次下载、GitHub Stars 达 87, 最近一次更新时间为 2016 年 07 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 arandilopez/laravel-profane 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 arandilopez/laravel-profane 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 227.83k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 87
- 点击次数: 27
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-07-19