Laravel自定义类验证器:TranslatorInterface不可实例化

I have a problem with a custom class validator.

Here is my CustomValidator.php

<?php
use Illuminate\Validation\Validator;


class CustomValidator extends Validator {


    public function validateEmailExistence($attribute, $value, $parameters)
    {
        //check email existence
    }

}

Here in validators.php call the class

Validator::extend('check_email', 'CustomValidator@validateEmailExistence');

In bindings.php resolve the validator

Validator::resolver(function($translator, $data, $rules, $messages)
{
    return new CustomValidator($translator, $data, $rules, $messages);
});

When I run I get this error:

  Target [Symfony\Component\Translation\TranslatorInterface] is not instantiable.

If I extend validator through anonymous function it works fine. I know this is problem with interface binding, but I don't know which implementation should I use.

Your code seems to be ok for me, but try creating a service provider and register it in the app config file.

class ValidationServiceProvider extends ServiceProvider
{
    public function register()
    {

    }

    public function boot()
    {
        $this->app->validator->resolver(function($translator, $data, $rules, $messages) {
            return new CustomValidator($translator, $data, $rules, $messages);
        });
    }
}

Note: do a composer dumpauto after creating the service provider.

Let me know if you are still getting the error.