<?php

namespace App\Http\Requests\Api;

use Illuminate\Foundation\Http\FormRequest;

class StoreLeadRequest extends FormRequest
{
    public function authorize(): bool
    {
        return true;
    }

    public function rules(): array
    {
        return [
            'reference' => ['nullable', 'string', 'max:255'],

            'title' => ['nullable', 'string', 'max:50', 'regex:/^[a-zA-Z\'\-\s]+$/'],
            'first_name' => ['nullable', 'string', 'min:2', 'max:50', 'regex:/^[a-zA-Z\'\-\s]+$/'],
            'middle_name' => ['nullable', 'string', 'min:2', 'max:50', 'regex:/^[a-zA-Z\'\-\s]+$/'],
            'last_name' => ['nullable', 'string', 'min:2', 'max:50', 'regex:/^[a-zA-Z\'\-\s]+$/'],
            'full_name' => ['nullable', 'string', 'min:2', 'max:100', 'regex:/^[a-zA-Z\'\-\s]+$/'],
            'preferred_name' => ['nullable', 'string', 'min:2', 'max:50', 'regex:/^[a-zA-Z\'\-\s]+$/'],

            'dob' => ['nullable', 'date', 'before:-18 years', 'after:-120 years'],
            'email' => ['required', 'email:rfc,dns', 'unique:clients,email_address'],
            'phone_number' => ['required', 'regex:/^(\+44\s?7\d{3}|\(?07\d{3}\)?)\s?\d{3}\s?\d{3}$/', 'unique:clients,phone_number'],
            
            'what_type_of_care_were_you_in' => ['nullable', 'string', 'max:1000'],
            'anything_you_wish_to_tell_us' => ['nullable', 'string', 'max:5000'],
        ];
    }
}