I try to add new validation rule (Laravel 5.2) for google recaptcha and this rule not working. Can you explain me why? And how to fix it?
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Validator;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Validator::extend('recaptcha', function($attribute, $value, $parameters, $validator) {
return false;
});
}
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
}
-
class AuthController extends Controller
{
/**
* Get a validator for an incoming registration request.
*
* @param array $data
* @return \Illuminate\Contracts\Validation\Validator
*/
protected function validator(array $data)
{
return Validator::make($data, [
'email' => 'required|email|max:255|unique:users',
'password' => 'required|confirmed|min:6',
'g-recaptcha-response' => 'recaptcha|required',
]);
}
Require rule working fine, recaptcha not. I try to do dump-autoload - no results.
Thank you very much :)
return falsetoreturn $value == 'recaptcha'return $value == 'recaptcha'is worked for me, but this condition return false? why just false not working?