laravel-google-recaptcha-v3 icon indicating copy to clipboard operation
laravel-google-recaptcha-v3 copied to clipboard

Issue with Validation class (Request) and function rules()

Open ma3achou opened this issue 2 years ago • 0 comments

Hello friends,

My env : Laravel 8, PHP7.3, Vue.Js 2.0

I don't know what's wrong with that ... why he is waiting for a string ?

This my validation class

use Modules\Core\Http\Requests\Request;
use TimeHunter\LaravelGoogleReCaptchaV3\Validations\GoogleReCaptchaV3ValidationRule;

class RegisterRequest extends Request {

public function rules()
    {
        return [
            'first_name' => ['required'],
            'last_name' => ['required'],
            'email' => ['required', 'email', 'unique:users'],
            'phone' => ['required'],
            'password' => ['required', 'confirmed', 'min:6'],
            'g-recaptcha-response' => [new GoogleReCaptchaV3ValidationRule('register')],
            'privacy_policy' => ['accepted'],
        ];
    }
}

My blade file :

<div class="form-group p-t-5 d-flex  justify-content-between">
                        {!!  GoogleReCaptchaV3::renderField('grecaptcha','register') !!}
                        @error('g-recaptcha-response')
                        <span class="error-message">{{ $message }}</span>
                        @enderror
                    </div>

When I post I get this error :

TypeError
strpos(): Argument #1 ($haystack) must be of type string, TimeHunter\LaravelGoogleReCaptchaV3\Validations\GoogleReCaptchaV3ValidationRule given
http://192.168.1.169:8000/fr/register

With dd() I get the object :

TimeHunter\LaravelGoogleReCaptchaV3\Validations\GoogleReCaptchaV3ValidationRule {#2212 ▼
  #action: "register"
  #ip: null
  #message: null
}

Is the documentation is not full in the case we use validation class ?

Screenshot of Error 500 image

Thank you :)

ma3achou avatar Nov 06 '23 07:11 ma3achou