我尝试为google recaptcha添加新的验证规则(Laravel 5.2),此规则无效。你能解释一下为什么吗?以及如何解决它?
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',
]);
}
要求规则正常工作,不要重新计算。 我尝试做dump-autoload - 没有结果。
非常感谢:)
答案 0 :(得分:1)
将recpatcha|required
更改为captcha|required