<?php

namespace ModulesGarden\Servers\ProxmoxCloudVps\App\UI\VmCreate\Validators;

use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Widget\Forms\Validators\BaseValidator;

class IsoImageValidator extends BaseValidator
{

    protected function validate($data, $additionalData = null)
    {
        if($additionalData->get('formData')['osTemplate'] && $additionalData->get('formData')['osTemplate']!='installationFromIso' ){
            return true;
        }

        if (is_array($data) && count($data) > 0)
        {
            return true;
        }

        if ((is_string($data) && strlen(trim($data)) > 0) || is_numeric($data))
        {
            return true;
        }

        $this->addValidationError('thisFieldCannotBeEmpty');

        return false;
    }

}