particleflux / yii2-blocklist-validator
Validate attributes against a blocklist
Package info
github.com/particleflux/yii2-blocklist-validator
pkg:composer/particleflux/yii2-blocklist-validator
1.0.0
2026-07-27 14:18 UTC
Requires
- php: ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0
- yiisoft/yii2: ^2.0
Requires (Dev)
- infection/infection: ^0.27.6
- phpcompatibility/php-compatibility: ^10.0.0@dev
- phpmd/phpmd: ^2.14
- phpro/grumphp: ^2.1
- phpstan/phpstan: ^1.2
- phpunit/phpunit: ^10.4
- squizlabs/php_codesniffer: ^4.0
This package is auto-updated.
Last update: 2026-07-27 14:18:44 UTC
README
A Yii2 validator to block certain values
Installation
composer require particleflux/yii2-blocklist-validator
Usage
BlockListFileValidator
Block attribute values contained in a file.
public function rules(): array { return [ ['username', BlockListFileValidator::class, 'file' => '@app/config/bad-usernames.txt'], ]; }
Some of the behavior can be fine-tuned:
public function rules(): array { return [ [ 'username', BlockListFileValidator::class, 'file' => '@app/config/bad-usernames.txt' // the path to the blocklist file, can contain aliases 'strict' => true, // whether to do strict comparison (default: false) 'useCache' => true, // use cache component defined in 'cache' (default: true) 'cacheTtl' => 60, // cache TTL (default: null, meaning the component default) 'cache' => 'customCache', // cache component to use (default 'cache') ], ]; }