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.

I'm confused about the new Validator in 2.1

From 2.1.x blog post:

Should the line return $this->validate(); be instead return $validator? I'm not seeing how anything is being assigned permanently here.


namespace Invo\Models;

use Phalcon\Mvc\Model;
use Phalcon\Validation;
use Phalcon\Validation\Validator\Email as EmailValidator;
use Phalcon\Validation\Validator\Uniqueness as UniquenessValidator;

class Users extends Model
    public function validation()
        $validator = new Validation();

            new EmailValidator()

            new UniquenessValidator(
                    'message' => 'Sorry, That username is already taken',

        return $this->validate();


You have to pass the validator:

return $this->validate($validator);


Ok cool. So just small bug in the blog post only?

Will fix the article, thanks