satomif / extra-aura-filter-module
Aura filter 2.x additional custom rule module
Installs: 930
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 2
Open Issues: 0
Type:project
Requires
- php: >=5.6.0
- aura/filter: ~2.3
- ray/di: ^2.5
- ray/validate-module: ~0.1
Requires (Dev)
- phpmd/phpmd: ~2.3
- phpunit/phpunit: ~5.7
- squizlabs/php_codesniffer: ~2.5
This package is not auto-updated.
Last update: 2025-03-02 06:15:09 UTC
README
ExtraAuraFilterModule
https://github.com/auraphp/Aura.Filter/blob/2.x/docs/custom.md
こちらのカスタムルールを追加するためのModuleです。
module install
$config = require dirname(dirname(__DIR__)) . '/var/conf/validate.php';
$this->install(new ExtraAuraFilterModule($config));
config(validate.php)
$config = [
'mbstrlen-max' => \Satomif\ExtraAuraFilterModule\Filter\MbStrlenMax::class
];
return $config;
how to validate
use ValidationInject;
$mbString = 'こんにちは!世界2!';
$this->filter->validate('var_name')->is('mbstrlen-max', 9);
$data = ['var_name' => $mbString];
$fail = $this->filter->apply($data);
if (! $fail) {
$msgs = (string) $this->errorString;
}