<?php

namespace App\Http\Requests\Tenancy\Auth;

use App\Models\Tenancy\User;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
use Illuminate\Validation\Rules\Password;

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

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array<string, mixed>
     */
    public function rules()
    {
        return [
            'email' => ['required', 'string', 'email', 'max:255', 'unique:'.User::class],
            'phone' => [ 'sometimes','nullable','string', 'max:255', 'unique:'.User::class],
            'name' => ['required', 'string', 'max:255'],
            'lastname' => ['required', 'string', 'max:255'],
            'password' => ['required', 'confirmed', Password::defaults()],
            'gender' => ['required', Rule::in(['male', 'female'])],
            'birth_date' => ['required', 'date_format:Y-m-d'],
            'is_alien' => ['required', 'boolean'],
        ];
    }
}
