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 :)
change recpatcha|required
to captcha|required
assuming you're using https://github.com/anhskohbo/no-captcha
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.