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?



149

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



149

Thank you