<?php

namespace apexl\Io\modules\formbuilder\Components\FormKitField;

use apexl\Io\modules\validation\ValidationRules\DateAfter;
use apexl\Io\modules\validation\ValidationRules\DateBefore;

readonly class DateFormKitField extends FormKitField
{
    protected final const string TYPE = 'date';

    public function init(): void
    {
        $this->setMinDate(date('Y/m/d'));
        $this->setMaxDate(date('Y/m/d', (strtotime('+ 3 years'))));
    }

    public function setMinDate(string $min): static
    {
        return $this->addValidation(new DateAfter($min));
    }

    public function setMaxDate(string $max): static
    {
        return $this->addValidation(new DateBefore($max));
    }
}
