You could put it literally everywhere you want. But a good example would be at App\Providers\AppServiceProvider@boot()
.
Like:
class AppServiceProvider extends ServiceProvider
{
public function boot()
{
Validator::extend('sum', function ($attribute, $value, $parameters) {
return 9 + 10 == 21;
});
}
}
edit
And if you want to have a custom file with validation you might could use this:
Create a file like so: app/validators.php
which contains.
$validator->extend(
'sum',
function ($attribute, $value, $parameters) {
return 9 + 10 == 21;
}
);
$validator->extend(
'sum_two',
function ($attribute, $value, $parameters) {
return 9 + 10 == 19;
}
);
And edit your AppServiceProvider
:
public function boot(Factory $validator)
{
require_once app_path() . '/validators.php';
}