satomif/extra-aura-filter-module

Aura filter 2.x additional custom rule module

2.0.2 2017-12-08 00:05 UTC

This package is not auto-updated.

Last update: 2024-04-14 01:36:08 UTC


README

Build Status

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;
}