In Controller i have:
$email = $this->request->getPost('email');
$obj = new Users();
$valid = $obj->validation($email);
if(!$valid)
{
$this->flashSession->error("invalid email!");
}
else
{
$this->flashSession->success("good email!");
}
In Model:
public function validation($email) { $this->validate( new Email( array( 'field' => 'email', 'required' => true, ) ) );
if ($this->validationHasFailed() == true) {
return false;
}
}
Validation always returns error message. Please advise, what i am lacking!