<?php

// app/Http/Requests/StoreSeccion1BasicosRequest.php
namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

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

    public function rules(): array {
        return [
            // Para resolver form_id:
            'nit'       => ['required','string','max:20'],
            'municipio' => ['required','string','max:10'],
            'anio'      => ['nullable','integer','between:2000,2100'],
            'periodo'   => ['nullable','integer','between:1,12'],
            'creado_por'=> ['nullable','string','max:100'],

            // Los editables dentro de "basicos[...]"
            'basicos.periodo_evaluado'  => ['required','string','in:I,I-II,I-II-III'],
            'basicos.nivel_complejidad' => ['required','string','in:BAJA,MEDIA,ALTA'],
            'basicos.nivel_atencion'    => ['required','string','in:PRIMARIA,COMPLEMENTARIA'],

            'basicos.poblacion_inicial' => ['required','integer','min:0'],
            'basicos.valor_per_capita'  => ['required','numeric','min:0'],
            'basicos.valor_total_mes'   => ['required','numeric','min:0'],
            'basicos.duracion_contrato' => ['required','integer','min:0'],

            'basicos.numero_informe'     => ['required','string','max:50'],
            'basicos.novedad_contractual'=> ['nullable','string','max:200'],
            'basicos.anexos_disponibles' => ['nullable','string'],
        ];
    }

    public function messages(): array {
        return [
            'basicos.periodo_evaluado.in' => 'Periodo debe ser I, I-II o I-II-III.',
        ];
    }
}
