particleflux / yii2-blocklist-validator
验证属性是否在黑名单中
0.1.0
2024-04-30 18:05 UTC
Requires
- php: ~8.1.0 || ~8.2.0 || ~8.3.0
- yiisoft/yii2: ^2.0
Requires (Dev)
- infection/infection: ^0.27.6
- phpcompatibility/php-compatibility: dev-develop
- phpmd/phpmd: ^2.14
- phpro/grumphp: ^2.1
- phpstan/phpstan: ^1.2
- phpunit/phpunit: ^10.4
- squizlabs/php_codesniffer: ^3.7
This package is auto-updated.
Last update: 2024-09-30 18:57:04 UTC
README
一个用于阻止特定值的 Yii2 验证器
安装
composer require particleflux/yii2-blocklist-validator
使用方法
BlockListFileValidator
阻止文件中包含的属性值。
public function rules(): array { return [ ['username', BlockListFileValidator::class, 'file' => '@app/config/bad-usernames.txt'], ]; }
一些行为可以进行微调
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') ], ]; }