Say you have a custom rule like this:
<?php
class CheckFoo extends \Respect\Validation\Rules\AbstractRule
{
public function validate($input)
{
if ($input == 'foo')
return true;
else
return false;
}
}
class CheckFooException extends \Respect\Validation\Exceptions\ValidationException
{
public static $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} must be foo',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} must not be foo',
],
];
}
This works fine but is it possible to add additional rules inside this rule? To illustrate, is something like this possible:
class CheckFoo extends \Respect\Validation\Rules\AbstractRule
{
public function validate($input)
{
if (strlen($input) != 3)
return false;
if ($input == 'foo')
return true;
else
return false;
}
}
How can I define a custom error message inside CheckFooException
if (strlen($input) != 3)
is triggered?