<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

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

    public function rules(): array
    {
        return [
            'ear_tag' => ['required_without:cattle_id', 'string', 'max:64'],
            'cattle_id' => ['required_without:ear_tag', 'integer', 'exists:cattle,id'],
            'weight_kg' => ['required', 'numeric', 'min:0.01', 'max:9999'],
            'weighed_at' => ['required', 'date'],
            'notes' => ['nullable', 'string', 'max:500'],
        ];
    }
}
