定制 accentinteractive/laravel-disallowlister 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

accentinteractive/laravel-disallowlister

Composer 安装命令:

composer require accentinteractive/laravel-disallowlister

包简介

Validate data against one or multiple disallowlists, using the built-in Laravel validator or by calling the facade directly. Supports wildcards.

README 文档

README

Effortlessly test strings against any array of disallowed strings. Supports fnmatch wildcards, like * and ?.

accentinteractive/disallowlister contains both a facade Disallowlister and custom validation rule disallowlister. You can set a default array of disallowed strings in config, or add and remove disallowed strings using Disallowlister:add() and Disallowlister:remove()

Latest Version on Packagist Build Status Quality Score Total Downloads

This Laravel-specific package tests a string against a disallowlist. It is a Laravel implementation of the platform agnostic accentinteractive/disallowlister.

If you are looking for a framework agnostic implementation, see https://github.com/accentinteractive/disallowlister

For a list of all options, see https://github.com/accentinteractive/disallowlister#readme.

The isDisallowed() method can use wildcards, like * and ?.

Under the hood, accentinteractive/disallowtester uses fnmatch(), so you can use the same wildcards as in that php function (the globbing wildcard patterns):

  • *sex* disallows sex, sexuality and bisexual.

  • cycle* disallows cycle and cycles, but not bicycle.

  • m[o,u]m disallows mom and mum, but allows mam.

  • m?n disallows man and men, but allows moon.

  • Installation

  • Examples

  • Config settings

Installation

You can install the package via composer:

composer require accentinteractive/laravel-disallowlister

Optionally you can publish the config file with:

php artisan vendor:publish --provider="Accentinteractive\LaravelDisallowlister\LaravelDisallowlisterServiceProvider" --tag="config"

Usage

Set the disallowlist in config

  1. Publish the config file, running php artisan vendor:publish --provider="Accentinteractive\LaravelDisallowlister\LaravelDisallowlisterServiceProvider" --tag="config"
  2. Set an default array of disalllowed strings in disallowlister.lists.default
  3. If you wish to use more than one disallowlist, you can add additional arrays of disalllowed strings to disallowlister.lists, like disallowlister.lists.my_list

Use the disallowlister validation rule

By default, the validator uses the default disallow list.

// Use the disallowlist validator with the default disallowlist. 
$rules = [
    'user_input' => 'disallowlister'
];

However, you can also pass to the validator which disallowlist to use.

// Use the disallowlist validator with the my_list disallowlist. 
$rules = [
    'user_input' => 'disallowlister:default',
    'user_emails' => 'disallowlister:my_email_list'
];

Case sensitivity

By default, matching is not case sensitive. You can set case sensitivity in confg

config(['disallowlister.is_case_sensitive' => true]);

Whole word checking

By default the entire string is checked. You can set to check word for word in config.

config(['disallowlister.match_word_for_word' => true]);

Use the class directly

use Accentinteractive\LaravelDisallowlister\Facades\Disallowlister;

// Call the facade directly, using the default disallowlist
DisallowLister::isDisallowed('Earn $4,000 A DAY working from HOME!!!');

// Call the facade directly, using a specific disallowlist
DisallowLister::setDisallowList(config('disallowlister.lists.mylist'))
              ->isDisallowed('Earn $4,000 A DAY working from HOME!!!');

// Add and remove items on the facade
DisallowLister::add('foo')
              ->add(['*bar*', 'b?t'])
              ->remove('b?t')
              ->isDisallowed('Earn $4,000 A DAY working from HOME!!!');

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 joost@accentinteractive.nl instead of using the issue tracker.

Credits

License

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-08-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固