<?php

namespace App\Http\Requests;

use App\Support\Backoffice\Sanitizer\Traits\SanitizesInput;
use Illuminate\Foundation\Http\FormRequest;

class AccountAddressUpdateRequest extends FormRequest
{
    use SanitizesInput;

    public function rules()
    {
        return [
            'name' => 'required|max:255',
            'address' => 'required|max:255',
            'floor' => 'nullable|max:255',
            'postalCode' => 'required|max:15',
            'location' => 'required|max:100',
            'countryId' => 'required|exists:countries,id',
            'phonePrefix' => 'nullable|string|max:10',
            'phone' => 'nullable|string|max:20',
            'taxId' => 'nullable|string|max:20',
        ];
    }

    /**
     * Filters to be applied to the input.
     *
     * @return array
     */
    public function filters(): array
    {
        return [
            'name' => "trim|strip_tags|xss_clean",
            'address' => "trim|strip_tags|xss_clean",
            'floor' => "trim|strip_tags|xss_clean",
            'postalCode' => "trim|strip_tags|xss_clean",
            'location' => "trim|strip_tags|xss_clean",
            'phonePrefix' => "trim|strip_tags|xss_clean",
            'phone' => "trim|strip_tags|xss_clean",
            'taxId' => "trim|strip_tags|xss_clean",
        ];
    }
}
