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

Uniqness concatenate two cloumns or (mixed index)

Hello

how to use uniqness Validator for mixed columns,

like

concatenate name(attr) and family(attr) together and etc...

    $validator = new Validation();
    $validator->add(
        'name-family-...',
        new Uniqueness([
            "message" => "Error"
        ])
    );
    return $this->validate($validator);


39.2k
Accepted
answer
edited Nov '16

Since Phalcon v3.0.0 you can use combination of fields as follows:

$validator = new Validation();

$validator->add(
    ['name', 'family'],
    new Uniqueness(
        'message' => 'Error',
    )
);

return $this->validate($validator);
edited Nov '16

Since Phalcon v3.0.0 you can use combination of fields as follows: .....

Thank You , Phalcon is the best.