{"action":"created","issue":{"url":"https://api.github.com/repos/phalcon/cphalcon/issues/11159","labels_url":"https://api.github.com/repos/phalcon/cphalcon/issues/11159/labels{/name}","comments_url":"https://api.github.com/repos/phalcon/cphalcon/issues/11159/comments","events_url":"https://api.github.com/repos/phalcon/cphalcon/issues/11159/events","html_url":"https://github.com/phalcon/cphalcon/issues/11159","id":119048647,"number":11159,"title":"Fatal error on validate Uniqueness validator in model","user":{"login":"dilistinc","id":6850508,"avatar_url":"https://avatars.githubusercontent.com/u/6850508?v=3","gravatar_id":"","url":"https://api.github.com/users/dilistinc","html_url":"https://github.com/dilistinc","followers_url":"https://api.github.com/users/dilistinc/followers","following_url":"https://api.github.com/users/dilistinc/following{/other_user}","gists_url":"https://api.github.com/users/dilistinc/gists{/gist_id}","starred_url":"https://api.github.com/users/dilistinc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dilistinc/subscriptions","organizations_url":"https://api.github.com/users/dilistinc/orgs","repos_url":"https://api.github.com/users/dilistinc/repos","events_url":"https://api.github.com/users/dilistinc/events{/privacy}","received_events_url":"https://api.github.com/users/dilistinc/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-11-26T13:47:07Z","updated_at":"2015-11-26T14:08:45Z","closed_at":null,"body":"Test script\r\n```php\r\n<?php\r\n\r\nuse Phalcon\\Validation;\r\nuse Phalcon\\Validation\\Validator;\r\nuse Phalcon\\Db\\Adapter\\Pdo\\Mysql;\r\n\r\nclass Robot extends Phalcon\\Mvc\\Model\r\n{\r\n    protected $email;\r\n\r\n    protected function validation()\r\n    {\r\n        $validation = new Validation();\r\n\r\n        $validation->add(\r\n            'email',\r\n            new Validator\\Uniqueness(['message' => 'message'])\r\n        );\r\n\r\n        return $this->validate($validation);\r\n    }\r\n}\r\n\r\ntry {\r\n    $di = new \\Phalcon\\Di\\FactoryDefault();\r\n    $db = new Mysql([\r\n        'dbname' => 'test',\r\n        'host' => '127.0.0.1',\r\n        'port' => 3306,\r\n        'username' => 'root',\r\n        'password' => ''\r\n    ]);\r\n    $di->set('db', $db);\r\n\r\n    $robot = new Robot(['email' => 'mailmail']);\r\n    $status = $robot->create();\r\n\r\n    var_dump($robot->getMessages());\r\n\r\n} catch (\\Phalcon\\Exception $e) {\r\n    echo $e->getMessage();\r\n}\r\n```\r\n\r\nResult:\r\nFatal error: Uncaught exception 'RuntimeException' with message 'Trying to call method getdi on a non-object'\r\n"},"comment":{"url":"https://api.github.com/repos/phalcon/cphalcon/issues/comments/159924059","html_url":"https://github.com/phalcon/cphalcon/issues/11159#issuecomment-159924059","issue_url":"https://api.github.com/repos/phalcon/cphalcon/issues/11159","id":159924059,"user":{"login":"KorsaR-ZN","id":579410,"avatar_url":"https://avatars.githubusercontent.com/u/579410?v=3","gravatar_id":"","url":"https://api.github.com/users/KorsaR-ZN","html_url":"https://github.com/KorsaR-ZN","followers_url":"https://api.github.com/users/KorsaR-ZN/followers","following_url":"https://api.github.com/users/KorsaR-ZN/following{/other_user}","gists_url":"https://api.github.com/users/KorsaR-ZN/gists{/gist_id}","starred_url":"https://api.github.com/users/KorsaR-ZN/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KorsaR-ZN/subscriptions","organizations_url":"https://api.github.com/users/KorsaR-ZN/orgs","repos_url":"https://api.github.com/users/KorsaR-ZN/repos","events_url":"https://api.github.com/users/KorsaR-ZN/events{/privacy}","received_events_url":"https://api.github.com/users/KorsaR-ZN/received_events","type":"User","site_admin":false},"created_at":"2015-11-26T14:08:45Z","updated_at":"2015-11-26T14:08:45Z","body":"You have to use it like this:\r\n```php\r\n$validation->add('email', new Validator\\Uniqueness([\r\n   'message' => 'message',\r\n   'model' => $this\r\n]));\r\n```"}}