<?php

namespace Planaday\Utility\FormBuilder;

/**
 * @template T
 */
interface InputField extends LayoutItem, SettableData {

	public function getName(): string;

	public function getDescription(): string;

	/**
	 * @return T|null
	 */
	public function getValue(): mixed;

	/**
	 * @return T|null
	 */
	public function getDefaultValue(): mixed;
	public function getAutocomplete(): string;

	public function isSet(): bool;

	public function addValidator(Validator ...$validators): static;
	public function setIndex(string $index): static;
	public function setDescription(string $description): static;
	public function setName(string $name): static;
	public function setDefaultValue(mixed $defaultValue): static;
	public function setAutocomplete(string $autocomplete): static;

	/**
	 * @param callable(T|null $value):void $callback gets called at setValue after sanitization with the new value
	 *
	 * @return $this
	 */
	public function addSetCallback(callable $callback): static;
}