auraphp/Aura.Input — pull request #40 by kenjis (2014-08-05 08:34:52+00:00)
Title: Add support for adding messages in closure rules

This PR makes it possible to add messages in a closure.

~~~php
$filter->setRule(
'foo',
'Enter Foo correctly',
function ($value) use ($filter) {
$pass = true;
if ($value == '') {
$filter->addMessages('foo', 'Foo is required');
$pass = false;
}

if (! ctype_alpha($value)) {
$filter->addMessages('foo', 'Foo should be alpha only');
$pass = false;
}
return $pass;
}
);
~~~