<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class AdmissionNumberGetStudentRequest extends FormRequest
{
    public function authorize()
    {
        return true;
    }

    public function rules()
    {
        return [
            'admission_number' => ['required', 'string', 'max:50', studentAdmissionNumberValidationRule()],
        ];
    }

    protected function prepareForValidation()
    {
        if ($this->has('admission_number')) {
            $this->merge([
                'admission_number' => normalizeAdmissionNumber($this->admission_number),
            ]);
        }
    }

    public function messages()
    {
        return [
            'admission_number.regex' => 'Enter a valid Admission Number, e.g. MMF-201-012-2026.',
        ];
    }
}
