We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Uniqueness validation multiple fields - Phalcon 2.1

How to validalidate multiple fields in unique validator?

I read that in the old version it was:

    $this->validate(new Uniqueness(array(
        'field' => array('email', 'name')
    )));

But now Model validators are deprecated, i try the following but it doesn't work.

        $validator->add('field_unique_per_user_id',
            new Uniqueness([
                'model' => $this,
                "message" => 'You already have this field.',
                "fields"   => ["user_id", "field_unique_per_user_id"],
            ])
        );

:C