承接 arandilopez/laravel-profane 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

arandilopez/laravel-profane

最新稳定版本:v0.5.0

Composer 安装命令:

composer require arandilopez/laravel-profane

包简介

Laravel Profanity Valitador

README 文档

README

Latest Stable Version Total Downloads License Daily Downloads composer.lock StyleCI

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

License

This project is open-sourced software licensed under the MIT license.

统计信息

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

GitHub 信息

  • Stars: 87
  • Watchers: 3
  • Forks: 35
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 未知

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固