andersao / l5-repository

Laravel 5 - Repositories to abstract the database layer
http://andersao.github.io/l5-repository
MIT License
4.18k stars 876 forks source link

SSoT for validation rules #476

Open OzairP opened 6 years ago

OzairP commented 6 years ago

When I generate a new entity, it creates the validator in app/Validators which host the validation rules for creating and updating a model. However, with the controller, it generates a Laravel Request class in app/Http/Requests which hosts a set of validation rules.

Is there any way to have these validation rules follow the Single Source of Truth principal?

rugleb commented 6 years ago

For example in your Request class in app/Http/Requests namespace:

    public function rules(PostValidator $validator)
    {
        return $validator->getRules(ValidatorInterface::RULE_CREATE);
    }