Support the ongoing development of →
posted 7 years ago
Last updated 2 years ago.

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,

  1. where to put my rule
  2. which of the many validators to use (\Dotenv\Validator::, \Illuminate\Contracts\Validation\Validator::, \Illuminate\Validation\Validator:: or \Illuminate\Support\Facades\Validator::
  3. how to call my validation

Please help :-)



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)


Last updated 7 years ago.

Can anyone help me out of this ?



Sign in to participate in this thread!


Your banner here too?

bforpc bforpc Joined 14 Dec 2016


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 - All rights reserved.