PHPackages                             accentinteractive/disallowlister - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. accentinteractive/disallowlister

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

accentinteractive/disallowlister
================================

Test a string against a disallowlist. Useful for user forms and such.

v0.4.0(4y ago)0401MITPHPPHP ^7.3|^7.4|^8.0

Since Aug 16Pushed 4y ago1 watchersCompare

[ Source](https://github.com/accentinteractive/disallowlister)[ Packagist](https://packagist.org/packages/accentinteractive/disallowlister)[ Docs](https://github.com/accentinteractive/disallowlister)[ RSS](/packages/accentinteractive-disallowlister/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (2)Versions (6)Used By (1)

Disallowlister
==============

[](#disallowlister)

[![Latest Version on Packagist](https://camo.githubusercontent.com/122329a64a75fb1f23908e46ad0ad3f68dabbe579910d2f82cf672189eb0c8b6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616363656e74696e7465726163746976652f646973616c6c6f776c69737465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/accentinteractive/disallowlister)[![Build Status](https://camo.githubusercontent.com/b61e7ce390ced1cde45c94ed22977f8d90960e48946bbf23141c1b548115b62c/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f616363656e74696e7465726163746976652f646973616c6c6f776c69737465722f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/accentinteractive/disallowlister)[![Quality Score](https://camo.githubusercontent.com/11ec70b3004f3b047bf69d2429f44bf9df11442892644e52250f49113d0889cb/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f616363656e74696e7465726163746976652f646973616c6c6f776c69737465722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/accentinteractive/disallowlister)[![Total Downloads](https://camo.githubusercontent.com/ec24ec74c0123c01549eb76f698e20554e2cabfb1ceecc8d35c1c9a5a7123126/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616363656e74696e7465726163746976652f646973616c6c6f776c69737465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/accentinteractive/disallowlister)

This little package tests a string against a disallowlist.

If you are looking for a Laravel-specific implementation, see

The `isDisallowed()` method can use wildcards, like \*.

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**, **sex**uality and bi**sex**ual.
- `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](#installation)
- [Examples](#usage)
- [Config settings](#config-settings)

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require accentinteractive/disallowlister
```

Usage
-----

[](#usage)

### Setting the disallowlist

[](#setting-the-disallowlist)

You can pass the disallowlist in the constructor or via other methods.

```
// Pass the disallowlist in the constructor
$disallowLister = new DisallowLister(['foo']); // ['foo']

// Set the disallowlist in the setter method
$disallowLister->setDisallowList(['bar']); // ['bar']

// Add an item to the disallowlist
$disallowLister->add('baz'); // ['bar', 'baz']

// Add multiple items to the disallowlist
$disallowLister->add(['bat', 'fiz']); // ['bar', 'baz', 'bat', 'fiz']

// Remove an item from the disallowlist
$disallowLister->remove('fiz'); // ['bar', 'baz', 'bat']

// Remove multiple items from the disallowlist
$disallowLister->remove(['baz', 'bat']); // ['bar']
```

### Checking data against the disallowlist

[](#checking-data-against-the-disallowlist)

```
## Literal string
$disallowLister = new DisallowLister(['bar', 'foo']);

$disallowLister->isDisallowed('bar'); // Returns true
$disallowLister->isDisallowed('bars'); // Returns false

## Wildcards
// Under the hood, `accentinteractive/disallowtester`
// uses `fnmatch()`, so you can use the same
// wildcards as in that php function (the
// globbing wildcard patterns):
(new DisallowLister(['b?r']))->isDisallowed('bar'); // Returns true
(new DisallowLister(['m[o,u]m']))->isDisallowed('mom'); // Returns true
(new DisallowLister(['*bar*']))->isDisallowed('I like crowbars'); // Returns true
```

### Case sensitivity

[](#case-sensitivity)

```
// By default, matching is not case sensitive
(new DisallowLister(['bar']))->isDisallowed('BAR'); // Returns true

// To set case sensitive matching
(new DisallowLister(['bar']))->caseSensitive(true)->isDisallowed('BAR'); // Returns false
```

### Whole word checking

[](#whole-word-checking)

```
// By default the entire string is checked.
(new DisallowLister())->setDisallowList(['bar'])->isDisallowed('My favorite bar'); // Returns false

// Check word for word.
(new DisallowLister())->setDisallowList(['bar'])->setWordForWord(true)->isDisallowed('My favorite bar'); // Returns true
```

### Testing

[](#testing)

```
composer test
```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Joost van Veen](https://github.com/accentinteractive)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 83.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~2 days

Total

5

Last Release

1716d ago

PHP version history (2 changes)v0.1.0PHP ^7.3|^8.0

v0.3.1PHP ^7.3|^7.4|^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/356020?v=4)[Accent Interactive](/maintainers/accentinteractive)[@accentinteractive](https://github.com/accentinteractive)

---

Top Contributors

[![joostvanveen](https://avatars.githubusercontent.com/u/540294?v=4)](https://github.com/joostvanveen "joostvanveen (5 commits)")[![accentinteractive](https://avatars.githubusercontent.com/u/356020?v=4)](https://github.com/accentinteractive "accentinteractive (1 commits)")

---

Tags

accentinteractivedisallowlister

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/accentinteractive-disallowlister/health.svg)

```
[![Health](https://phpackages.com/badges/accentinteractive-disallowlister/health.svg)](https://phpackages.com/packages/accentinteractive-disallowlister)
```

###  Alternatives

[webmozart/assert

Assertions to validate method input/output with nice error messages.

7.6k894.0M1.2k](/packages/webmozart-assert)[bensampo/laravel-enum

Simple, extensible and powerful enumeration implementation for Laravel.

2.0k15.9M104](/packages/bensampo-laravel-enum)[swaggest/json-schema

High definition PHP structures with JSON-schema based validation

48612.5M73](/packages/swaggest-json-schema)[stevebauman/purify

An HTML Purifier / Sanitizer for Laravel

5325.6M19](/packages/stevebauman-purify)[ashallendesign/laravel-config-validator

A package for validating your Laravel app's config.

217905.3k5](/packages/ashallendesign-laravel-config-validator)[crazybooot/base64-validation

Laravel validators for base64 encoded files

1341.9M8](/packages/crazybooot-base64-validation)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
