I am trying to register new custom validation but get this error:
Method [validateAlphaSpace] does not exist. [Laravel 5]
Here is my code:
CustomValidator.php
<?php namespace App;
use Illuminate\Validation\Validator;
class CustomValidator extends Validator {
public function alpha_space($attribute, $value, $parameters)
{
return preg_match('/^[a-zA-Z0-9\s]+$/u', $value);
}
}
ValidatorServicePorvider.php
<?php namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Validator;
use App\CustomValidator;
class ValidatorServicePorvider extends ServiceProvider {
/**
* Bootstrap any necessary services.
*
* @return void
*/
public function boot()
{
Validator::resolver(function($translator, $data, $rules, $messages)
{
return new CustomValidator($translator, $data, $rules, $messages);
});
}
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
}
}
I also register provider inside app.php... Anyone can see what is problem?