<?php

namespace Planaday\Utility\FormBuilder;

use JsonSerializable;

/**
 * @template T
 */
interface DataType extends JsonSerializable {
	/**
	 * @param mixed $value
	 *
	 * @throws InvalidFormDataException
	 * @return T|null
	 */
	public function sanitize(mixed $value): mixed;

	public function addValidator(Validator ...$validators): static;

	/**
	 * @param T|null $value
	 *
	 * @return true|InvalidFormDataException
	 */
	public function validate($value): bool|InvalidFormDataException;
}