<?php

namespace App\Http\Requests\Discounts;

use App\Http\Requests\ApiFormRequest;

class UpdateDiscountVoucherRequest extends ApiFormRequest
{
    public function authorize(): bool
    {
        return true;
    }

    public function rules(): array
    {
        return [
            'code' => ['sometimes', 'string', 'max:50'],
            'discount_type' => ['sometimes', 'in:percent,fixed'],
            'discount_value' => ['sometimes', 'numeric', 'min:0'],
            'max_uses' => ['nullable', 'integer', 'min:0'],
            'valid_from' => ['nullable', 'date_format:Y-m-d'],
            'valid_until' => ['nullable', 'date_format:Y-m-d', 'after_or_equal:valid_from'],
            'is_active' => ['nullable', 'boolean'],
            'description' => ['nullable', 'string'],
            'school_year' => ['nullable', 'string'],
            'semester' => ['nullable', 'string'],
        ];
    }
}
