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

Validation slug for all models

Validation slug for all models:

public function validation()
{  
    $validator = new Validation();

    $validator->add('slug', new UniquenessValidator(
        [
            "model"   => new Article(),
            "message" => "Slug is already exists",
        ]
    ));
    return $this->validate($validator);
}

Do you have a problem? or just is an example?



339

Good morning. I have a problem. I want to inspect slugs validator for all models. In the example above, only one model is being inspected which Article model.

There is no specific validator that does what you need, but you can create your own to validate the slug in the models that implement this behavior

example of custom validator

Good luck



339

Thank you