<?php

namespace App\Http\Requests\Frontend;

use Closure;
use Illuminate\Foundation\Http\FormRequest;

class DeleteUser extends FormRequest
{
    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules(): array
    {
        return [
            'email' => 'email|required',
            'token' => 'alpha_num|required',
            'g-recaptcha-response' => [
                'required',
                function(string $attribute, $value, Closure $fail)
                {
                    $recaptcha = checkRecaptcha($value, 'delete_user_request');
                    if (!$recaptcha) {
                        $fail("Google ReCaptcha check failed. Please try again");
                    }
                }
            ]
        ];
    }
}
