<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class UpdateFormEmail 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
     */
    public function rules()
    {
        return [
//            'email_deadline' => ['required'],
            'profile_id' => ['required'],
            'email_name' => ['required','regex:/(([a-zA-Z]+)\s+\1$|[a-zA-Z]+$)/u'],
            'email_surname' => ['required','regex:/(([a-zA-Z]+)\s+\1$|[a-zA-Z]+$)/u'],
            'email_personalemail'=>['required','email']
            
        ];
    }

    public function messages()
    {
        return [
            'profile_id.required' => 'Debe Seleccionar un Perfil relacionado a la tarea.',
            'email_name.required'=>'El campo Nombre/s es requerido.',
            'email_name.regex'=>'El formato del nombre es inválido',
            'email_surname.required'=>'El campo Apellido/s es requerido.',
            'email_surname.regex'=>'El formato del Apellido es inválido',
            'email_personalemail.required'=>'El campo Email Personal es requerido.',
            'email_personalemail.email'=>'El campo Email Personal debe ser un email válido. ',
//            'email_deadline.required' => 'El campo Deadline es requerido'
        ];
    }
}
