Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Documentation Validators

Hello everyone,

first of all, I really like phalcon so far, I think the thing which mostly makes it less popular then for example Laravel is the Documentation, which makes it very hard for beginners to get into it.

One example, I wanted to implement a simple Uniqueness validator into one of my models, and I took exactly the example from the documentation (due to it fits my model) but I am getting an error:

Uncaught TypeError: Argument 1 passed to Phalcon\Mvc\Model::validate() must implement interface Phalcon\ValidationInterface, instance of >Phalcon\Mvc\Model\Validator\Uniqueness given in

That really should not happen.

The whole validation combined with the inaccurate documentation is very confusing. I have read that one Validator class applies to model and the other one to for example forms. But maybe thats outdated to? who knows?

Just to get some feedback on another topic out: the forum

The editor starts to lag already after a short passage like that one. When using it on my 9:16 Full HD Display (a turned 16:9, should be rather common among developers, there is simply no submit button to start a discussion. Furthermore the layout in editior is not even close to what it will look like later.

Best Regards, Ludwig

edited Dec '16

So after some further research I am one step further. It seems like Phalcon/Mvc/Model/Validator is outdated since 2.1, but why is it in the 3.0.1 documentation then? Still unclear.

I wont get a fatal error anymore, but there is still no message added, my validation function in the model now looks like this:

public function validation()
    $validator = new \Phalcon\Validation();
        new \Phalcon\Validation\Validator\Uniqueness([
            'field' => 'email',
            'message' => 'Error, this email is not Unique',
    return $this->validate($validator);

Best Regards, Ludwig

edit: nevermind, I wasnt printing out the model message, so it works now. But the point I wanted to make about the documentation and the forum still apply.

Because it still used for Collection.

edited Dec '16

Because it still used for Collection.

That may be true, but the documentation shows an explizit example in a model, which is just inaccurate and missleading. Sadly the link got smashed due to underscores in it, thats why I posted it below again:

edit: wont work even when using the link feature in the forum, which refers back to the other topic. So I cant even post a link to the documentation as soon as underscores are in it I guess. If you still want to get there you have to replace every %5 with an underscore.

edited Dec '16

Well it wasnt updated because they are deprecated. From 3.1.x they will have @deprecated annotation. From 3.2.x there will be E_DEPRECATED trigger about using of those classes. Just for models use Phalcon\Validation alone.