I'm adding custom validation rules to my Laravel 5.1 application, and I currently have it set up like this in AppServiceProvider
:
Validator::extend('word_count', 'App\CustomValidators@wordCount');
Validator::extend('required_if_not', 'App\CustomValidators@requiredIfNot');
Validator::extend('date_in_year', 'App\CustomValidators@dateInYear');
This works, but I'm wondering if there is a better method I should be using with 5.1 rather than calling the Validator facade.
For example, calling to a view no longer requires me to call View::request('template', $viewData)
or View::make('template', $viewData)
, but instead I can call view('template', $viewData)
, which cuts down on the number of namespaces I need to 'use' for my class. I can do something similar with redirects as well.
What is the best/cleanest method in Laravel 5.1 for adding custom validation rules?