<?php

namespace App\Http\Requests\User;

use Illuminate\Foundation\Http\FormRequest;

class RegistrationRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
     */
    public function rules(): array
    {
        return [
            'name' => 'required',
           'lastname' => 'required',
           'email' => 'required|unique:users',
           'address' => 'required',
           'city' => 'required',
           'state' => 'required',
           'post_code' => 'required',
           'country' => 'required',
           'company' => 'required',
           'phone' => 'required|numeric|regex:/^[0-9]+$/',
           'password' => 'required|min:8|regex:#.*^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*\W).*$#',
           'confirm' => 'required|same:password', 
           'g-recaptcha-response' => 'required|recaptchav3:verify_registration,0.5'
        ];
    }

    public function messages()
    {
        return [
            'password.regex' => 'Passwords must contain at least eight characters, including uppercase, lowercase letters, numbers and symbol'
        ];
    }
}
