diff --git a/src/Validator/Rule/PregMatch.php b/src/Validator/Rule/PregMatch.php new file mode 100644 index 0000000..3d400bb --- /dev/null +++ b/src/Validator/Rule/PregMatch.php @@ -0,0 +1,21 @@ +pattern,$container->get($this->field)); + } +} diff --git a/src/Validator/Validator.php b/src/Validator/Validator.php index c8303ad..1d625e0 100644 --- a/src/Validator/Validator.php +++ b/src/Validator/Validator.php @@ -27,7 +27,8 @@ class Validator 'filename' => 'ctiso\\Validator\\Rule\\FileName', 'count' => 'ctiso\\Validator\\Rule\\Count', 'isfile' => 'ctiso\\Validator\\Rule\\IsFile', - 'code' => 'ctiso\\Validator\\Rule\\Code' + 'code' => 'ctiso\\Validator\\Rule\\Code', + 'reg' => 'ctiso\\Validator\\Rule\\PregMatch', ); function __construct($rules = array()) { @@ -77,7 +78,7 @@ class Validator } } - public function addRule($rule/*: any*/) { + public function addRule($rule/*:z any*/) { if (is_array($rule)) { $this->chain = array_merge($this->chain, $rule); } else { @@ -85,7 +86,7 @@ class Validator } } - public function skip($rule/*: AbstractRule*/, $container/*: Collection*/) // -> Rule_Abstract + public function skip($rule/*z: AbstractRule*/, $container/*: Collection*/) // -> Rule_Abstract { if ($rule->skipEmpty()) { $data = $container->get($rule->field);