I got a problem with validating models in Kohana ORM, it should throw an ORM_Validation_Exception, however, it does not. I am trying to validate an emailaddress.
Model_Emailaddress
public function rules()
{
return array(
'emailaddress' => array(
array(
'Valid::email'
),
),
);
}
Controller_Test
public function action_valid()
{
$email = ORM::factory('emailaddress');
$email->emailaddress = 'test';
try
{
$email->create();
}
catch(ORM_Validation_Exception $e)
{
echo Debug::dump($e->errors());
}
}
This example should dump an array with errors to the screen but instead it just saves the emailaddress without further notices.
When I change 'Valid::email' to 'not_empty', it does throw an exception. After some debugging I discovered that Valid::email returns false, as it should.
EDIT: As some people stated, changing 'Valid::email' to 'email' does not help. Also, when I place an exit inside the email method, the script execution will be stopped.