<?php
/**
 * @package   Essentials YOOtheme Pro 2.2.16 build 0813.1608
 * @author    ZOOlanders https://www.zoolanders.com
 * @copyright Copyright (C) Joolanders, SL
 * @license   http://www.gnu.org/licenses/gpl.html GNU/GPL
 */

namespace ZOOlanders\YOOessentials\Form;

use ZOOlanders\YOOessentials\Vendor\Respect\Validation\Validator;

$input = require __DIR__ . '/../form_input_text/element.php';

return array_merge($input, [
    'validation' => function ($control, Validator $validator) {
        $props = $control['props'];

        $min = $props['min'] ?? null;
        $max = $props['max'] ?? null;
        $required = $props['required'] ?? false;

        if (isset($min)) {
            $validator->min($min);
        }

        if (isset($max)) {
            $validator->max($max);
        }

        if ($required) {
            $validator->notOptional();
        }

        return $validator;
    },
]);
