Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

SteveBelanger's avatar

BadMethodCallException in Validator.php line 2678

I am extending form a previous thread I started here I am using Laravel 5.1

I get : BadMethodCallException in Validator.php line 2678:Method [validateScheduleConflicts] does not exist. when this validation triggers.

my custom validator :


namespace app\Validators;
use Illuminate\Support\Facades\DB;
use Illuminate\Validation\Validator;

class scheduleConflictValidator extends Validator
{
    function validateScheduleConflicts($attribute,$value, $parameters)
    {
        return scheduleConflictValidator::scheduleConflicts($attribute,$value, $parameters);
    }

    static function scheduleConflicts($attribute,$value, $parameters)
    {
        return true;
    }
}

my service provider

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
//use Illuminate\Support\Facades\Validator;
use Validator;
use app\Validators\scheduleConflictValidator;

class CustomValidationServProv extends ServiceProvider
{
    /**
     * Bootstrap the application services.
     *
     * @return void
     */
    public function boot()
    {   
         Validator::extend('scheduleConflict', 'app\Validators\scheduleConflictValidator@validateScheduleConflicts');
    }

    
    public function register()
    {
        //
    }
}


my request :

namespace App\Http\Requests;

use App\Http\Requests\Request;

class askSubstitutionRequest extends Request
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
        //todo review this authorize...
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'datetimeDebut' => 'required|date_format:d#m#Y H#i|after:now|scheduleConflicts',
            'datetimeFin'  => 'required|date_format:d#m#Y H#i|after:datetimeDebut'
            //
        ];
    }
}


I feel like I am almost there, with a typo, one missing line or something...

0 likes
3 replies
godigitalweb's avatar
Level 7

I haven't tested this but I suspect your error is due to formatting. Give this simplified version a test and if it works you can go from there. Watch were you're using camel case vs snake case, it's possible that when the validator class is converting the class@method string it is looking for one format vs the other and that can be relevant elsewhere like within the rules. Hope this helps.

app/Validators/ScheduleConflictsValidator.php

namespace App\Validators;

class ScheduleConflictsValidator
{
    function validateScheduleConflicts($attribute,$value, $parameters)
    {
        return false; // so you can see it works
    }
}

Start by putting this in your AppServiceProvider.php and then put elsewhere after you get everything working...

app/Providers/AppServiceProvider.php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Validator;

class AppServiceProvider extends ServiceProvider
{
    public function boot()
    {   
         Validator::extend('schedule_conflicts', 'App\Validators\ScheduleConflictsValidator@validateScheduleConflicts');
    }
}

Your rule...

    public function rules()
    {
        return [
            'datetime_debut' => 'required|schedule_conflicts',
        ];
    }

Please or to participate in this conversation.