Hi again, i has found them idea to write a custom validation rule. Fine. But now, after hours of searching, i'm totaly confused. I use laravel 5.3,
I had a try in AppServiceProvider, in the boot section like that: \Illuminate\Support\Facades\Validator::extend('path', function ($attribute, $value, $parameters, $validator) { return false; });
At this point: i am not sure,
Please help :-)
Jan
You can get all about how to create custom validator with laravel at How can you create Custom Validation recipe in Laravel 5.x.
Hi, thanks for your hint, but its not working (at me). I had create a first this 2 Classes:
namespace App\Validator;
use Illuminate\Validation\Validator;
class CustomValidator extends Validator {
public function ValidateFilepath($attribute, $value, $parameters){
return $value == "bla";
}
}
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use App\Validator\CustomValidator;
class ValidationServicePovider extends ServiceProvider {
public function boot(){
$this->app->validator->resolver(function ($translator, $data,$rules,$messages){
return new CustomValidator($translator, $data,$rules,$messages);
});
}
...
also i had register the ValidationServicePovider in /config/app.php
But now nothing happen, when i call it liek that:
$this->validate($request, ['path' => 'required:filepath']);
I had try "filepath" in some cases, no results (and no errors)
Jan
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community